Page 1 of 1

Problem in fetching data from mysql database [solved]

Posted: Fri Oct 26, 2007 8:33 pm
by ravi1511
hi

i m new in php programming

i have made simple page to retrieve information from mysql database but the error showed is this:

mysql_fetch_array(): supplied argument is not a valid MySQL result resource in c:\wamp\www\sampe app\sample.php on line 21

Just i want to print data from database

please reply
wht can i do for it[/syntax]

Re: Problem in fetching data from mysql database

Posted: Fri Oct 26, 2007 11:14 pm
by ashrafzia
ravi1511 wrote:hi

i m new in php programming
i have made simple page to retrieve information from mysql database but the error showed is this:
mysql_fetch_array(): supplied argument is not a valid MySQL result resource in c:\wamp\www\sampe app\sample.php on line 21
Just i want to print data from database
please reply
wht can i do for it[/syntax]
Your supplied argument is invalid or you may have a spell mistake.
Try like this:

Code: Select all

$sql = "select * from mytable";
$result = mysql_query($sql, $connection) or die(mysql_error());
while($row=mysql_fetch_array($result)){
          $id=$row['id'];
          $name=$row['name'];
          
}
       echo "$id<br>$name";

Thanks

Posted: Sat Oct 27, 2007 10:44 am
by ravi1511
Thanks for giving me reply so quickly.

My problem is now solved
problem is in connection string.


i h made one use in mysql with password
and use it in connection string
but that user is not working

so when i used localhost with blank pass and blank username
it worked

once again thanks for replying me

bye