Web Hosting Talk







View Full Version : Using PHP with MySQL on Alabanza


MadMax82
11-18-2000, 06:29 PM
Ok gang,

I am a complete novice with PHP and MySQL (trying to expand my knowledge ya know!). I have created a database on an Alabanza account and I have no problem creating tables, variables, etc. And I have put some sample data in the database with no problems. However when I use the PHP example listed in the Alabanza knowledgebase I am getting the following error:

Warning: 0 is not a MySQL result index in /home/websat/websatori-www/test3.php on line 23

I have gone so far as to create a database with the same table name and variables as the example. Here is my PHP code (with login and password deleted):

<?
mysql_connect("localhost", *****, ******);
$result = mysql(mydatabase, "select * from products");
$i = 1;

while($i <= 3) {
echo mysql_result($result,$i,"prodid");*
<p>

echo mysql_result($result,$i,"name");*</p>
<p>

echo mysql_result($result,$i,"price");*</p>
<p>

$i++;}
?></p>


I would greatly appreciate it if any of you experts out there could give me an idea of what I am missing. Is it the PHP code or do I need to specify something in MySQL (I have a key variable). Any help would be greatly appreciated!

KDAWebServices
11-19-2000, 09:09 AM
$result = mysql_db_query("mydatabase", "select * from products");

Should do the trick in place of the $result = that you have got, for future refrence take a look at http://www.php.net/mysql.

If you need any more help then feel free to ICQ me.

Forgot the quotes round mydatabase

MadMax82
11-19-2000, 10:51 AM
That was it! Time to get some books and do some online reading. Thanks again for your help!

Marty
11-20-2000, 10:44 AM
If you have only connected to one database, you could also use,

$result = mysql_query("select * from products");

Less to type with the same end result.