Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

php and Mysql

Status
Not open for further replies.

hecheng

Programmer
Jun 23, 2003
7
CA
this is my PHP code

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot;>
</head>

<body>
<?php
$mylink=mysql_connect(&quot;localhost&quot;, &quot;root&quot;, &quot;12456&quot;);
mysql_select_db(&quot;elementary&quot;, $mylink);
$sql=&quot;select * from elementary&quot;;
$result=mysql_query($sql);
while($myarray=mysql_fetch_array($result))
{
}
?>
</body>
</html>

web server gives me an error
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in f:\database\test.php
on line 13 while($myarray=mysql_fetch_array($result))

how can i solve this problem??
thanks for your help

 
try this:
$result=mysql_query($sql) or die(mysql_error());

the problem may be in the query execution....


Known is handfull, Unknown is worldfull
 
I'm thinking of the top of my head here but try

while ($result.next()){}
otherwise

while($myarray==mysql_fetch_array($result))
{
}
where == is logical equals and = assigns, or am I reading this wrong??
 
the while loop is meant to assign, so == is not the problem...

Known is handfull, Unknown is worldfull
 
Oh well, I'm abit of a newb myself :)
I have a similar problem and put it down to trying to read an empty set of results. Add a couple of dbase entries and see if that fixes it, otherwise I have no idea.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top