Viewing mysql db on IE via php
Moderator: General Moderators
Am a bit late, but thought I might try to help out. I think we all know how frustrating a blank screen can be.
Your PHP code and MySQL query is 100% correct. I ran it, and it does exactly what it is supposed to do. I agree with the others that you should always put in error checking after each line. It a good idea to follow mysql_connect, mysql_select_db, & mysql_query with the appropriate error checking statements so you know if & where your code is failing.
You said: "I've saved the file as both .php and .html, but I suppose that wouldn't matter as long as the .html had the php script embedded inside"
Your script should be saved with the .php extension. I could be wrong, but the only way I know of to masquerade PHP scripts as HTML file (.html files) is by using Apache's 'mod_rewrite' module and creating an .htaccess file that causes the server to parse PHP files as HTML. I'd stick with the .php extension.
Sounds like you have either configuration issues, or less likely but possible, your MySQL table might not be 100% OK. Can you run a "select * from mydatabase" query in MySQL monitor?
I'm not a Windows guy, if you want to get up and running with PHP quickly and without too much hassle you might look into
a all in one package like XAMP http://www.apachefriends.org/en/xampp-windows.html I read about it here http://education.nyphp.org/phundamental ... =2/17/2004 Probably what I would do if you continue having problems. Good luck,
Your PHP code and MySQL query is 100% correct. I ran it, and it does exactly what it is supposed to do. I agree with the others that you should always put in error checking after each line. It a good idea to follow mysql_connect, mysql_select_db, & mysql_query with the appropriate error checking statements so you know if & where your code is failing.
You said: "I've saved the file as both .php and .html, but I suppose that wouldn't matter as long as the .html had the php script embedded inside"
Your script should be saved with the .php extension. I could be wrong, but the only way I know of to masquerade PHP scripts as HTML file (.html files) is by using Apache's 'mod_rewrite' module and creating an .htaccess file that causes the server to parse PHP files as HTML. I'd stick with the .php extension.
Sounds like you have either configuration issues, or less likely but possible, your MySQL table might not be 100% OK. Can you run a "select * from mydatabase" query in MySQL monitor?
I'm not a Windows guy, if you want to get up and running with PHP quickly and without too much hassle you might look into
a all in one package like XAMP http://www.apachefriends.org/en/xampp-windows.html I read about it here http://education.nyphp.org/phundamental ... =2/17/2004 Probably what I would do if you continue having problems. Good luck,
sorry for being away this long guys. Work got the better of me.
I hope there's someone out there that can help me with this.
I have this php code, connected to mysql database,that runs to the best of my knowledge. I have applied error codes to identify any connection failures to the database and if I enter wrong database names etc, I am duly informed on the web browser about syntax errors or unknown usernames and passwords.
But when I get all my details right, no errors are generated, but I get a blank page display, with nothin on it.
This suggests that my queries are running okay, but do I need to do anything to view them?
Please help. see code below:
feyd | Please review how to post code using
I hope there's someone out there that can help me with this.
I have this php code, connected to mysql database,that runs to the best of my knowledge. I have applied error codes to identify any connection failures to the database and if I enter wrong database names etc, I am duly informed on the web browser about syntax errors or unknown usernames and passwords.
But when I get all my details right, no errors are generated, but I get a blank page display, with nothin on it.
This suggests that my queries are running okay, but do I need to do anything to view them?
Please help. see code below:
Code: Select all
<html>
<head>
<title>dbtest</title>
</head>
<body>
<?
$dbcnx = mysql_connect("localhost","root","password") or die(mysql_error());
mysql_select_db("test",$dbcnx) or die(mysql_error());
$query = "SELECT email FROM customer WHERE customerid='001'";
$chucka = mysql_query($query) or die("Couldnt connect.");
$row = mysql_fetch_array($chucka) or die("not working");
?>
</body>
</html>feyd | Please review how to post code using
Code: Select all
andCode: Select all
tags. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
you haven't printed what came from mysql_fetch_array()..
var_export()
"you haven't printed what came from mysql_fetch_array().. "
please explain.
I'm new to php and the speed with which I have had to learn means I might be missing small but vital aspects.
I have specified a query, given the query a variable name and requested that the query to display the results of the query. what am I missing then?
PLEASE IGNORE FROM HERE DOWN (just checking your code writing guideline)
php
mysql_Connect( $localhost, $username, $password);
/php
please explain.
I'm new to php and the speed with which I have had to learn means I might be missing small but vital aspects.
I have specified a query, given the query a variable name and requested that the query to display the results of the query. what am I missing then?
PLEASE IGNORE FROM HERE DOWN (just checking your code writing guideline)
php
mysql_Connect( $localhost, $username, $password);
/php
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
notice the text on the end..feyd wrote:you haven't printed what came from mysql_fetch_array()..var_export()
Hey everyone.
Thanks for all your feedback on this. I am finally getting some response fromt mysql with php, but obviously, not without problems.
I have just run the following query:
Everything works fine. except the display is of the column headers rather than the actual data. So for example, I have 20 records on my database, but they are all displayed (all 20 of them) as the header column.
e.g CustomerID CustomerNAME CustomerAdd. etc.
This is repeated 20 times. So I have my connection and display, but there's something not quite right.
Can you help?
Thanks
Thanks for all your feedback on this. I am finally getting some response fromt mysql with php, but obviously, not without problems.
I have just run the following query:
Code: Select all
<html>
<head>
<title>dbtest</title>
</head>
<body>
<?
$dbcnx = mysql_connect("localhost","root","password") or die(mysql_error());
mysql_select_db("test",$dbcnx) or die(mysql_error());
$customer="customerID";
$customernam="customerName";
$customerad="customeradd";
$customertel="customertel";
$customertel2="customertel2";
$email="Email";
$query = "SELECT * FROM customer WHERE customerid='001'or'002'or '003'";
$result = mysql_query($query) or die("No current connection to database.");
echo "<font size='2'><b>ACCOUNT DETAILS</font>";
while ($row = mysql_fetch_array($result))
{
extract($row);
echo "<table border='2' bgcolor='yellow'>";
echo "<tr>\n
<td>$customer</td>\n
<td>$customernam</td>\n
<td>$customerad</td>\n
<td>$customertel</td>\n
<td>$customertel2</td>\n
<td>$email</td>\n
</tr>\n";
echo "</table>\n";
}
?>
</body>
</html>e.g CustomerID CustomerNAME CustomerAdd. etc.
This is repeated 20 times. So I have my connection and display, but there's something not quite right.
Can you help?
Thanks
Well, just kept getting the blank page and my error codes didnt seem to work, but following some extensive overnight work, I have managed to get everything in place. I can now view the db on the webpage and its been well worth the time and energy.
er! problem though (not really a problem) When I select
I get all the records as well as duplicated table headers. i.e
for every record, I have the headers (customer name, customer address etc) being replicated between records and ideally, I would just like one set of headers and all the records below. I know this would be a simple code enhancements, but after 4 hours of doing this, my brain isnt functioning very well.
this is what I have
can you help?
er! problem though (not really a problem) When I select
Code: Select all
select * from XXXXXX;for every record, I have the headers (customer name, customer address etc) being replicated between records and ideally, I would just like one set of headers and all the records below. I know this would be a simple code enhancements, but after 4 hours of doing this, my brain isnt functioning very well.
this is what I have
Code: Select all
Header section:
<tr bgcolor='9966ff'>
<th><font size='1' face='courier new'>PROJECT ID</font></th>
<th><font size='1' face='courier new'>PROJECT NAME</font></th>
<th><font size='1' face='courier new'>START DATE</font></th>
<th><font size='1' face='courier new'>FINISH DATE</font></th>
<th><font size='1' face='courier new'>CORDINATOR</font></th>
<th><font size='1' face='courier new'>DETAILS</font></th>
Records
<tr bgcolor='white'>
<th><font size='1' face='courier new'>$projectid</font></th>
<th><font size='1' face='courier new'>$projectname</font></th>
<th><font size='1' face='courier new'>$commencedate</font></th>
<th><font size='1' face='courier new'>$finishdate</font></th>
<th><font size='1' face='courier new'>$cordinator</font></th>
<th><font size='1' face='courier new'>$projectdetails</th>
</tr>\n