PDA

View Full Version : Simple select statement


briintex1
05-03-2008, 07:35 AM
Hello,
I was wondering if you could tell me why this statement is not inserting information into a database?




//$sql="INSERT INTO my_table (Number, Type, Panel, Sys) VALUES('$_POST[s_number]','$_POST[c_type]','$_POST[b_panel]','$_POST[sys]')";
$sql="INSERT INTO my_table (Number, Type, Panel, Sys) VALUES('1','2', '3','4')";


I put the commented line there because that was my orginal line of code and I added the second line to see if would add it but neither one of the lines add the information to the db. If need be I can post more code.

Thanks

Fou-Lu
05-03-2008, 08:26 AM
Few things I can suggest, from general php and sql:
I assume you are actually using a mysql/mssql/whatever connectioni object or method to insert the data. All you have there is a string, so that doesn't actually do anything of course.
If this isn't the problem, check with the error reporting, either in the logs or enable the error_reporting(E_ALL) on your page.
'Number' tends to be a reserved type in sql, so you may want to try entering it with single quotations or backquotes.

I almost always recommend using quotations to surround my field names: I've been trapped with things like date, year, number, text, etc as my fieldnames before (curses to those designers :D), but a quotation tells the sql to treat it as an identifier and not as a function or system command - always good to use. Try that, I'm placing my money there, but if that doesn't work, we'll need more code.

abduraooft
05-03-2008, 08:27 AM
Have you called mysql_query() ?