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

IIS & NW MII on the same server
Hi,

We're weighing the possibility to run both IIS and MII (NetWeaver) on the same server

Concatenate two strings ???
I have string one $string1 and another $string2.

How to concatenate (add) both of them $str

Please help - should be a simple fix.. driving me nuts
Everything seemed to be working fine. I have a table, it alphabetically lists a bunch of cities and

newbie question
Hi out thereIm totaly new in this forum and to .net and vb so here is a totaly newbie question.I wan

Sufficient protection from bad input?
I am writing a simple script to let people upload 'pages' of their own content, be it simply a few b

Include with Parameters
In a particular page I would like to include a file that requires $_GET parameters.

when I go

Simple MySQL script is not working
Hey guys,

Just familiarizing myself with PHP and MySQL. I am following along in the O'Reilly

TimeZoneOffset
Hello,

Please i need your help. I have a system that users can use to punch in and out. This

form class help (oop php5)
Hidy Ho Neighbors,

I'm forcing myself to learn oop/classes for php5. It seems like a good id

Which practice of iteration through containers is preferred
In the "real world" what kind of loop do most people use to iterate through a container like a vecto

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