Jump to content


Photo

Inserting records problem!!


  • Please log in to reply
1 reply to this topic

#1 seegy87

seegy87
  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 18 January 2003 - 04:22 PM

The case is this...

I am setting up a new site that will contain many different tabs. It will have the ability to sign up and post your own tablatures, so therefore it needs a way to add a record for everytime someone signs up etc.

So i made a page called signupprocess.php or something and put at the top my connection details and a query with INSERT INTO (i\'ll post the whole thing further down...)

Well, it didn\'t work, so i had an idea!
I added a record using phpMyAdmin, and copied the code that it churned up (the confirmation bit thingy). I then deleted the old record so that it wouldn\'t try to overwrite the old thing and cause a problem. I then slapped that code into my php page and it didn\'t work :x

I was wondering if anyone could help me...
here is my code...

<?php
$db = mysql_connect(\"localhost\", \"jamieguthrie\", \"******\")
or
die(\"could not connect\");
mysql_select_db(\"jamieguthrie_uk_db\",$db);
?>

<?php
INSERT INTO `user` (`userid`, `forename`, `surname`, `fav_tabs`, `fav_quote`) VALUES (\'\', \'Jamie\', \'Guthrie\', \'GreenDay\', \'howdy\');
?>

(that insert bit is exactly what came out of phpMyAdmin)

That is what i have basically.

The database is called jamieguthrie_uk_db,
my username is jamieguthrie,
my password is ******,
the table i want to add to is called user,
there are 5 rows (you can see them in the coding)


Please help, as i don\'t know what i have done wrong :?

P.S. that \'\' before the \'Jamie\' bit in the VALUES bit is a double \'. It is the id set to autoincrement so it hasn\'t been filled in.

#2 metalblend

metalblend
  • Members
  • PipPipPip
  • Advanced Member
  • 89 posts
  • LocationCalifornia, USA

Posted 18 January 2003 - 07:06 PM

..just as I replied in the PHP Help forum, you need to use PHP\'s mysql_query().

mysql_query("INSERT INTO `user` (`userid`, `forename`, `surname`, `fav_tabs`, `fav_quote`) VALUES (\'\', \'Jamie\', \'Guthrie\', \'GreenDay\', \'howdy\')",$db);

Hope that helps.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users