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: Wed Sep 13, 2006 9:43 am Reply with quote

I got my form and table already. For my form action I wanted to use a string instead of a file (ie insert.php).

Code:
$addcat = $db->sql_query("INSERT INTO ".$prefix."_league_cats (cid, ctitle) VALUES ('$ctitle')");

$ctitle = 'name';


$addcat is my form action and name is my field. Did I go wrong somewhere?
 
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
floppydrivez







PostPosted: Wed Sep 13, 2006 10:20 am Reply with quote

oh nevermind,

Code:
$addcat = $db->sql_query("INSERT INTO ".$prefix."_league_cats (cid,ctitle) VALUES ('cid','$ctitle')");


I found the problem through trial and error.
 
montego
Site Admin



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

PostPosted: Thu Sep 14, 2006 5:50 am Reply with quote

floppydrivez, are you sure that is your working line of code? Is the 'cid' property on the database defined as autoincrement? If so, I would just use '' instead of 'cid', or I believe you can even use NULL. The real problem is that you had a mismatch of number of properties to values in your original line of code. Those need to match.

_________________
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
floppydrivez







PostPosted: Thu Sep 14, 2006 5:57 am Reply with quote

Yes you are correct. It should look a little more like this. It was causing some problems with my auto_increment though.

This is a similiar snipplet, just using null for gid and it seems to be the correct way to format if auto_increment is used for an id.

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


Thanks
 
montego







PostPosted: Thu Sep 14, 2006 6:30 am Reply with quote

Yep.... looks good!

:clap:
 
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 ©