deep
01-07-2004, 05:29 PM
Hello, I just started out learning sql and I need your help!
I created my little db and added it to my site with no errors :) It looks like this:
CREATE TABLE friend_user (
id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
edUser CHAR(15),
edName CHAR(20),
edLastname CHAR(30),
edCity CHAR(20)
);
Now I want to add a user and I use this code:
<?php
$db = mysql_pconnect("localhost", "hello", "hello");
mysql_select_db("mydb", $db) or die ("error!");
if ($id) {
print "your username is taken, try a new one.";
} else {
$sql = "INSERT INFO `friend_user` (`edUser`, `edPass`, `edName`, `edLastname`, `edCity`)
VALUES ('$edUser', '$edPass', '$edName', '$edLastname', '$edCity')";
print "<b>Welcome $username</b><br>";
print "You are now a registered member";
}
?>
I know this is a noobs code but i need to start somewhere :) My problem is that the user info is not added to the database and im wondering what im doing wrong...
Another thing bothering me is the $id... how is the webpage going to remember you and your $id... so that when you come back it will know who you are..??? (if i understood the $id right that is)
plz help! :)
I created my little db and added it to my site with no errors :) It looks like this:
CREATE TABLE friend_user (
id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
edUser CHAR(15),
edName CHAR(20),
edLastname CHAR(30),
edCity CHAR(20)
);
Now I want to add a user and I use this code:
<?php
$db = mysql_pconnect("localhost", "hello", "hello");
mysql_select_db("mydb", $db) or die ("error!");
if ($id) {
print "your username is taken, try a new one.";
} else {
$sql = "INSERT INFO `friend_user` (`edUser`, `edPass`, `edName`, `edLastname`, `edCity`)
VALUES ('$edUser', '$edPass', '$edName', '$edLastname', '$edCity')";
print "<b>Welcome $username</b><br>";
print "You are now a registered member";
}
?>
I know this is a noobs code but i need to start somewhere :) My problem is that the user info is not added to the database and im wondering what im doing wrong...
Another thing bothering me is the $id... how is the webpage going to remember you and your $id... so that when you come back it will know who you are..??? (if i understood the $id right that is)
plz help! :)