Cyto Posted November 30, 2011 Share Posted November 30, 2011 Hi, wye does $link return a empty row in mysql? $link = $m[1]; $ssql = "INSERT INTO site (id, link) VALUES ('', '$link');"; mysql_query($ssql); Thx, Quote Link to comment https://forums.phpfreaks.com/topic/252134-mysql-question/ Share on other sites More sharing options...
QuickOldCar Posted November 30, 2011 Share Posted November 30, 2011 You should use auto increment for the id values on insert http://dev.mysql.com/doc/refman/5.6/en/example-auto-increment.html If were to update into a certain id, then you should specify the id, but not leave it blank. Quote Link to comment https://forums.phpfreaks.com/topic/252134-mysql-question/#findComment-1292662 Share on other sites More sharing options...
Psycho Posted November 30, 2011 Share Posted November 30, 2011 How are we supposed to know? What is the value of $link? Did you verify it has the value you expect? Does the variable contain a value that is consistent with the database field (i.e. are you trying to store text into a numeric field)? Although, that last problem would likely create an error rather than inserting an empty field. Also, there is no need to include the 'id' in the insert query if it is an auto-increment field. Try the following $link = $m[1]; $ssql = "INSERT INTO `site` (`link`) VALUES ('$link');"; $result = mysql_query($ssql); //Debugging code echo "The value of the link: '{$link}'<br>\n"; echo "Insert Query: {$ssql}<br>\n"; if(!$result) { echo "Query failed: " . mysql_error(); Quote Link to comment https://forums.phpfreaks.com/topic/252134-mysql-question/#findComment-1292663 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.