Hi All I have used this query millions of times, but now i am realising that each time it is run, it places two entries onto my table. One with all the details on and the other just blank. Normally i can just ignore this but when reading the last value off the table there is always a blank one. I cannot afford to delete these blank entries everytime one is created. I have a form that passes the varibale into this seperate page.... <?php mysql_query("INSERT INTO comments (com_member_av, com_poster, com_member_id, com_date, com_group_id, comment) VALUES('$_POST[member_av]', '$_POST[username]', '$_POST[member_id]', '$_POST[date]', '$_POST[group_id]', '$_POST[comment]') ") or die(mysql_error()); echo "<META HTTP-EQUIV='Refresh' CONTENT='1; URL=holiday.php?id=group&destination=$destination&group_id=$group_id#comments'>"; ?> PHP: Any ideas why two entries are being created ??
Perhaps the second blank rows inserted were caused by meta refresh. Please tell me what is the filename of above scripts Arief
have you tried removing the echo line?. It might be the reason. It opened again the php file that inserted the values. Since the second time it opened the file, the $_POST[] values are blank does resulting to blank fields.
Yeah i think that has fixed it, since removing the echo REFRESH i havent had any blank messages. Thanks My next problem now tho, is to do with an 'UPDATE'. I have a form which displays all the users current data, they can edit this information and click submit. This then passes the variables to another page where the UPDATE code is. Often the data doesnt get updated and infact all the data is removed from that entry and just left blank. (so the old data doesnt get updated, it gets deleted). <?php mysql_query("UPDATE groups SET group_name = '$_POST[groupname]', group_des = '$_POST[destination]', group_date = '$_POST[date]', group_year = '$_POST[year]', group_days = '$_POST[days]', group_hotel ='$_POST[hotel]', group_info = '$_POST[group_info]', group_other_dest = '$_POST[other_des]', group_howmany = '$_POST[howmany]' WHERE group_id = '$group_id'") or die(mysql_error()); echo" <h2 class='h2'>Changes Made</h2> <div class='table'><ul><li > <p class='center bold'> Your changes have been made. LINK 1 - LINK 2 - LINK 3"; ?> GOOGLE BANNER </p> </li></ul></div> Code (markup): Any ideas why sometimes this is happening ??
The users could be submitting blank data, do you have any php above to check if the data is blank being submitted? Even if its just a "reset" button back to zero, if you are using hidden html post for that someone could edit the html, point it to the urls and run it off their desktop if($_POST[groupname]!=""){ if($_POST[destination]!=""){ if($_POST[date]!=""){ if($_POST[year]!=""){ if($_POST[days]!=""){ if($_POST[hotel]!=""){ if($_POST[group_info]!=""){ if($_POST[other_des]!=""){ if($_POST[howmany]!=""){ mysql_query("UPDATE groups SET group_name = '$_POST[groupname]', group_des = '$_POST[destination]', group_date = '$_POST[date]', group_year = '$_POST[year]', group_days = '$_POST[days]', group_hotel ='$_POST[hotel]', group_info = '$_POST[group_info]', group_other_dest = '$_POST[other_des]', group_howmany = '$_POST[howmany]' WHERE group_id = '$group_id'") or die(mysql_error()); }else{print "you left something blank";} }else{print "you left something blank";} }else{print "you left something blank";} }else{print "you left something blank";} }else{print "you left something blank";} }else{print "you left something blank";} }else{print "you left something blank";} }else{print "you left something blank";} }else{print "you left something blank";} PHP: Quickest thing i could cook up in 5 mins. you might also want to run is_numeric thru anything that has to be a number too, and run some security thru your post. Change the else to specific print statements of what was left blank. hopefully that helps you