Wednesday, 15 April 2015

SQL syntax error in php for long paragraph -



SQL syntax error in php for long paragraph -

i getting sql syntax error long paragraph same code working fine short line text. have attached screen shot of error.!

below insert query code. waiting response.

<?php include('config.php'); if(isset($_post['add'])) { echo $name=$_post['name']; $description=$_post['description']; $status=$_post['status']; $image=$_files['image']['name']; if(isset($_files['image']['name'])) { move_uploaded_file($_files['image']['tmp_name'],"gallery_files//".$_files['image']['name']); echo $image=$_files['image']['name']; } echo $sql="insert test(name,description,image,status)values('$name','$description','$image','$status')"; $r=mysql_query($sql) or die(mysql_error()); echo "<script>window.location = 'product.php'</script>"; } ?>

your content contains quote characters, need escape. can utilize php function mysql_real_escape_string() escapes special characters in string utilize in sql statement.

try with:

$description = mysql_real_escape_string($_post['description']);

also create sure datatype text or longtext used storing big pieces of string data.

php sql insert-query

No comments:

Post a Comment