salman_ahad@yahoo.com Posted October 26, 2009 Share Posted October 26, 2009 I am taking sentences through a form on page. Then checking some condition and trying to insert them in database. I have issues while inserting... foreach ($sentences as $final) { ...... else { if(strlen($final) <= 120){ echo $final.'.<br />';} else echo substr($final,0,120). '.<br />'; //Inserting of final(sentences) in database starts $sent = mysql_real_escape_string($_POST ['$final']); $error= "Error while inserting, either User present or other. Please check database"; $inserted= "sentences inserted"; $result = mysql_query("SELECT sent FROM sentences WHERE sent='{$final}' "); if($result) { $num = mysql_num_rows( $result ); if ($num == 0) { $querypost = mysql_query ("INSERT INTO sentences (sent) VALUES ('$final')"); echo $inserted; } else echo $error; } } } Please correct my logic error. Quote Link to comment Share on other sites More sharing options...
trq Posted October 26, 2009 Share Posted October 26, 2009 Exactly what is your question? Quote Link to comment Share on other sites More sharing options...
jefffan24 Posted October 26, 2009 Share Posted October 26, 2009 Do you have your method in your form set to post? <form method="post"> Quote Link to comment Share on other sites More sharing options...
salman_ahad@yahoo.com Posted October 26, 2009 Author Share Posted October 26, 2009 I fixed it... I had given wrong local variable earlier. Quote Link to comment 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.