damnedgentleman Posted April 13, 2011 Share Posted April 13, 2011 Hi everyone. I confess, I've been learning PHP now for a very short amount of time and really enjoy using it! However, I do seem to be having a spot of bother using it in conjunction with MySQL. So far all I've managed to do is get a couple of table creation scripts to work. I've spent today trying to get the following code to function but I'm not having much luck. Running the script returns the error message: "Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home/blah/blah/php/displayEvents.php on line 19" Can anybody tell me where I've gone wrong? <?php //database connection information. include ("dbConnect.php"); //MySQL query assigned to variable. Selects data from the events table for //up and coming events. $queryTable = "SELECT eventDate, eventName, eventDescLong, eventEntryFee FROM eventsTable WHERE eventDate >= CURDATE() AND eventDate <= DATE_ADD(CURDATE(), INTERVAL 7 DAY) ORDER BY EventDate ASC"; $result = mysql_query($connection, $queryTable) or die (mysql_error()); //Pulls data from events table and assigns it to an array. while($row = mysql_fetch_array($result)) { //Assigns table fields from array to variables. $eventDate = $row ['eventDate']; $eventName = $row ['eventName']; $eventDescLong = $row ['eventDescLong']; $eventEntryFee = $row ['eventEntryFee']; //displays event information. echo "<h1>$eventArtists</h1>"; echo "<h2>$eventDate Tax: £$eventEntryFee</h2>"; echo "<p>$eventDescLong</p><br>"; } mysql_close ($connection); ?> Quote Link to comment https://forums.phpfreaks.com/topic/233561-mysql_query-supplied-argument-is-not-a-valid-mysql-link-resource/ Share on other sites More sharing options...
DavidAM Posted April 13, 2011 Share Posted April 13, 2011 $result = mysql_query($connection, $queryTable) You have the parameters backwards. The query comes first, and the connection comes second. Quote Link to comment https://forums.phpfreaks.com/topic/233561-mysql_query-supplied-argument-is-not-a-valid-mysql-link-resource/#findComment-1200962 Share on other sites More sharing options...
damnedgentleman Posted April 13, 2011 Author Share Posted April 13, 2011 Ah! That seems to have helped somewhat. Thank you very much. Quote Link to comment https://forums.phpfreaks.com/topic/233561-mysql_query-supplied-argument-is-not-a-valid-mysql-link-resource/#findComment-1201056 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.