ali_2kool2002 Posted March 3, 2007 Share Posted March 3, 2007 :( hi im creating a query to enter data into the table but my table has two fields one is auto increment called id and the other called name the query in sql works as below INSERT INTO test(`name`) VALUES ('smith'); But the same query in php doesnt work,,says couldnt execute query $insert_query = "INSERT INTO test(`name`) VALUES ('smith')"; $result = mysql_query($insert_query) or die ("couldnt execute query"); ne 1 know why? Link to comment https://forums.phpfreaks.com/topic/40994-solved-sql-and-php-query-not-working-ne-1-please/ Share on other sites More sharing options...
Orio Posted March 3, 2007 Share Posted March 3, 2007 Try removing the back-sticks from the column's name: INSERT INTO test(name) VALUES ('smith'); Orio. Link to comment https://forums.phpfreaks.com/topic/40994-solved-sql-and-php-query-not-working-ne-1-please/#findComment-198512 Share on other sites More sharing options...
ali_2kool2002 Posted March 3, 2007 Author Share Posted March 3, 2007 nope that doesnt work? ??? ??? Link to comment https://forums.phpfreaks.com/topic/40994-solved-sql-and-php-query-not-working-ne-1-please/#findComment-198513 Share on other sites More sharing options...
Orio Posted March 3, 2007 Share Posted March 3, 2007 Try: INSERT INTO `test`(name) VALUES ('smith') Orio. Link to comment https://forums.phpfreaks.com/topic/40994-solved-sql-and-php-query-not-working-ne-1-please/#findComment-198523 Share on other sites More sharing options...
peterbarone Posted March 3, 2007 Share Posted March 3, 2007 try this mysql_query("INSERT INTO test ( name) VALUES ( 'smith' ) ") or die(mysql_error()); Link to comment https://forums.phpfreaks.com/topic/40994-solved-sql-and-php-query-not-working-ne-1-please/#findComment-198524 Share on other sites More sharing options...
ali_2kool2002 Posted March 3, 2007 Author Share Posted March 3, 2007 sorry the original line "INSERT INTO test(`name`) VALUES ('ggg')" was rite i just didnt connect to a databse,, would have helped if had an error sayin something about connecting but ye simple mistake of mine,,, thanks for ur help ppl.!! Link to comment https://forums.phpfreaks.com/topic/40994-solved-sql-and-php-query-not-working-ne-1-please/#findComment-198526 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.