jay7981 Posted April 24, 2009 Share Posted April 24, 2009 i have a php page that should display results of a mysql query inside a table ... however no matter how many entries i have in the table it wont display any results only the headers any help would be great i have checked and verified the login data several times over it is all correct i have just replaced them with my*** for posting. i have also verified that all fields are correct and matching. <html> <head> </head> <body> <form name="action" id="action" method="post" action="<?=$_SERVER['PHP_SELF']?>"> <? $MyUsername="myuser"; $MyPassword="mypass"; $MyDatabase="mydb"; $MyTable="mytable"; mysql_connect(localhost,$MyUsername,$MyPassword) or die( "Unable to conect to database"); @mysql_select_db($MyDatabase) or die( "Unable to select database"); if($_POST['perform']) { foreach($_POST as $id) { mysql_query("DELETE FROM $MyTable WHERE ID='$id' LIMIT 1"); } } $query="SELECT * FROM $MyTable ORDER BY ID DESC" or die( "Unable to select table"); $result=mysql_query($query); $num=mysql_numrows($result); echo "<table width=100% border=0 align=center cellpadding=4 cellspacing=1 bordercolor=#333333 bgcolor=#FCFCFC> <tr bgcolor=#990000> <th height=30 align=center><span class=tab_head>Number</span></th> <th height=30><span class=tab_head>Boat ID</span></th> <th height=30><span class=tab_head>TS Name</span></th> <th height=30><span class=tab_head>Boat Name</span></th> <th height=30><span class=tab_head>First Name</span></th> <th height=30><span class=tab_head>Last Name</span></th> <th height=30><span class=tab_head>Boat Level</span></th> <th height=30><span class=tab_head>Pirate Level</span></th> <th height=30><span class=tab_head>Current EP</span></th> <th height=30><span class=tab_head>Current Guild</span></th> <th height=30><span class=tab_head>Join Shy?</span></th> <th height=30><span class=tab_head>Country</span></th> <th height=30><span class=tab_head>Other Boats</span></th> <th height=30><span class=tab_head>Comments</span></th> <th height=30><span class=tab_head>IP</span></th> </tr>\n"; while($row=mysql_fetch_array($result)) { echo "<tr bgcolor=#2F2F2F>\n"; echo "\n<td align=center>". $row['ID'] . "<input type=checkbox name=". $row['ID'] . " id=". $row['ID'] . " value=". $row['ID'] . " /></td>"; echo "\n<td>". $row['tagid'] . "</td>"; echo "\n<td>". $row['tsname'] . "</td>"; echo "\n<td>". $row['boatname'] . "</td>"; echo "\n<td>". $row['firstname'] . "</td>"; echo "\n<td>". $row['lastname'] . "</td>"; echo "\n<td>". $row['blevel'] . "</td>"; echo "\n<td>". $row['plevel'] . "</td>"; echo "\n<td>". $row['ep'] . "</td>"; echo "\n<td>". $row['guild'] . "</td>"; echo "\n<td>". $row['country'] . "</td>"; echo "\n<td>". $row['interested'] . "</td>"; echo "\n<td>". $row['otherboats'] . "</td>"; echo "\n<td>". $row['comments'] . "</td>"; echo "\n<td>". $row['ip'] . "</td>"; echo "\n</tr>"; } echo "\n</table>\n"; mysql_close(); ?> <input type="submit" name="perform" id="perform" value="Delete Selected" /> </form> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/155467-php-not-displaying-mysql-data/ Share on other sites More sharing options...
mikesta707 Posted April 24, 2009 Share Posted April 24, 2009 are there any error messages? Quote Link to comment https://forums.phpfreaks.com/topic/155467-php-not-displaying-mysql-data/#findComment-818086 Share on other sites More sharing options...
jay7981 Posted April 24, 2009 Author Share Posted April 24, 2009 no error messages .... here is the page http://shy.angeldyne.com/joinreqs.php Quote Link to comment https://forums.phpfreaks.com/topic/155467-php-not-displaying-mysql-data/#findComment-818139 Share on other sites More sharing options...
jay7981 Posted April 24, 2009 Author Share Posted April 24, 2009 also here is my php info http://shy.angeldyne.com/phpinfo.php and my php.ini (supplemented) http://shy.angeldyne.com/phpinfo2.php Quote Link to comment https://forums.phpfreaks.com/topic/155467-php-not-displaying-mysql-data/#findComment-818156 Share on other sites More sharing options...
radi8 Posted April 24, 2009 Share Posted April 24, 2009 Well, it seems as though the SQL is not returning any data, hence the header only being displayed. Do an echo $query; and see what is being displayed. Then, copy the SQL and put it into PHPMYADMIN query analyzer and work out the sql statement. Also, temporarily remove the delete sql and try it again. Quote Link to comment https://forums.phpfreaks.com/topic/155467-php-not-displaying-mysql-data/#findComment-818245 Share on other sites More sharing options...
jay7981 Posted April 26, 2009 Author Share Posted April 26, 2009 ok i did the echo $query; and now the page is blank i tried to add it at the bottom just before the mysql_close(); tag and it was blank not even the header, then i tried to add it just after the inital query, again blank page and no header.... i know that the sql is correct due to the information is being input into the db .... ??? im so confused as to what the issue could be.... Quote Link to comment https://forums.phpfreaks.com/topic/155467-php-not-displaying-mysql-data/#findComment-819507 Share on other sites More sharing options...
jay7981 Posted April 28, 2009 Author Share Posted April 28, 2009 any help on this would be greatly appreciated Quote Link to comment https://forums.phpfreaks.com/topic/155467-php-not-displaying-mysql-data/#findComment-821183 Share on other sites More sharing options...
wildteen88 Posted April 28, 2009 Share Posted April 28, 2009 Blank screens normally mean there is an error in your script. To see the errors add the following lines at the start of your script: <?php error_reporting(E_ALL); ini_set('display_errors', 'On'); ?> Quote Link to comment https://forums.phpfreaks.com/topic/155467-php-not-displaying-mysql-data/#findComment-821185 Share on other sites More sharing options...
jay7981 Posted May 5, 2009 Author Share Posted May 5, 2009 adding the information that u suggested resulted in a blank page as well. perhaps it will help if i explain what i was trying to accomplish, i am trying to have this page show the results in a table format with headers of all records in the DB and in each row have a check box that when selected and the button pressed will delete only the selected rows from the DB. Now mind you i am no expert in php nor sql but i belive that i have all the correct syntax i have double and triple checked the code and cannot find any mistakes any where. i know it is connecting and selecting the correct DB and TABLE due to no reply from the or die( "Unable to select database"); Again here is the code i have made a few slight modifications... <html> <head> </head> <body> <form name="action" id="action" method="post" action="<?=$_SERVER['PHP_SELF']?>"> <? $MyUsername="#######"; $MyPassword="#######"; $MyDatabase="#######"; mysql_connect(#######,$MyUsername,$MyPassword) or die( "Unable to conect to database"); @mysql_select_db($MyDatabase) or die( "Unable to select database"); if($_POST['perform']) { foreach($_POST as $id) { mysql_query("DELETE FROM 'join' WHERE ID='$id' LIMIT 1"); } } $query=SELECT * FROM 'join' ORDER BY ID DESC or die( "Unable to select table"); $result=mysql_query($query); $num=mysql_numrows($result); echo "<table width=100% border=0 align=center cellpadding=4 cellspacing=1 bordercolor=#333333 bgcolor=#FCFCFC> <tr bgcolor=#990000> <th height=30 align=center><span class=tab_head>Number</span></th> <th height=30><span class=tab_head>Boat ID</span></th> <th height=30><span class=tab_head>TS Name</span></th> <th height=30><span class=tab_head>Boat Name</span></th> <th height=30><span class=tab_head>First Name</span></th> <th height=30><span class=tab_head>Last Name</span></th> <th height=30><span class=tab_head>Boat Level</span></th> <th height=30><span class=tab_head>Pirate Level</span></th> <th height=30><span class=tab_head>Current EP</span></th> <th height=30><span class=tab_head>Current Guild</span></th> <th height=30><span class=tab_head>Join Shy?</span></th> <th height=30><span class=tab_head>Country</span></th> <th height=30><span class=tab_head>Other Boats</span></th> <th height=30><span class=tab_head>Comments</span></th> <th height=30><span class=tab_head>IP</span></th> </tr>\n"; while($row=mysql_fetch_array($result)) { echo "<tr bgcolor=#2F2F2F>\n"; echo "\n<td align=center>". $row['ID'] . "<input type=checkbox name=". $row['ID'] . " id=". $row['ID'] . " value=". $row['ID'] . " /></td>"; echo "\n<td>". $row['tagid'] . "</td>"; echo "\n<td>". $row['tsname'] . "</td>"; echo "\n<td>". $row['boatname'] . "</td>"; echo "\n<td>". $row['firstname'] . "</td>"; echo "\n<td>". $row['lastname'] . "</td>"; echo "\n<td>". $row['blevel'] . "</td>"; echo "\n<td>". $row['plevel'] . "</td>"; echo "\n<td>". $row['ep'] . "</td>"; echo "\n<td>". $row['guild'] . "</td>"; echo "\n<td>". $row['country'] . "</td>"; echo "\n<td>". $row['interested'] . "</td>"; echo "\n<td>". $row['otherboats'] . "</td>"; echo "\n<td>". $row['comments'] . "</td>"; echo "\n<td>". $row['ip'] . "</td>"; echo "\n</tr>"; } echo "\n</table>\n"; mysql_close(); ?> <input type="submit" name="perform" id="perform" value="Delete Selected" /> </form> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/155467-php-not-displaying-mysql-data/#findComment-826548 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.