0

i am unable to store data in database

<?php

include ("db_connect.php");

$res = mysql_query("SELECT * FROM posts");
while($data = mysql_fetch_array($res))
  {
  $pid=$data['pid'];
  }
echo $pid; 

$pid=$pid+1;

//Get data in local variable
$ptitle=$_POST['ptitle'];

$uname=$_POST['uname'];

$email=$_POST['email'];

$pcont=$_POST['pcont'];

if ($uname==""  or $ptitle=="" or $pcont=="" or $email=="")

echo "All fields must be entered, hit back button and re-enter information";

else{

$query="insert into posts (pid,ptitle,pcont,uname,email) values('$pid','$ptitle','$pcont','$uname''$email')";

mysql_query($query)  or die(mysql_error());

echo "Your Experience have been recorded";

}

?>

Its throughing error " Column count doesn't match value count at row 1 "

Some1 please help e its urgent

Edited by diafol: applied code tags

2
Contributors
1
Reply
2
Views
5 Years
Discussion Span
Last Post by Biiim
0

missing a comma

$query="insert into posts (pid,ptitle,pcont,uname,email) values('$pid','$ptitle','$pcont','$uname''$email')";

should be

$query="insert into posts (pid,ptitle,pcont,uname,email) values('$pid','$ptitle','$pcont','$uname','$email')";
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.