try before the :
if ($submit) 



the vars are now declared on a different way in the new phph versions

you need to do:

if ($_POST[submit]){

and the insert values are also now :

echo $_POST[phone];

so check phpinfo(); there are all the vars you need...


Mark Snijders, Developer 
Atos Origin 
Groenewoudeseweg 1, Room VN-515 
5621 BA  Eindhoven, The Netherlands 
*    :+31 (0)40 - 2785992 (tel) 
* : +31 (0)40 - 2788729 (fax) 

The information in this mail is intended only for use of the individual or
entity to which it is addressed and may contain information that is
privileged, confidential and exempt from disclosure under applicable law.
Access to this mail by anyone else than the addressee is unauthorized. If
you are not the intended recipient, any disclosure, copying, distribution or
any action taken omitted to be taken in reliance of it, is prohibited and
may be unlawful.

-----Original Message-----
From: Josh Jones [mailto:bootsec99@;]
Sent: woensdag 13 november 2002 14:25
Subject: [PHP-DB] PHP 4 inserting data in MySQL 3.23

I'm running the following setup:
Apache 2.0.40-8
MySQL 3.23.52-3
PHP 4.2.2-8.0.5

I have no problems retreiving data from the database
and posting it to a website, but I can't insert data
from the website to the database via forms or

I'm new to this, but I've triple checked all the
permissions and the code - it all works fine from the
MySQL command line. I can't find any errors in the
logs either, maybe I'm looking in the wrong place.

Here's a sample of some testing code:



$db = mysql_connect("localhost", "webuser");


$result = mysql_query("SELECT * FROM mytable",$db);

echo "<table border=1>\n";

echo "<tr><td>Name</td><td>Phone</tr>\n";

while ($myrow = mysql_fetch_row($result)) {

printf("<tr><td>%s</td><td>%s</td></tr>\n", $myrow[0],


echo "</table>\n";





if ($submit) {

  // process form

  $db = mysql_connect("localhost", "webuser");


  $sql = "INSERT INTO mytable (name, phone) VALUES

  $result = mysql_query($sql);

  echo "Thank you! Information entered.\n";

} else{

  // display form


  <form method="post" action="<?php echo $PHP_SELF?>">

  Name:<input type="Text" name="name"><br>

  Phone:<input type="Text" name="phone"><br>

  <input type="Submit" name="submit" value="Enter



} // end if



Any help or direction pointing would be appreciated.


Do you Yahoo!?
U2 on LAUNCH - Exclusive greatest hits videos

PHP Database Mailing List (
To unsubscribe, visit:

PHP Database Mailing List (
To unsubscribe, visit:

Reply via email to