FURQAN Posted June 24, 2010 Share Posted June 24, 2010 hi there my name is furqan ahmed and i am having problem in inserting record in two tables at the same time i have posted the code in this code "$query" is running but "$query1" is not running any help from your side will be highly appreciated waiting for ur reply if(isset($_POST['submit1'])) { $question=$_POST['question']; $option1=$_POST['option1']; $option2=$_POST['option2']; $option3=$_POST['option3']; $option4=$_POST['option4']; $answer=$_POST['answer']; $query="INSERT INTO questions VALUES('$question','$option1','$option2','$option3','$option4')"; $result=mysql_query($query) or die('cannot be updated'); $query1="INSERT INTO answer VALUES('','$answer')"; $result1=mysql_query($query1) or die('cannot update query1'); Link to comment https://forums.phpfreaks.com/topic/205711-inserting-query-error/ Share on other sites More sharing options...
kenrbnsn Posted June 24, 2010 Share Posted June 24, 2010 Change the "or die" clause to <?php $result1=mysql_query($query1) or die("cannot update $query1<br>" . mysql_error()); ?> and see what is displayed. Ken Link to comment https://forums.phpfreaks.com/topic/205711-inserting-query-error/#findComment-1076410 Share on other sites More sharing options...
phpchamps Posted June 24, 2010 Share Posted June 24, 2010 r u getting any error message???? try changing your query to below code $query="INSERT INTO questions VALUES('".$question."','".$option1."','".$option2."','".$option3."','".$option4."')"; Link to comment https://forums.phpfreaks.com/topic/205711-inserting-query-error/#findComment-1076412 Share on other sites More sharing options...
kenrbnsn Posted June 24, 2010 Share Posted June 24, 2010 The OP said the first query worked fine, but the second didn't. Anyway your change would make no difference. Ken Link to comment https://forums.phpfreaks.com/topic/205711-inserting-query-error/#findComment-1076415 Share on other sites More sharing options...
FURQAN Posted June 24, 2010 Author Share Posted June 24, 2010 brothers from $query1 i am getting the following ,ysql_error() Incorrect integer value: '' for column 'question' at row 1 $query1="INSERT INTO answer VALUES('','$answer')"; i have used '' in inserting the first field because the field is auto incremented is it the problem Link to comment https://forums.phpfreaks.com/topic/205711-inserting-query-error/#findComment-1076424 Share on other sites More sharing options...
phpchamps Posted June 24, 2010 Share Posted June 24, 2010 yaa thts the problem .. write full insert query with column name and its values.... Link to comment https://forums.phpfreaks.com/topic/205711-inserting-query-error/#findComment-1076427 Share on other sites More sharing options...
FURQAN Posted June 24, 2010 Author Share Posted June 24, 2010 $query1="INSERT INTO answer(question,answer) VALUES('','$answer')"; is this the correct way but it is still not working Link to comment https://forums.phpfreaks.com/topic/205711-inserting-query-error/#findComment-1076432 Share on other sites More sharing options...
kenrbnsn Posted June 24, 2010 Share Posted June 24, 2010 Try changing the query to <?php $query1 = "insert into answer set answer = '$answer'"; ?> Ken Link to comment https://forums.phpfreaks.com/topic/205711-inserting-query-error/#findComment-1076440 Share on other sites More sharing options...
FURQAN Posted June 25, 2010 Author Share Posted June 25, 2010 thanx bri it really works thanx again for the help u have been really helpfull to me i think you r a php guru can i have ur email id please thanxx i shall be waiting for ur reply Link to comment https://forums.phpfreaks.com/topic/205711-inserting-query-error/#findComment-1077283 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.