|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
mysql record insert
Hi, I am a newbie and am having troubles with record insert. When I insert through a form the auto increment updates but no data is written to the db. Here is the code for the 2 forms. Can someone please help. Using latest PHP and MySql and Apache. Thanks
Form 1 <html> <body> <form action=submitform.php method=POST> First Name: <input type=text name=first_name size=25 maxlength=25> Last Name: <input type=text name=last_name size=25 maxlength=25> <p> <input type=submit> </form> </body> </html> Form 2 <?php $location = "localhost"; $username = "admin"; $password = "131154"; $database = "ausvans"; $conn = mysql_connect("$location","$username","$password"); if (!$conn) die ("Could not connect to database"); mysql_select_db($database,$conn) or die ("Could not open database"); $insert = "insert into newsletter (first_name,last_name) values ('$first_name','$last_name')"; mysql_query ($insert) or die ("Could not add data to table"); echo $_POST["first_name"]; print (" "); echo $_POST["last_name"]; print ("<p>"); print ("Thanks for submitting your name."); ?> |
|
#2
|
|||
|
|||
|
RE: mysql record insert
If your message at the end is displaying ok, it probably means that you may have register_globals off in your php.ini - try putting the following lines in before you define the $insert variable:
of course, you could just use the $_POST statements within the $insert declaration |
|
#3
|
|||
|
|||
|
RE: mysql record insert
Thanks for the info. It worked placing the variables b4 the insert command, but I tried putting the $_POST into the actual insert statement no luck. What is the correct syntax to use on the previous example.
|
|
#4
|
||||
|
||||
|
RE: mysql record insert
|
![]() |
| Viewing: Codewalkers Forums > Other Technologies > Database Help > mysql record insert |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|