maxudaskin Posted November 4, 2007 Share Posted November 4, 2007 Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home/thelyonn/public_html/spilledinkmac/include/functions.php on line 70 Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/thelyonn/public_html/spilledinkmac/include/functions.php on line 72 Any Ideas? function viewpoems($limit){ $viewpoemsql = "SELECT * FROM entries_literature ORDER BY eid DESC LIMIT 2"; $viewpoemquery = mysql_query(viewpoemsql,$con); echo '<table width="162" border="0" cellspacing="0" cellpadding="0">'; while($viewpoemresult = mysql_fetch_array($viewpoemquery)){ echo '<tr>'; echo '<td colspan="2"><div align="center">Title</div></td>'; echo '</tr>'; echo '<tr>'; echo '<td>'; echo '<div align="left" class="style1">Name</div></td>'; echo '<td><div align="right" class="style1">Date</div></td>'; echo '</tr>'; echo '<tr>'; echo '<td colspan="2"><div align="center">TEXT</div></td>'; echo '</tr>'; } echo '</table>'; } Link to comment https://forums.phpfreaks.com/topic/75964-not-a-valid-mysql-link-resource/ Share on other sites More sharing options...
Daukan Posted November 4, 2007 Share Posted November 4, 2007 You need to pass the $con variable into the function or not use the connection argument. PHP will always use the last open connection if one isn't supplied. This $viewpoemquery = mysql_query($viewpoemsql,$con); TO $viewpoemquery = mysql_query($viewpoemsql); Link to comment https://forums.phpfreaks.com/topic/75964-not-a-valid-mysql-link-resource/#findComment-384531 Share on other sites More sharing options...
BlueSkyIS Posted November 4, 2007 Share Posted November 4, 2007 few things... $viewpoemquery = mysql_query(viewpoemsql,$con); viewpoemsql is missing it's dollar sign. what is $con? i suggest you use or die (mysql_error()) for more info. $viewpoemquery = mysql_query($viewpoemsql,$con) or die(mysql_error()); Link to comment https://forums.phpfreaks.com/topic/75964-not-a-valid-mysql-link-resource/#findComment-384532 Share on other sites More sharing options...
marcus Posted November 4, 2007 Share Posted November 4, 2007 By appropriateness of a function, the variable $con is obviously defined OUTSIDE the function. So you need to globalize the variable. $con = "connection to db"; function whatever($this){ global $con; // other stuff } Link to comment https://forums.phpfreaks.com/topic/75964-not-a-valid-mysql-link-resource/#findComment-384542 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.