Jump to content

Archived

This topic is now archived and is closed to further replies.

princess

mysql_fetch_array(): supplied argument is not a valid..

Recommended Posts

hey another question from me.. still working on the guestbook thing, but started over with a new one, problems i dont understand came on my way..

 

please can you look at this and explain the mistake to me? i really dont see whats wrong.

 

This is the warning i receive while i test it:

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:FoxServwwwtestguestbookindex.php on line 19

 

this is my code:

 

<?

$db = mysql_connect(\"lxxx\",\"xxx\",\"xxx\");

mysql_select_db (\"testgastenboek\", $db);

 

$sql = \'SELECT * FROM `testgastenboek`;\';

$result = mysql_query($sql,$db);

 

while ( $myrow = mysql_fetch_array($result) )

{

echo \"<b>Name:</b>\";echo \"<br>\";

echo $myrow[name];

echo \"<br>\";

echo \"<b> Email:</b>\";

echo \"<br>\";

echo \"<a href=\"mailto:\";

echo $myrow;

echo \"\">\";

echo $myrow;

echo \"</a>\";

echo \"<br>\";

echo \"<b> Homepage:</b>\";

echo \"<br>\";

echo \"<a href=\"\";

echo $myrow;

echo \"\">\";

echo $myrow;

echo \"</a>\";

echo \"<br>\";

echo \"<b>Comment:</b>\";

echo \"<br>\";

echo $myrow[comment];

echo \"<br>\";

echo \"<br>\";

echo \"<a href=changeform.php?id=$myrow[id]>[change]</a>\";

echo \"&nbsp\";

echo \"<a href=changeform.php?id=$myrow[id]>[delete]</a>\";

echo \"<hr noshadow width=\"300\" align=\"left\" color=\"#FF6600\">\";

}

?>

 

 

i hope this is enough information..

 

thanks in advance, Princess

Share this post


Link to post
Share on other sites

the error means that the query never executed, therefore it has nothing to be identified with. this means there is a problem with any of these: (a) the database connection; (B) choosing a database; © running the query

 

i think this extra \';\' here is the problem:

$sql = \'SELECT * FROM `testgastenboek`;\';

semicolons are not needed to end a query when using php, opposed to the mysql command line.

Share this post


Link to post
Share on other sites

easiest way, and i guess that the last poster is right

print mysql_error();

 

after the query call.

 

 

Kevin

Share this post


Link to post
Share on other sites

progli@progli.awardspace.com here my data show 'tt' but other server side not work Why ? Please solve and mail me: munnabd_02@yahoo.com

 

<?php

//if you view 'tt' mail me(munnabd_02@yahoo.com)

$cnn=mysql_connect('db1.awardspace.com', 'progli_progli', '8013731')

or die ("Cannot connect to MySQL server: " . mysql_error());

mysql_select_db('progli_progli')

or die ("Cannot connect to db: " . mysql_error());

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

$row=mysql_fetch_row($result);

echo $row[1];

?>

 

Share this post


Link to post
Share on other sites

Change

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

to

$result=mysql_query("select *from user") or die(mysql_error() . "<br>$query");

 

and

"select *from"

to

"select * from"

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.