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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PHP simple script involving form updating table in database

Status
Not open for further replies.

Tugend

Technical User
Jul 5, 2001
1
HK
Hi all,

Very simple script. Takes two variables, user and pass which are input into a form and must be inserted into the 'players' table. The script is as follows:

<?

if (!$user || !$pass)
{
echo &quot;You have not filled out all the fields. Please hit back on your browser.<br>&quot;;
exit;

}

$user = addslashes($user);
$pass = addslashes($pass);

$db = mysql_connect(&quot;localhost&quot;, &quot;djoseph&quot;, &quot;paradise&quot;);

if (!$db)
{
echo &quot;Houston, we have a problem...&quot;;
exit;
}

mysql_select_db(&quot;iedge&quot;);


$query = &quot;insert into players values ('&quot;.$user.&quot;', '&quot;.$pass.&quot;')&quot;;

$result = mysql_query($query)

?>

*******************************************************

The script doesnt work. Doesnt seem to be a connection issue because the error doesnt come up. The script seems to execute, with the browser blank and directed to the right PHP script.

Any tips/suggestions anyone?

Thanks All
 
It's this line right here:

You have your SQL wrong. It should be like so:

[tt]
$query = &quot;INSERT INTO players (id,user,pass) VALUES ('','$user', '$pass')&quot;;
[/tt]

You have to have the name of the fields that you are inserting values into for the query to work.

Hope this helps.

-Vic vic cherubini
krs-one@cnunited.com
====
Knows: Perl, HTML, JavScript, C/C++, PHP, Flash
====
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top