Forum Moderators: coopster
here is my problem im learning php and im having problems doing a simple query from mysql.. and i get this error
Call to a member function on a non-object in /nfs/cust/3/85/95/659583/web/php/TMP44bo8vpfyi.php on line 53
here's my code. please help me out :P
<?php
$q= mysql_query ('SELECT name FROM items');
while ($row = $q -> mysql_fetc_array ()) {
print "$row[0], $row[1] \n";
?>
You need to make a connection to the database first. There is a nice example in our PHP Forum Library [webmasterworld.com] that describes the Basics of extracting data from MySQL [webmasterworld.com] that you might want to read through.
$q= mysql_query ("SELECT * FROM items ");
$showquery = mysql_fetch_array($q);
while ($row = $showquery){$row = mysql_fetch_assoc($q);
print $row['name'] ;}
try this thread for the basics
Basics of extracting data from MySQL using PHP [webmasterworld.com]
<added>oops, coopster already mentioned it, have a look it will show you exactly the thing you are having problems with