mattsolomon Posted March 7, 2011 Share Posted March 7, 2011 Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/largemus/public_html/assets/inc/upcoming.php on line 15 i have hidden connection details for this example <?php $host=""; // Host name $username=""; // Mysql username $password=""; // Mysql password $db_name=""; // Database name $tbl_name=""; // Table name // Connect to server and select database. mysql_connect("$host", "$username", "$password")or die("cannot connect server "); mysql_select_db("$db_name")or die("cannot select DB"); $sql="SELECT * FROM $tbl_name WHERE user = $session->clientid ORDER BY date ASC LIMIT 3;"; $result=mysql_query($sql); while($rows=mysql_fetch_array($result)){ ?> <div style="width:385px;"> <table style="width: 385px; text-align:center;"> <tr> <td style="width: 121px"><h3>Client</h3></td> <td style="width: 100px"><h3>Occasion</h3></td> <td style="width: 80px"><h3>Location</h3></td> <td><h3>Date</h3></td> </tr> </table> <table style="width: 385px"> <tr> <td style="width: 121px"> <p><? echo $rows['clientid']; ?></p> </td> <td style="width: 100px"> <p><? echo $rows['occasion']; ?></p> </td> <td style="width: 80px"> <p><? echo $rows['location']; ?></p> </td> <td> <p><? echo $rows['date']; ?></p> </td> </tr> </table> </div> <? } mysql_close(); //close database ?> Link to comment https://forums.phpfreaks.com/topic/229819-trying-to-list-users-events-by-user-id-getting-this-error/ Share on other sites More sharing options...
cunoodle2 Posted March 7, 2011 Share Posted March 7, 2011 You need to use single quotes around the user like this.. $sql="SELECT * FROM $tbl_name WHERE user = '".$session->clientid."' ORDER BY date ASC LIMIT 3;"; This MAY work too.. $sql="SELECT * FROM $tbl_name WHERE user = '$session->clientid' ORDER BY date ASC LIMIT 3;"; If not then this $sql="SELECT * FROM $tbl_name WHERE user = '{$session->clientid}' ORDER BY date ASC LIMIT 3;"; Link to comment https://forums.phpfreaks.com/topic/229819-trying-to-list-users-events-by-user-id-getting-this-error/#findComment-1183779 Share on other sites More sharing options...
mattsolomon Posted March 7, 2011 Author Share Posted March 7, 2011 thanks, one more thing, when it repeats the 3 events it also copies the first table of "client" "occasion" "location" "date" how can i make it just copy the table with the data in it? insted of copying the tittle table? (if that makes sense) Link to comment https://forums.phpfreaks.com/topic/229819-trying-to-list-users-events-by-user-id-getting-this-error/#findComment-1183782 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.