MySQL issue


Posted on 16th Feb 2014 07:03 pm by admin

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.

No comments posted yet

Your Answer:

Login to answer
103 Like 42 Dislike
Previous forums Next forums
Other forums

Get Total From While Loop
I'm trying to get the total for each product and add them for a Grand Total to list outside the loop

Members Only
Hi all, for my website i have a members area only which on members can veiw, but at the moment anyon

New to Arrays
Hi I am new to PHP (a week and a half now) and I am just beginning to read about arrays. I understan

add 20 000 to the rowcnt
Hi ...
I need to add 20 000 to the row count but just cant find a way to do this i am new to php

Wierd if else problem
Hi guys,

this probably aint wierd for you, but it seems like php is playin up to me. may b i

if description does not contain the following words
Hello everyone,

I am parsing a MS Excel (.xls) file and adding it's content to a mySQL databa

Stopping page post back
I have few literal contriols in my page and a repeater too. But inspite of using update panel, postb

Inserting multiple records from single form
I've found a number of threads that deal with this issue, but I'm new to php and coding language so

Mail Form receiving emails with no content
Hi, I hope someone here can help me.
I have a simple form in my website, it was working OK, after

Posting Serialized Data Not Working
I am trying to send an object from one PHP file to another using POST. I serialize the object and th

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash