PHP 4 inserting data in MySQL 3.23

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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
whatever.

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:

<html>
<body>

<?php

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

mysql_select_db("example",$db);

$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],
$myrow[1]);

}

echo "</table>\n";

?>

</body>
</html>

<html>
<body>

<?php

if ($submit) {

  // process form

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

  mysql_select_db("example",$db);

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

  $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
information">

  </form>

  <?php

} // end if

?>

</body>
</html>

Any help or direction pointing would be appreciated.

Thanks
 

__________________________________________________
Do you Yahoo!?
U2 on LAUNCH - Exclusive greatest hits videos
http://launch.yahoo.com/u2

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux