mikebyrne Posted March 18, 2008 Share Posted March 18, 2008 I'm trying to retrive data from my database and fill the table but all I mange to get is "The users could not be retrieved" and ive no idea where im going wrong my code is <?php # Script - StudentEnrolled.php // This will retrieve all the records from the Student table $page_title = 'View the Current Users'; // Page header echo '<h1 id="mainhead">Registered Users </h1>'; require_once ('mysql_connect.php'); //Connect to database //Make a query $query = "SELECT (Surname, ', ', Name) AS name, DATE FORMAT(Date_Registered, '%M %d, %Y') AS date FROM student_entry_details ORDER BY Date_Registered ASC"; $result = mysql_query ($query); // Run query if ($result) { // If it ran OK , display the records. // Create table echo '<table align="center" cellspacing="0" cellspacing="5"> <tr><td align="left"><b>Name</b></td> <td align="left"><b>Date_Registered</b> <td align="right"><b>CV Info</b> </td></tr>'; //Fetch and print all records. while ($row = mysql_fetch_array ($result, MYSQL_ASSOC)) { echo '<tr><td align="left">' . $row['name'] . '</td><td align="left">' . $row['date'] . '</td></tr>'; } echo '</table>'; mysql_free_result ($result); //Free up the resources. } else { // If it did not run OK. echo '<p class="error">The users could not be retrieved.</p>'; } mysql_close(); //Close the database connection ?> Quote Link to comment Share on other sites More sharing options...
AdRock Posted March 18, 2008 Share Posted March 18, 2008 Just a guess DATE FORMAT(Date_Registered, '%M %d, %Y') maybe DATE FORMAT(Date_Registered, '%M, %d, %Y') Quote Link to comment Share on other sites More sharing options...
treehugger88 Posted March 18, 2008 Share Posted March 18, 2008 I would guess you are getting 0 records returned. Are you sure you have stuff in the database? Quote Link to comment Share on other sites More sharing options...
AdRock Posted March 18, 2008 Share Posted March 18, 2008 Either that or there is something wrong with the query such as field names 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.