Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mixed HTML/MySQL/PHP page do not display even with basic php coding

Status
Not open for further replies.

switch3133

Programmer
Dec 23, 2004
3
CA
Hi,

This is my first post in this forum, i'll try to be descriptive.
I'm trying to use PHP to display the MySQL databases and then I ask for the SQL command to be performed on the database. It's very basic, I know :)

Here's my code :

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="expires" CONTENT="0">
</HEAD>

<BODY BGCOLOR = "#FFFFFF" LINK="#000080" VLINK="#000080" ALINK="#0000FF">

<?php
error_reporting(E_ALL);
$host="localhost";
$user="olympic_sql";
$password="(REMOVED!FOR.THE.FORUM)";
?>

<FORM NAME="requete_sql" ACTION="exemple_mysql_test.php" METHOD=POST>
S&eacute;lectionnez la base de donn&eacute;e SQL pour la requ&ecirc;te :<BR><BR>

<SELECT NAME="database" SIZE=1>

<?php
mysql_connect($host, $user, $password);
$db_table = mysql_list_dbs();
for ($i = 0; $i < mysql_num_rows($db_table); $i++)
{
echo ("<OPTION>" . mysql_tablename($db_table, $i);
}
?>

</SELECT>

<BR><BR>

Entrez la requ&ecirc;te &agrave; ex&eacute;cuter :

<BR><BR>

<TEXTAREA NAME"req" COLS=50 ROWS=10></TEXTAREA>

<BR><BR>

<INPUT TYPE="SUBMIT" VALUE="Envoyer" NAME="Envoyer">

</FORM>
</BODY>
</HTML>

Then I save it and send it on my webhosting ftp.

Here's the configuration of the server :

apache 1.3.33 (Unix)
mysql 4.0.22-standard-log
Linux OS Kernel 2.4.20-28.7
PHP 4.3.9

BUT NOTHING DISPLAYS when I hit reload.
AND if I view the source of the page I can see the following HTML code :

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=windows-1252"></HEAD>
<BODY></BODY></HTML>

(???) I just don't get it. Please help. I have looked in
the php manual :


My first feeling is that the server cannot go back from php to html.

Best regards,
Frederick St-Hilaire
 
What happens if you create a file with the following code in it:
Code:
<?php
phpinfo();
?>
and bring it up with your browser?

If PHP is working, this should display everything you want to see about the PHP on your server.

Ken
 
You can switch back and forth from HTML-output mode to PHP-interpretation mode at will in your code. But if you think that's the problem, stay in PHP-interpretation mode and use print() or echo() statements to produce your output.


Want the best answers? Ask the best questions!

TANSTAAFL!!
 
I'm curious about differences between the HTML source you quoted in your original post and the PHP script. Particularly, your <BODY> tag. That script should have output a more complex <BODY> tag than you've shown.


Want the best answers? Ask the best questions!

TANSTAAFL!!
 
I was wondering about the body tag, too. It looks like everything from the BGCOLOR= all the way down to the </FORM> line is missing. This appears to be more of an HTML problem than a php problem.
 
You seem to have a PHP error in the following code:
Code:
<?php
    mysql_connect($host, $user, $password);
    $db_table = mysql_list_dbs();
    for ($i = 0; $i < mysql_num_rows($db_table); $i++)
    {
    echo ("<OPTION>" . mysql_tablename($db_table, $i);
    }
?>
Remove the opening "(" from the echo statement.

Ken
 
KEN !!

YOU WERE RIGHT.

Thanks to all people who have look and reply.

Frederick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top