Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> MySQL
Author Message
floppydrivez
Involved
Involved



Joined: Feb 26, 2006
Posts: 340
Location: Jackson, Mississippi

PostPosted: Thu Sep 14, 2006 10:07 am Reply with quote

When I insert my row of info its adding a row of blanks Very Happy with its own id.

Did I format any of this wrong?

Code:
CREATE TABLE nuke_league_games (

   gid int NOT NULL auto_increment,
   PRIMARY KEY (gid),
   gname text NOT NULL,
   version text NOT NULL,
   gabbr text NOT NULL
) TYPE=MyISAM;


Code:


$addgame = $db->sql_query("INSERT INTO ".$prefix."_league_games VALUES (null, '$gtitle','$version','$abrev')");
 
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
kguske
Site Admin



Joined: Jun 04, 2004
Posts: 6437

PostPosted: Thu Sep 14, 2006 10:36 am Reply with quote

Looks OK. Usually the primary key field is defined after the fields on the create statement.

_________________
I search, therefore I exist...
Only registered users can see links on this board! Get registered or login!
 
View user's profile Send private message
floppydrivez







PostPosted: Thu Sep 14, 2006 10:37 am Reply with quote

Yeah, I changed it to see if that made a difference. Any idea why I get a extra row with nothing defined except the gid?
 
fkelly
Former Moderator in Good Standing



Joined: Aug 30, 2005
Posts: 3312
Location: near Albany NY

PostPosted: Thu Sep 14, 2006 11:23 am Reply with quote

You are defining gid as not null and then sticking null in it for one thing.

I'd stick a 1 in it.
 
View user's profile Send private message Visit poster's website
floppydrivez







PostPosted: Thu Sep 14, 2006 12:03 pm Reply with quote

This makes sense plus it works.

Code:
$addgame = $db->sql_query("INSERT INTO ".$prefix."_league_games VALUES ('', '$gtitle','$version','$abrev')"); 


I tried it without the

Code:
''


My result was an error.
 
montego
Site Admin



Joined: Aug 29, 2004
Posts: 9457
Location: Arizona

PostPosted: Fri Sep 15, 2006 7:20 am Reply with quote

floppydrivez, I used your original CREATE statement from above to create the table and then I tried this exact INSERT statement:

INSERT INTO nuke_league_games VALUES (null, 'title','version','abrev');

It inserted just fine and only 1 row. I believe that you may have had an issue with how your variables were getting defined/valued and that it had nothing to do with the actual SQL.

_________________
Only registered users can see links on this board! Get registered or login!
Only registered users can see links on this board! Get registered or login! 
View user's profile Send private message Visit poster's website
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> MySQL

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©