I'm a newbie to php+sql and I'm having a problem that's really bugging me.
I have installed PHP and Mysql on a server, and created mysql databases and tables which I have been populating with records okay. I have also run small php scripts which have executed okay and the phpinfo(); generates the php welcome page, so I know both work individually.
Now I'm trying to view my "mysql" db on a web page via php, but the number of times I've come up against a blank page is driving me mad.
The code below is what I'm running on a Win2k Server:(host is localhost, root is the username and password is the "root" password)
Code: Select all
<html>
<head>
<title>
dbtest</title>
</head>
<body><pre>
<?
$dbcnx =mysql_connect("localhost","root","password");
mysql_select_db("test",$dbcnx);
$result=mysql_query("SELECT * FROM customer",$dbcnx);
while ($row=mysql_fetch_row($result))
{
for ($i=0;$i<mysql_num_fields($result); $i++)
echo $row[$i] . "";
echo "n";
}
mysql_close($dbcnx);
?>
</pre>
<font size="1">thank you</font>
</body>
</html>
As you can see this is simple enough.
even when I run:
<html>
<head>
<title>
dbtest</title>
</head>
<body><pre>
<?
$dbcnx =mysql_connect("localhost","root","password");
mysql_select_db("test",$dbcnx);
$result=mysql_query("SELECT * FROM customer",$dbcnx);
mysql_close($dbcnx);
?>
</pre>
<font size="1">thank you</font>
</body>
</html>Thanks in advance.
Chuck
Phenom| Please use
Code: Select all
tags for php-code[/size][/color]