Page 1 of 1
PHP + MySQL INSERT Problem?
Posted: Wed Jul 09, 2003 10:42 pm
by pistolfire99
Code: Select all
$result = mysql_query("INSERT INTO tblpresult VALUES ('NULL', '$pollID', '$pollvalue')");
mysql_close();
?>
There is a form and when the user clicks "submit", it goes to this page and its supposed to enter the values in the database.
There is other code that I haven't posted here. The above code is supposed to add the values into the database, but nothing happens. When I check the database, there are no entries, also PHP doesnt complain or give any errors or warnings. I have turned both errors and warnings ON. Any suggestions. Im clueless..
Posted: Thu Jul 10, 2003 1:33 am
by DuFF
Are you using POST as the method for your form? If so make sure the form tag looks like this:
Code: Select all
<form action=PAGEHERE enctype=multipart/form-data method=post>
Then use these variables to query your database:
Code: Select all
$result = mysql_query("INSERT INTO tblpresult VALUES ('NULL', '$_POSTї'pollID']', '$_POSTї'pollvalue']')");
mysql_close();
?>
Posted: Thu Jul 10, 2003 2:04 am
by pistolfire99
Duff:- Thank you for your help. Yes I am using POST and the multipart/form-data didnt work.
form1.html
Code: Select all
form tag
two fields, pollID --> hidden, pollvalue --> checkbox.
submit --> POST -->goto --> form2.php
form2.php
Code: Select all
connect to $db
$result = mysql_query("INSERT INTO tblpresult VALUES ('NULL', '$_POSTї'pollID']', '$_POSTї'pollvalue']')");
mysql_close();
?>
This is the URL if someone wants to test it out.
http://www.i2l2.com/zzpoll.php
Thats a shorter version. Hope this helps and hope I can be helped.
Posted: Thu Jul 10, 2003 12:22 pm
by pistolfire99
Anyone got any suggestions.
Posted: Thu Jul 10, 2003 7:05 pm
by DuFF
http://www.i2l2.com/zzpoll.php doesnt work, can you either link to the form page or post the full code from the form page?
Posted: Thu Jul 10, 2003 8:11 pm
by pistolfire99
Try this
http://www.i2l2.com/kpsnatest/zzpoll.php
Sorry bout the earlier thing, changed directories thinking it might help, but it didnt. Im desperate to try anything. Similar code works fine in other *.php files where I am updating and inserting information and so on. Its just that this wont work... wonder why?
Thank you for any help.
Posted: Thu Jul 10, 2003 8:15 pm
by m3mn0n
I just want to add that there is a
Database forum for a reason.

Posted: Thu Jul 10, 2003 9:13 pm
by pistolfire99
Sami:- Thank you for your input and I am aware of the $DB forum. This is more with my PHP than MySQL, or so I think.
Posted: Thu Jul 10, 2003 10:27 pm
by bionicdonkey
how many fields are there in your table?
Posted: Fri Jul 11, 2003 4:24 pm
by pistolfire99
This is really amazing and weird, if "TRUE"
My script works just "Perfect" now, without any changes at all. The problem I believe is something todo with Windows or MySQL server itself. Not sure which one is to blame... but I would say Windows.
I hadnt rebooted my windows XP SP1 computer for

this many days. Now I reboot the computer, start my MySQL server, Apache and so on... and the script works. No changes or whatsoever. Totally weird.
Anyway, thanks to all who spent time helping me.
Posted: Fri Jul 11, 2003 9:22 pm
by m3mn0n
hey, how do you get that command to work? Is it included with windows xp sp1 or is it a seperate program?
Thanks.
Posted: Fri Jul 11, 2003 9:30 pm
by pistolfire99
Sami
hey, how do you get that command to work? Is it included with windows xp sp1 or is it a seperate program?
Its a seperate program. You can download it from microsoft's website. Its called uptime. Alternatively, you can also download it from me, here is the link.
http://www.i2l2.com/uptime.rar
You will need Winrar 3.x or higher in order to open the file. Winrar can be downloaded from
http://www.rarlab.com/
Same probelm with Win98
Posted: Sat Jul 12, 2003 3:17 am
by jot-87
I have the same probelm but I use win98. This is what my code looks like:
$query = "INSERT INTO tagboard (date, name, text) VALUES(NOW(), ".$_POST['name'].", ".$_POST['text'].")";
if(!mysql_query($query, $link_id)) echo "error msg".$_POST['name'].".".$_POST['text'];
When I echo mysql_error() it says "Unknown column 'Peter' in 'field list'". Peter is the value of $_POST['name'].
Found a possible solution
Posted: Sat Jul 12, 2003 9:00 am
by jot-87
This is embaressing, I had just forgotten the single quotes... I also noticed that pistolfire99 uses single quotes around his NULL value, which I suspect is wrong.