PDA

View Full Version : Insert Record PHP/MySQL


cocoonfx
02-19-2007, 09:40 PM
Hello


I am having problems with some code which is linked to a shopping cart.

I have used :-


$insert = "INSERT INTO users (username, password)
VALUES ('".$_POST['username']."', '".$_POST['pass']."')";
$add_member = mysql_query($insert);
print "words=You are registered.&checklog=2";
die();
?>


---------------------------------------------------------
However the data is not inserted into my table. Is there anything i am doing wrong?

HELP?

davidj
02-20-2007, 05:54 AM
How long have you been programming in PHP?
Do you understand it

cocoonfx
02-20-2007, 10:57 PM
hello i am starting to learn PHP for the last few months, and yes i do understand PHP but i am still learning.

davidj
02-21-2007, 05:57 AM
im not sure how valid this is..

$insert = "INSERT INTO users (username, password)
VALUES ('".$_POST['username']."', '".$_POST['pass']."')";
i would do it like this


$username = $_POST['username'];
$pass = $_POST['pass'];

$insert = "INSERT INTO users (username, password)
VALUES ('$username', '$pass')";


then echo the $insert var and then run the script
echo $insert = "INSERT INTO users (username, password) >>>>>


post here the result thats printed to the screen

if your just starting out then try these..
http://www.dreamweaverclub.com/vtm