...

View Full Version : PHP 5.0 , MySQL 5.0 problem



akimoto82
01-03-2007, 08:15 AM
Hi.. I am using php 5.0, MySql 5.0 and IIS 5.1
I can run normal php pages but when i try to connect to MySql Server to display some data using tables, nothing is displayed. blank screen. i wonder y...hope anyone for noes this, can enlighten me.?


here are the php codes


<?php
echo "HI";
$connection = mysql_connect("localhost","root","")
or die ("couldn't connect to server");
mysql_error();

$db = mysql_select_db("property", $connection)
or die ("Couldn't select database");

$query = "SELECT * FROM new" ;
$result = mysql_query($query)
or die("Query Failed: ".mysqli_error());

echo "<table border ='1'>";
echo "<tr>";
echo "<th>Date</th><th>Contact</th><th>Name</th><th>Project Name</th><th>Area</th><th>Room Type</th>
<th>Price</th><th>Availability</th><th>Remarks</th><th>Block</th><th>Unit / Level</th>";

while ($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>", $row['Date'], "</td><td>",
$row['Contact'], "</td><td>",
$row['Name'], "</td><td>",
$row['ProjectName'], "</td><td>",
$row['Area'], "</td><td>",
$row['RoomType'], "</td><td>",
$row['Price'], "</td><td>",
$row['Availability'], "</td><td>",
$row['Remarks'], "</td><td>",
$row['Blk'], "</td><td>",
$row['UnitOrLevel'], "</td>";
echo "</tr>";
}

echo "</table>";

mysql_close($connection);



?>

koyama
01-03-2007, 09:20 AM
Hmm... You are saying that you don't even get to see 'HI' being printed. What have you done to debug? Are error messages on? If not add at the top of your script


<?php
error_reporting(E_ALL);
/* your script */
...
?>

display_errors has to be on though. Use e.g. phpinfo(); to see if this is the case.

If it isn't possible to get error messages, remove one statement at a time from the bottom until you get to see 'HI'. Then post again your minimal script that isn't working.

akimoto82
01-03-2007, 11:24 AM
I have added error_reporting(E_ALL); to my coding but still the same..I can the word HI , but the others simply cannot view.. I dunno y also..

Not even any error messages..

koyama
01-03-2007, 11:42 AM
Well if it prints 'HI' then you don't have any parse errors at least.

What about the html that was sent. If you say 'View Source' from your browser, do you see an empty table?

What do you see when you run this?


<?php
error_reporting(E_ALL);
echo "HI";
$connection = mysql_connect("localhost","root","");
$db = mysql_select_db("property", $connection);

$query = "SELECT * FROM new";
$result = mysql_query($query);

$row = mysql_fetch_array($result);
var_dump($row);
}

?>

akimoto82
01-03-2007, 12:28 PM
now the word HI is gone also...total blank page....

akimoto82
01-03-2007, 12:30 PM
okok...now the word HI is back again...but still no tables....

koyama
01-03-2007, 12:33 PM
Sorry, there was a brace that shouldn't have been there.:)
Try:


<?php
error_reporting(E_ALL);
echo "HI";
$connection = mysql_connect("localhost","root","");
$db = mysql_select_db("property", $connection);

$query = "SELECT * FROM new";
$result = mysql_query($query);

$row = mysql_fetch_array($result);
var_dump($row);
?>

akimoto82
01-03-2007, 12:53 PM
Its still the same.. = (

Only display the word HI only...

koyama
01-03-2007, 01:18 PM
In that case, I must give up. It makes no sense to me that you only see 'HI' and nothing from the var_dump. Maybe someone else can see what's wrong.

It seems you have display_errors set to off so we don't get any messages. By the way are you sure your table 'new' isn't empty?

MRMAN
01-03-2007, 02:50 PM
ok two things. 1) Do you have data in that table for that database.
2) what exactly do you get when you view source.

also in your first code chang the mysqli_error ro mysql_error

and in the test code you have change it to this


<?php
error_reporting(E_ALL);
echo "HI";
$connection = mysql_connect("localhost","root","");
$db = mysql_select_db("property", $connection);

$query = "SELECT * FROM new";
$result = mysql_query($query) or die(mysql_error());

$row = mysql_fetch_array($result);
var_dump($row);
?>



Cheers

akimoto82
01-03-2007, 05:50 PM
I'm sure i have data in the table for the database
but my source is like this




<html>
<head>
<title>Untitled Document</title>

</head>

<body>

HI

CFMaBiSmAd
01-03-2007, 05:55 PM
You should probably post your latest code.

akimoto82
01-03-2007, 06:11 PM
my lastest code for my test app

PHP


<html>
<head>
<title>Untitled Document</title>

</head>

<body>

<?php
error_reporting(E_ALL);
echo "HI";
$connection = mysql_connect("localhost","root","");
$db = mysql_select_db("property", $connection);

$query = "SELECT * FROM new";
$result = mysql_query($query) or die(mysql_error());

$row = mysql_fetch_array($result);
var_dump($row);
?>

</body>
</html>


my source




<html>
<head>
<title>Untitled Document</title>

</head>

<body>

HI


i just nid to make sure my the connection from php to mysql can work...now currently i'm just seeing blank pages except for the word "HI"

akimoto82
01-03-2007, 06:20 PM
Is it also got to do with some software configurations that i need to do?

CFMaBiSmAd
01-03-2007, 06:28 PM
Because your output does not have the HTML tags that are at the end of the file, I suspect that the PHP code stops executing due to an error, but that error output is off on your server. Try adding the following line after your opening <?php tag -

ini_set('display_errors', 1);If you have access to your server log file, also check it.

akimoto82
01-03-2007, 06:34 PM
ok..i tried addding and i run the php file again..now this error

Fatal error: Call to undefined function mysql_connect() in C:\EngGlobe\test.php on line 13

akimoto82
01-04-2007, 03:25 AM
I managed to solve the problem. thanx to the people who helped me along the way...

The solution to my problem is that i didn't put the required .dll files into my windows/system32 folder..so thats why my coding didn't work.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum