By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,321 Members | 1,875 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,321 IT Pros & Developers. It's quick & easy.

Insert statment problem

P: 8
Good morning

I have a form with the controls in the insert statment below. table1 has an Auto increment primary key hence is omitted in the insert statment and form. Am getting the error It didnt work " .mysql_insert_id(); and not any other php or mysql error to tell me if anything is wrong the insert statment.

To top it up, I have an echo statment of the insert statment before it executes, when I copy and paste the insert statment from the browser and paste it in MySQL query analyser, the insert statment actually works. What could be wrong, please help

$Sql= "insert into table1(leader,SnrOp,Op1,Op2,Absent,OP3,ExtraOp,Dat e,Autho) values(".$_POST['sleader'].",".$_POST['SnrOp'].",".$_POST['Op1'].",".$_POST['Op2'].",".$_POST['otOp1'].",".$_POST['extOp'].",".$mydate.",".$_SESSION['absent_status'].")";

$result = mysql_query($Sql);
if (mysql_query($result)){
echo "<br /> Entered id " .mysql_insert_id();
}else{echo "It didnt work " .mysql_insert_id();
Apr 22 '07 #1
Share this Question
Share on Google+
1 Reply

code green
Expert 100+
P: 1,726
Am getting the error It didnt work " .mysql_insert_id(); and not any other php or mysql error
Well you won't do because you do not try to echo out any php or MySql errors
Apr 24 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.