[Help] is there something worng with my php code?

Vigintennalis Membrum
Vicennium
Joined
Feb 1, 2005
Messages
257
Reaction score
9
PHP:
<?php

// Connects to your Database
mysql_connect("127.0.0.1", "root", "") or die(mysql_error()); 
mysql_select_db("fakedb") or die(mysql_error()); 

$username = stripslashes($_POST['u_name']);
$password = stripslashes($_POST['u_pass']);


$query = mysql_query("INSERT INTO Accounts (username, password) VALUES ('$username','$password')");
mysql_query($query) or die(mysql_error());
?>

i wrote this simple code to be able to just insert the two values into the database. The problem is that an empty query error occurs . What am i doing wrong?
 
PHP:
<?php

// Connects to your Database
mysql_connect("127.0.0.1", "root", "") or die(mysql_error()); 
mysql_select_db("fakedb") or die(mysql_error()); 

$username = stripslashes($_POST['u_name']);
$password = stripslashes($_POST['u_pass']);


$query = mysql_query("INSERT INTO Accounts (username, password) VALUES ('$username','$password')");
mysql_query($query) or die(mysql_error());
?>


i wrote this simple code to be able to just insert the two values into the database. The problem is that an empty query error occurs . What am i doing wrong?


you made another query
remove last "mysql_query($query) or die(mysql_error());" should be only this in last line.
PHP:
mysql_query("INSERT INTO Accounts (username, password) VALUES ('$username','$password')");
 
Last edited:
Back