Page 1 of 1

Datbase Simple Insert Query

Posted: Wed Jul 02, 2003 12:29 am
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();

Posted: Wed Jul 02, 2003 1:52 am
by []InTeR[]
What is the table structureof login?

And please, change your login and passwd of the database server ****.

Posted: Fri Jul 04, 2003 6:42 pm
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());
?>