I've learned the basics of PHP and MySQL by using a web hosting service over
the past few weeks. Call this site 1. And I am finally feeling that I am
getting the hang of things. 

Now, another web host that I have been using is letting me try out PHP and
MySQL on their server. Call this site 2.

The problem I am having is that if I take pages with php scripts from site
1; change the user, password and database names; and upload them to site 2 -
data does not insert into tables. However, the scripts are connecting to the
database (no die messages or other error messages are appearing) and the
tables have been prepared via phpmyadmin without problem. Likewise, I can
insert data via phpmyadmin without problem. 

Below is a sample script that is causing such a problem. I appreciate that
it is sloppy (it was one of my first). But it works on site 1 and not site
2.  Could this be a matter of the permissions the site 2 web host has
granted me? And if so, why can I do things with phpmyadmin but not via my
own scripts?

Many thanks,

Jeffrey Baumgartner

$dbcnx = mysql_connect("localhost", "USER", "PASSWORD");

$db = mysql_select_db("TABLENAME", $dbcnx) or die("Couldn't get DB");

If (isset($name)) {
echo "<P>" . $name . "</p> <P>" . $age . "</p>";  


<FORM ACTION="<?php echo($PHP_SELF);  ?>" METHOD="POST">
<P> Name: <INPUT TYPE=TEXT NAME="name" SIZE="62"></p>
<P> Age: <INPUT TYPE=TEXT NAME="age" SIZE="8"></p>
<INPUT TYPE=SUBMIT NAME="submitInfo" VALUE="Submit">


if (isset($name))  {
$query = "INSERT INTO formtest (name,age) VALUES ('$name' , '$age')" ; 

if (mysql_query($query)){
echo "<P>" . $name . "</p> <P>" . $age . "</p>";  

else {
echo ("<p>Tough cookies, sunshine</p>");


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

Reply via email to