Datbase Simple Insert Query

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
stockdalep
Forum Newbie
Posts: 6
Joined: Wed Jul 02, 2003 12:29 am

Datbase Simple Insert Query

Post by stockdalep »

[Admin Edit: removed host IP and password from mysql_connect() and added tags]

Hi

I have a simple INSERT query setup which works only once if I try to run the script again it fails.

But if I manually delete the last database entry I can then run the script again.???

Code: Select all

$username = $HTTP_POST_VARS['username'];
            $password = $HTTP_POST_VARS['password'];

$username = addslashes($username);
$password = addslashes($password);
 open the connection
 $conn = mysql_connect("host", "express", "****");
if (!$conn)
{
}


mysql_select_db("central");
$query = "insert into login values(' $username ',' $password' )";

$result = mysql_query($query);

if($result)
echo mysql_affected_rows().' Password Entered';

mysql_close();
[]InTeR[]
Forum Regular
Posts: 416
Joined: Thu Apr 24, 2003 6:51 am
Location: The Netherlands

Post by []InTeR[] »

What is the table structureof login?

And please, change your login and passwd of the database server ****.
bionicdonkey
Forum Contributor
Posts: 132
Joined: Fri Jan 31, 2003 2:28 am
Location: Sydney, Australia
Contact:

Post by bionicdonkey »

also insted of this:

Code: Select all

<?php
$conn = mysql_connect("host", "express", "****");
if (!$conn)
{
}
?>
use something like this:

Code: Select all

<?php
$conn = mysql_connect("host", "express", "****") or die(mysql_error());
?>
Post Reply