raggy99 Posted February 21, 2012 Share Posted February 21, 2012 I have been getting errors with the code below. Can someone please tell me where I went Wrong. <?php define('DB_NAME', 'raggsweb_oltusers'); define('DB_USER', 'raggsweb_raggs'); define('DB_PASSWORD', 'XXXXXXX'); define('DB_HOST', 'localhost'); $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); if (!$link) { die('çould not connect: '. mysql_error()); } mysql_select_db(DB_NAME, $link); $result = mysql_query ('SELECT * FROM Users') or die ('Error: '.mysql_error ()); echo "<table> <tr> <td>First Name</td> <td>Last Name</td> <td>Title</td> <td>Location</td> <td>Office Phone</td> <td>Office Extention</td> <td>Mobile</td> <td>Edit</td> <td> </td> </tr> </table>" while($row = mysql_fetch_array($result)); { echo '<tr>'; echo '<td>'.$row['Firstname'].'</td>'; echo '<td>'.$row['Lastname'].'</td>'; echo '<td>'.$row['Title'].'</td>'; echo '<td>'.$row['Location'].'</td>'; echo '<td>'.$row['Officephone'].'</td>'; echo '<td>'.$row['Officeextention'].'</td>'; echo '<td>'.$row['Mobile'].'</td>'; echo '<td>'.$row['Email'].'</td>'; echo '<td>' '</td>'; echo '</tr>'; } mysql_close(); ?> Thanks In Advance Link to comment https://forums.phpfreaks.com/topic/257444-code-check/ Share on other sites More sharing options...
Brentatechnologies Posted February 21, 2012 Share Posted February 21, 2012 Hey There, I don't know if it matters with your database connect setup <?php define('DB_NAME', 'raggsweb_oltusers'); define('DB_USER', 'raggsweb_raggs'); define('DB_PASSWORD', 'XXXXXXX'); define('DB_HOST', 'localhost'); $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); should be <?php define('DB_HOST', 'localhost'_; define('DB_USER', 'raggsweb_raggs'); define('DB_PASSWORD', 'XXXXXXX'); $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); (It may be that your not corresponding in order) or $result = mysql_query ('SELECT * FROM Users') or die ('Error: '.mysql_error ()); possibly $query = mysql_query("select * FROM Users WHERE username = '$user'"); // Queries the Database to check if the user already exsists Change the values that are different to the values from your database Let me know if this wasn't the problem... This is all I could see may be wrong Link to comment https://forums.phpfreaks.com/topic/257444-code-check/#findComment-1319484 Share on other sites More sharing options...
Andy-H Posted February 21, 2012 Share Posted February 21, 2012 Have you got error reporting on? ini_set('display_errors', 'On'); error_reporting(E_ALL); What errors are you getting? Also your echo '</table>'; statement, should come after your mysql loop. Link to comment https://forums.phpfreaks.com/topic/257444-code-check/#findComment-1319487 Share on other sites More sharing options...
cyberRobot Posted February 21, 2012 Share Posted February 21, 2012 You're missing a semicolon after displaying the table header: <?php //... echo "<table> <tr> <td>First Name</td> <td>Last Name</td> <td>Title</td> <td>Location</td> <td>Office Phone</td> <td>Office Extention</td> <td>Mobile</td> <td>Edit</td> <td> </td> </tr> </table>" //<--- ADD SEMICOLON HERE //... ?> The while loop shouldn't have a semicolon after it: <?php //... while($row = mysql_fetch_array($result)); //<--- REMOVE SEMICOLON { //... ?> Also, as Andy-H stated, the close tag for the table should go after all the table rows. <?php //... echo "<table> <tr> <td>First Name</td> <td>Last Name</td> <td>Title</td> <td>Location</td> <td>Office Phone</td> <td>Office Extention</td> <td>Mobile</td> <td>Edit</td> <td> </td> </tr>"; while($row = mysql_fetch_array($result)) { echo '<tr>'; //... echo '</tr>'; } echo '</table>'; //... ?> For bonus points, you should also utilize the table heading tag and scope attribute. <?php //... echo "<table> <tr> <th scope='col'>First Name</th> <th scope='col'>Last Name</th> <th scope='col'>Title</th> <th scope='col'>Location</th> <th scope='col'>Office Phone</th> <th scope='col'>Office Extention</th> <th scope='col'>Mobile</th> <th scope='col'>Edit</th> <th scope='col'> </th> </tr>"; //... ?> Link to comment https://forums.phpfreaks.com/topic/257444-code-check/#findComment-1319530 Share on other sites More sharing options...
cyberRobot Posted February 21, 2012 Share Posted February 21, 2012 I just noticed the following: <?php //... echo '<td>'.$row['Email'].'</td>'; echo '<td>' '</td>'; //<--- THE NON-BREAKING SPACE CHARACTER NEEDS TO BE INSIDE THE STRING --- SHOULD BE: echo '<td> </td>'; echo '</tr>'; //... ?> Link to comment https://forums.phpfreaks.com/topic/257444-code-check/#findComment-1319532 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.