forumnz Posted January 26, 2008 Share Posted January 26, 2008 Why am I getting this? It says this: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /usr/local/www/vhosts/site/httpdocs/Browse/Listing/listinginfo.php on line 5 With this as the code: <?php include('connectdb.php'); $result = mysql_query("SELECT * FROM `fflists` WHERE `id`={$id} AND `active`='1' LIMIT 1"); $num = mysql_num_rows($result); while($row = mysql_fetch_array($result)) { $business_name = $row['business_name']; $listid = $row['id']; $dcr = $row['dcr']; $add1 = $row['add1']; } ?> Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/87859-solved-warning-mysql_fetch_array/ Share on other sites More sharing options...
marcus Posted January 26, 2008 Share Posted January 26, 2008 mysql error most likely <?php include ('connectdb.php'); $sql = "SELECT * FROM `fflists` WHERE `id`='" . $id . "' AND `active`='1' LIMIT 1"; $result = mysql_query($sql) or die(mysql_error()); $num = mysql_num_rows($result); while ($row = mysql_fetch_array($result)) { $business_name = $row['business_name']; $listid = $row['id']; $dcr = $row['dcr']; $add1 = $row['add1']; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/87859-solved-warning-mysql_fetch_array/#findComment-449445 Share on other sites More sharing options...
forumnz Posted January 26, 2008 Author Share Posted January 26, 2008 Comes up with: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AND `active`='1' LIMIT 1' at line 1 Quote Link to comment https://forums.phpfreaks.com/topic/87859-solved-warning-mysql_fetch_array/#findComment-449455 Share on other sites More sharing options...
darkfreaks Posted January 26, 2008 Share Posted January 26, 2008 <?php $sql = 'SELECT * FROM `fflists` WHERE `id`='$id ' AND `active`='1' LIMIT 1';?> Quote Link to comment https://forums.phpfreaks.com/topic/87859-solved-warning-mysql_fetch_array/#findComment-449471 Share on other sites More sharing options...
marcus Posted January 26, 2008 Share Posted January 26, 2008 That's going to produce an error darkfreaks. $sql = 'SELECT * FROM `fflists` WHERE `id`='.$id .' AND `active`="1" LIMIT 1'; Quote Link to comment https://forums.phpfreaks.com/topic/87859-solved-warning-mysql_fetch_array/#findComment-449476 Share on other sites More sharing options...
revraz Posted January 26, 2008 Share Posted January 26, 2008 $sql = "SELECT * FROM `fflists` WHERE `id`='$id' AND `active`= 1 LIMIT 1";?> Quote Link to comment https://forums.phpfreaks.com/topic/87859-solved-warning-mysql_fetch_array/#findComment-449478 Share on other sites More sharing options...
phpSensei Posted January 26, 2008 Share Posted January 26, 2008 Where is $id ? Quote Link to comment https://forums.phpfreaks.com/topic/87859-solved-warning-mysql_fetch_array/#findComment-449480 Share on other sites More sharing options...
darkfreaks Posted January 26, 2008 Share Posted January 26, 2008 <?php sql = "SELECT * FROM `fflists` WHERE `id`='"$id"' AND `active`= '1' LIMIT 1";?> Quote Link to comment https://forums.phpfreaks.com/topic/87859-solved-warning-mysql_fetch_array/#findComment-449483 Share on other sites More sharing options...
marcus Posted January 26, 2008 Share Posted January 26, 2008 Still an error for your darkfreaks Quote Link to comment https://forums.phpfreaks.com/topic/87859-solved-warning-mysql_fetch_array/#findComment-449484 Share on other sites More sharing options...
darkfreaks Posted January 26, 2008 Share Posted January 26, 2008 corrected it Quote Link to comment https://forums.phpfreaks.com/topic/87859-solved-warning-mysql_fetch_array/#findComment-449486 Share on other sites More sharing options...
phpSensei Posted January 26, 2008 Share Posted January 26, 2008 <?php sql = "SELECT * FROM `fflists` WHERE `id`='"$id"' AND `active`= '1' LIMIT 1";?> I ment where is the value of it. Quote Link to comment https://forums.phpfreaks.com/topic/87859-solved-warning-mysql_fetch_array/#findComment-449522 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.