My php code can't be display on browser.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
crazyben21
Forum Newbie
Posts: 3
Joined: Tue Sep 01, 2009 2:53 pm

My php code can't be display on browser.

Post by crazyben21 »

My php code can't be display on browser. I get problem loading page. I don't know what I'm doing wrong? Please help. I was thinking to trying my code on a non 64bit os. That is probably causing my problem. I posted in two other forums but no reply, and no answer. Thank you in advance.

The problem starts in the while loop. Just note that I created my database table on the Mysql console.

Code: Select all

 
 
<?php
//sql connecting
 
$iscon = mysqli_connect('localhost','root','password');
if(!$iscon)
{
die('Could not connect to mySQL: ' . mysqli_connect_errno($iscon) . '<br/>' . mysqli_connect_error($iscon) . '<br/>');
}
 
 
?>
 
<?php
 
if ( !mysqli_select_db($iscon,'juniblog') )
{
echo 'Database doesn\'t excist: ' . mysqli_error($iscon) . '<br/>';
echo "Creating new database....<br/>";
if( mysqli_query($iscon, 'CREATE DATABASE juniblog') )
echo 'Database has been created successfully..';
else
echo die('An error has occured creating database: ' . mysqli_error($iscon));
}
else
echo "Database excist and is selected.";
?>
 
 
<?php
$junitable = mysqli_query($iscon, "select * from messageblog");
 
echo "Hello Milena!<br/>";
 
while($row = mysqli_fetch_array($junitable))
{
echo "<div style=\"border:thin black solid\">";
 
echo '<p>' . 'Titlte:' . $row['title'] . '</p>';
echo '<p>' . 'Message:' . $row['postmessage'] . '</p>';
echo '<p>' . 'Author:' . $row['author'] . '</p>';
echo '<p>' . 'Date:' . $row['date'] . '</p>';
 
echo "</div>";
}
 
 
?>
 
 
<?php mysqli_close($iscon); ?> 
 
 
Last edited by Benjamin on Tue Sep 01, 2009 7:27 pm, edited 2 times in total.
Reason: Changed code type from text to php.
User avatar
Darhazer
DevNet Resident
Posts: 1011
Joined: Thu May 14, 2009 3:00 pm
Location: HellCity, Bulgaria

Re: My php code can't be display on browser.

Post by Darhazer »

Enable error reporting... probably you have fatal error, for example because of missing mysqli extension, and you are getting blank page because of this

Code: Select all

ini_set('display_errors', 'on');
error_reporting(E_ALL)
crazyben21
Forum Newbie
Posts: 3
Joined: Tue Sep 01, 2009 2:53 pm

Re: My php code can't be display on browser.

Post by crazyben21 »

Thanks for the reply, I really appreciate it. I check error reporting on php.ini and is on. I tried the code you gave me to turn it on and still the same. I created a new simple while statement incrementing numbers and it works. I put back the while statement with mysqi_fetch_array and the problems start again. I'm starting thinking it's probably my 64bit apache, or mysql. Going to install apache, php, and mysql on my acer one to see if doesn't give me the problem there.

Thank You.
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: My php code can't be display on browser.

Post by califdon »

Look at the line:

Code: Select all

echo 'Database doesn't excist: ' . mysqli_error($iscon) . '<br/>';
 
What's going to happen when the parser tries to parse that? It will recognize

Code: Select all

echo 'Database doesn'
and then it won't understand what follows that, so it just won't send anything to the browser at all.

Use double quotes to define a string that has a single quote inside it.
crazyben21
Forum Newbie
Posts: 3
Joined: Tue Sep 01, 2009 2:53 pm

Re: My php code can't be display on browser.

Post by crazyben21 »

Thanks.

Code: Select all

# echo 'Database doesn't excist: ' . mysqli_error($iscon) . '<br/>';


I fixed that with a back slash. That particular gave me the error so that's how I spotted it.

Code: Select all

echo 'Database doesn\'t excist: ' . mysqli_error($iscon) . '<br/>';

I still was getting browser error after mysqli_fetch_array. I solve my "Page Can't be display" problem when I remove apavhe64 and php64bit and installed 32bit apache and php. Last time I'm using unofficial 64bit php and apache from http://www.elxis.org/guides/developers- ... ndows.html. Now The thing I'm running is MySqL 64bit Official from mysql website.

Thanks everybody. This the only forum that helped me. Two other forum still never reply to me. Thanks.

Kind of weird though. In the other two forums it had the backslash. Probably It was erased by mistake while I pasting it here.
Post Reply