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>'; } Quote Link to comment 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); Quote Link to comment 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()); Quote Link to comment 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 } Quote Link to comment 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.