homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

Warning: mysql fetch array() expects parameter 1 to be resource.

 10:40 am on Jan 5, 2013 (gmt 0)

hey guys, i'm a beginner in php.
i'm so confused.
i know my query is correct but this error always appear:
Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean...

here's the code:


echo "<form action='catps.php' method='get'>";

echo "<h3><center>Choose Object Class / Account Codes</center></h3>";
$result = mysql_query("SELECT * FROM `account_codes`");
echo "<table><tr><th width='150px'>Object Class</th><th align='center' width='450px'>Name</th><th align='center' width='30px'>Choose</th></tr>";

echo "<td align='center'>".$row['Account_Code_Number']."</td>";
echo "<td>".$row['Title']."</td>";
echo "<input type='hidden' value=".$row['Account_Code_Number']." name='acctcdnum' />";
echo "<input type='hidden' value='".$row['Title']."' name='accttitle' />";
echo "<td><input type='checkbox' name='check[".$i."]' float='right' value='".$row['Account_Code_Number']."'/></td>";
echo "</tr>";
echo "</table>";
echo "<br/><br/><center><input type='submit' name='sub' value='SUBMIT' float='right'/></center>";
echo "<br/><br/><br/>";

echo "</form>";

$sql = mysql_query("insert into `account_codes_classified`(`Account_Code_Number`,`Category_Number`) values (`".$check[$i]."`,100)");
echo "Successful";}

thanks in advance.



 3:58 am on Jan 6, 2013 (gmt 0)

If you're a beginner, then do yourself a BIG favour:
- forget about the obsolete mysql interface
- switch to the mysqli (note the i) interface and use prepared statements

That way you would have quite a big reduction in security bugs. (BTW: if you get this to work: it's begging for getting hacked with sql injection)


 5:38 am on Jan 6, 2013 (gmt 0)

... wherever you have got this ` change to this ' and that code should run fine (did you notice the difference).

Of course, security is a different issue.


 8:04 am on Jan 6, 2013 (gmt 0)

Unless you deleted some code from the original, I'd say your call to mysql_query failed because you haven't opened a connection to the database.


 1:47 pm on Jan 8, 2013 (gmt 0)

your best solution : [php.net...]
mysql_ everything is deprecated

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved