nativeg Posted November 20, 2003 Posted November 20, 2003 I am atempting to build a small database using php and MySql. When I try to connect, I do not get any MySql errors but I am not able to read any of the data I have built into the small database with the phpadmin tools on the server. Does anyone have any suggestions? Nativeg Quote
TCH-Andy Posted November 20, 2003 Posted November 20, 2003 Hi Nativeg Welcome to the family I'm not sure without a little more information. Are the initial connections correct? Name of host - localhost Database Name - cpanelusername_dbname Datbase User Name - cpanelusername_dbusername I assume so as you are not getting any errors. You say you can not read any data. Do you get an error message? or the wrong data? or just blank data? Quote
nativeg Posted November 26, 2003 Author Posted November 26, 2003 The Host, Username and Database name all seem to be correct. After I go through the connect procedure to the database This is my code: All I want to do at this time is to query the db so I can read the files I have already added using the tools TCM provides Here is my query code: I first define the DB_HOST, DB_USER,, DB_PASSWORD, and the DB_NAME. Then my code continues as: $dbh=mysql_connect (DB_HOST, DB_USER, DB_PASSWORD) or die ('I cannot connect to the database because: ' . mysql_error()); @mysql_select_db (DB_NAME) or die ('I cannot connect to the database because: ' . mysql_error()); echo "Database is (DB_NAME) and has connected properly: <p>"; $query ="SELECT * FROM dbase22 LIMIT 0, 30" ; $result = mysql_query($query ) or die ('I cannot read the database because: ' . mysql_error()); echo "$result <br>" ; echo " . . . were the results of this show query <br><br><br>"; echo " <br><br> $query "; echo '<table align="center" cellspacing="2" cellpadding="2"> <tr> <td align="left"><b>CALLSIGN</b></td><td align="left"><b>NAME</b></td><td align="left"><b>EMAIL</b> </td> </tr>'; // Fetch the records. while ($row = mysql_fetch_array($result, MYSQL_NUM)) { echo" <tr><td align = \"left\"> $row[0]</td><td align = \"left\"> $row[1]</td> <td align = \"left\"> $row[2]</td></tr> \n"; } echo '</table>'; mysql_free_result($result); }else{ echo'<p> no info due to a system error</p> <p>'. mysql_error().'</p>'; } mysql_close(); Ok So where did I go wrong? Quote
surefire Posted November 26, 2003 Posted November 26, 2003 It might help to turn error reporting up. By default, it is set very low at TCH. Try putting this at the start of your script >error_reporting(E_ALL); Quote
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.