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

date("now") prints out wrong date ?
Hi Guys
Anyone know why and how I can fix it ?

BB_Code error
I'm having a problem with a custom built function and keep getting this error:


Warning: M

2 decima places & How to reload my page
Hello There,

How do i put full-stop (.) after second figure from behind? ie if i have 123456

FTP Programs
Here is a list of commonly suggested FTP Programs to use:

FileZilla
SmartFTP
CuteFTP

PHP Multiples of 2, Show posts...not working (wordpress)
I have been using this code to show div.example with 6 li columns inside it, each li is a post with

PHP form help required
Hi all! Apologies in advance for having to message the forum for help. I know you must get a lot of

PHP Login
Hey!
I got this shopcart code online, am trying to modify it but am getting an error when i try a

Reg Ex
Im trying to search for the string: srv_9 (Dead ???)

I thought to use preg_match, however I d

Multi Level Array Problem
hi all,

For example I have array like below:

$temp = array(array('north america', 'us'

fopen() security
As i understood the usage of fopen() for it to function correctly the Dir you write to has to be rw

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