PHP - Db Not Connected
if (!$db_conn = new mysqli('localhost', 'poll', 'poll', 'poll'))
Similar TutorialsI am just starting my first php mysql html page project and having a small issue. So I have a phpMyAdmin server running a database called "Dive_Log_DB". There is a table in this database called "DL_Logbook" I have the following code to test connection to the phpMyAdmin server, test the connection to the Dive_Log_DB database and then create a two column table to just test outputting data to (once I get this working I will work on adding the rest of the data). If I adjust the password to be wrong, I get my error message. If I adjust the database name to be misspelled I get my error message. By correct the information I get my success output statement..so I believe I am connecting to everything correctly. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Web DIve Log Test</title> </head> <?php //Connect to phpMyAdmin: $SQLConnect = mysql_connect('localhost', 'MYUSERNAME', 'MYPASSWORD'); If(!$SQLConnect){ die(' ERROR: COULD NOT CONNECT TO SQL SERVER! ' .mysql_error()); } echo 'SQL SERVER CONNECTION SUCCESSFUL!' ."<br>"."<br>"; //Connect to Dive Log Database: $DBConnect = mysql_select_db('Dive_Log_DB', $SQLConnect); if(!$DBConnect){ die(' ERROR: COULD NOT CONNECT TO DATABASE! ' . mysql_error()); } echo 'DATABASE CONNECTION SUCCESSFUL!'."<br>"."<br>"; //Select which table to pull data from: $records = mysql_query('SELECT * FROM DL_Logbook'); //Pull data for table: While($row = mysql_fetch_assoc($records)){ echo "<tr>"; echo "<td>".$row['number']."</td>"; echo "<td>".$row['depth']."</td>"; echo "</tr>"; }//end while ?> <body> <table width = "100" border="1" cellpadding="1" cellspacing="1" <tr> <th>#</th> <th>Depth</th> <tr> </table> </body> </html>The above code outputs the following page: It is as if for some reason everything is connected, but no data is being grabbed. Does anyone have an idea why I am not getting any data in my table? Thank you for any advise in advance. |