Problem in fetching data from mysql database [solved]

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ravi1511
Forum Newbie
Posts: 2
Joined: Fri Oct 26, 2007 8:15 pm

Problem in fetching data from mysql database [solved]

Post 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]
ashrafzia
Forum Commoner
Posts: 37
Joined: Wed Sep 28, 2005 12:23 pm

Re: Problem in fetching data from mysql database

Post 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";
ravi1511
Forum Newbie
Posts: 2
Joined: Fri Oct 26, 2007 8:15 pm

Thanks

Post 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
Post Reply