Jump to content


Photo

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


  • Please log in to reply
4 replies to this topic

#1 princess

princess
  • New Members
  • Pip
  • Newbie
  • 1 posts
  • Locationholland

Posted 29 December 2002 - 11:22 PM

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[email];
echo \"\">\";
echo $myrow[email];
echo \"</a>\";
echo \"<br>\";
echo \"<b> Homepage:</b>\";
echo \"<br>\";
echo \"<a href=\"\";
echo $myrow[url];
echo \"\">\";
echo $myrow[url];
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
~..i do beleive in fairytales..~

#2 effigy

effigy
  • Staff Alumni
  • Advanced Member
  • 3,600 posts
  • LocationIL

Posted 31 December 2002 - 12:18 AM

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.
Regexp | Unicode Article | Letter Database
/\A(e)?((1)?ff(?:(?:ig)?y)?|f(?:ig)?)\z/

#3 delamitri

delamitri
  • New Members
  • Pip
  • Newbie
  • 7 posts
  • LocationUK

Posted 08 January 2003 - 04:31 PM

easiest way, and i guess that the last poster is right
print mysql_error();

after the query call.


Kevin

#4 munnabd_02

munnabd_02
  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 06 December 2006 - 03:46 PM

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];
?>


#5 artacus

artacus
  • Members
  • PipPipPip
  • Advanced Member
  • 737 posts
  • LocationOlympia, WA

Posted 06 December 2006 - 09:12 PM

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"
artacus

-- Trust your leaders, depend on your government, don't question the media... and this won't hurt a bit. --




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users