Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting items into database

Status
Not open for further replies.

mancroft

Programmer
Oct 26, 2002
267
GB
I am trying to get the cart at the url below working. How do I get the items below into the database?


insert into items values(0, 'Tony Hawk 3', 'Tony Hawk is back. Join him in this popular skating game where speed, collisions and tricks come together to produce the best skating game of all time!', 23.95);

insert into items values(0, 'FIFA Soccer 2002', 'The FIFA range of soccer games are the most popular in their genre. FIFA Soccer 2002 includes an all new team line up, advanced management capabilities, and richer, more realistic graphics.',36.50);

insert into items values(0, 'SSX Tricky', 'Image snowboarding down a steep hill at 100 miles per hour and you have SSX Tricky. It\'s packed with new players, new moves, and a whole new list of stages to complete.', 45.50);
 
What you are missing in your SQL are the fields into which the values you have specified will go.

Here is an example.

There is a table called 'Person' with the following fields

1) Name varchar(20)
2) Age int(2)
3) Sex char(1)

The correct syntax will be

insert into person(name, age, sex) values("JAMES BROWN", 6, 'M')

NB: The order of the fields must correspond to the order of the values
 
I'm still having problems inserting records into the database table. I can do the command listed below on the command line in mysql monitor;

insert into person(name, age, sex) values("JAMES BROWN", 6, 'M')

However, I can't seem toget it to work under PHP. What is the proper syntax to get it to work in PHP? I hae created a form and would like to input to be inserted into the table.

Here's what I have;

<?php
$conn=mysql_connect(&quot;localhost&quot;,&quot;mkt2000&quot;,&quot;chelsea7&quot;);
mysql_select_db(&quot;mylogin&quot;,$conn);
$addrec=&quot;INSERT INTO logins (userID,passID,nickname) VALUES ('','$userID','passID','nickname')&quot;;
if (mysql_query($addrec, $conn)){
echo &quot;entry successful!&quot;;
} else{
echo &quot;entry unsuccessful. Contact the Webmaster&quot;;
}
?>

I'm really stuck on this one. Any assistance would be helpful.

Thanks
Kyle


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top