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

getAlexaRank($url) function not working
I have made a function to get alexa rank
the site is here: http://mytestsite.rack111.com/1

Echoing ASCII code
I have a php page that splits a string into chars and then echoes the ASCII code for each char. I'm

Error with Font and imagettfbbox
I keep getting an error that says "Warning: imagettfbbox() [function.imagettfbbox]: Could not f

Comparing MySql data and arrays.
I have a mysql table set up like this:
idsubjectbodyuseriddatetimetags1blog subjectblog body111|2

check if value exists
I have googled this for a while and I am getting lots of different results. Is there a standard meth

send message to the java application
Oracle 10g with Windows platform.

I have a java application that periodically pings the d

difference between datetimes
($row['totime']-$row['fromtime'])/60

this is giving me 0

example of totime and fromtim

Need help/w Page: 1,2,3,4 function!
So I have this code im working on where it's ment to display seperate pages having 20 logs each
I

There was a problem with the request. (Code: 0)
Any Idea what could cause this? I get it randomly at best. But with both IE and FF. It derives from

foreach and array need help combining
Hi guys.

Here's the code

Code: array(
'tag' => 'code',<

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