| | |
PHP results in Blank Screen
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Apr 2007
Posts: 2
Reputation:
Solved Threads: 0
I am trying to display all data from my MYSQL database but it results in a blank page:
PHP Syntax (Toggle Plain Text)
<span class="ad_notxt"><code class="inlinecode"> <? mysql_connect($host,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query="SELECT * FROM events"; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); echo "<b><center>Database Output</center></b><br><br>"; $i=0; while ($i < $num) { $title=mysql_result($result,$i,"title"); $title =mysql_result($result,$i,"title"; $description =mysql_result($result,$i,"description"; $organization =mysql_result($result,$i,"organization"; $start_month =mysql_result($result,$i,"start_month"; $start_day =mysql_result($result,$i,"start_day"; $start_year =mysql_result($result,$i,"start_year"; $start_hour =mysql_result($result,$i,"start_hour"; $start_min =mysql_result($result,$i,"start_min"; $start_ampm =mysql_result($result,$i,"start_ampm"; $end_month =mysql_result($result,$i,"end_month"; $end_day =mysql_result($result,$i,"end_day"; $end_year =mysql_result($result,$i,"end_year"; $end_hour =mysql_result($result,$i,"end_hour"; $end_min =mysql_result($result,$i,"end_min"; $end_ampm =mysql_result($result,$i,"end_ampm"; $time_varies =mysql_result($result,$i,"time_varies"; $location =mysql_result($result,$i,"location"; $street1 =mysql_result($result,$i,"street1"; $street2 =mysql_result($result,$i,"street2"; $city =mysql_result($result,$i,"city"; $zip =mysql_result($result,$i,"zip"; $area =mysql_result($result,$i,"area"; $href =mysql_result($result,$i,"href"; $submitter_name =mysql_result($result,$i,"submitter_name"; $submitter_phone =mysql_result($result,$i,"submitter_phone"; $submitter_email =mysql_result($result,$i,"submitter_email"; $primary =mysql_result($result,$i,"primary"; echo "<b>$title</b>";"$description";"$organization";"$start_month";"$start_day";"$start_year";"$start_hour";"$start_min";"$start_ampm";"$end_month";"$end_day";"$end_year";"$end_hour";"$end_ampm";"$time_varies";"$location";"$street1";"$street2";"$city";"$zip";"$area";"$href";"$submitter_name";"$submitter_phone";"$submitter_email";"$primary"; $i++; } ?> </code></span>
•
•
•
•
I am trying to display all data from my MYSQL database but it results in a blank page:<? mysql_connect($host,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query="SELECT * FROM events"; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); $i=0; while ($i < $num) { //code } ?>
To shouldn't you get every result manually. I think you should do something like:
[php]
echo "<table>\n<tr><th>Field</th><th>Value</th></tr>\n";
foreach(mysql_fetch_assoc($result) as $key => $value)
{
echo "<tr><td>$key</td><td>$value</td></tr>\n"
}
echo "</table>";
[/php]
I didn't test it, but it should work (for one result, if there are more result you should format the table different).
As mentioned above mysql_num_rows is misspelled. Your while block is not being executed. There are some other changes you will need to make too or else you will get errors when you try and execute the script.
all your mysql_result lines are missing the ) and the end before the ; except for the first one.
You echo statement is a big mess as well. get rid of all the ; in there. You can do that in a couple different ways:
This will put them all on one line though. To have each on it's own line just add <br /> tags between each variable. Like this...
Hopefully this will help
all your mysql_result lines are missing the ) and the end before the ; except for the first one.
You echo statement is a big mess as well. get rid of all the ; in there. You can do that in a couple different ways:
PHP Syntax (Toggle Plain Text)
echo "<b>$title</b> $description $organization $start_month $start_day $start_year $start_hour $start_min $start_ampm $end_month $end_day $end_year $end_hour $end_ampm $time_varies $location $street1 $street2 $city $zip $area $href $submitter_name $submitter_phone $submitter_email $primary";
This will put them all on one line though. To have each on it's own line just add <br /> tags between each variable. Like this...
PHP Syntax (Toggle Plain Text)
echo "<b>$title</b> <br /> $description <br /> $organization<br /> $start_month <br /> $start_day <br /> etc... ";
Hopefully this will help
![]() |
Similar Threads
- Windows XP loads to blank screen (Windows NT / 2000 / XP)
- Just a blank screen = ( (Monitors, Displays and Video Cards)
- Blank screen before XP startup (Windows NT / 2000 / XP)
- HELP - Blank Screen starting ME (Windows 95 / 98 / Me)
- System Restore - blank screen (Windows NT / 2000 / XP)
Other Threads in the PHP Forum
- Previous Thread: help with forms
- Next Thread: Short guide to include RSS on your website
| Thread Tools | Search this Thread |
Tag cloud for PHP
.htaccess access ajax apache api array beginner binary broken cakephp checkbox class cms code cron curl database date development directory display download dynamic echo email error file files filter folder form forms function functions gc_maxlifetime google host href htaccess html image include insert integration ip java javascript joomla limit link login loop mail memmory memory menu mlm mod_rewrite multiple mysql navigation oop parse parsing paypal pdf php problem query radio random recursion regex remote script search server sessions sms snippet soap source space sql structure syntax system table thesishelp tutorial update upload url validation validator variable video web xml youtube






