Jump to content

Record insert not working


Mrkay

Recommended Posts

Hi and thanks in advance.

The following code is supposed to insert a record in a MySql tab anf for reason its not inserting anything. It was working but since adding the textarea's and dropdown it has stopped. There is no error message. Any ideas?

<form method="post">
<table>
<tr>
<td>Resort Name</td>
<td><input type="text" name="resortname" /></td>
</tr>
<tr>
<td>Ric No.</td>
<td><input type="text" name="ric" /></td>
</tr>
<tr>
<td valign="top">Resort Description</td>
<td><textarea name="resortdesc" cols="50" rows="6"></textarea></td>
</tr>
<tr>
<td valign="top">Address</td>
<td><textarea name="address" cols="50" rows="6"></textarea></td>
</tr>
<tr>
<td>Exchange</td>
<td><input type="text" name="exchange" /></td>
</tr>
<tr>
<td>Check in day</td>
<td><input type="text" name="checkinday" /></td>
</tr>
<tr>
<td>Resort Status</td>
<td><input type="text" name="rstatus" /></td>
</tr>
<tr>
<td>Golf Facilities</td>
<td><select name="rgolf">
<option value="TRUE">TRUE</option>
<option value="FALSE">FALSE</option>
</select></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="submit" value="add" /></td>
</tr>
</table>
<?php
if (isset($_POST['submit']))
{
include 'db.php';

$resortname=$_POST['resortname'] ;
$ric= $_POST['ric'] ;
$resortdesc=$_POST['resortdesc'] ;
$address=$_POST['address'] ;
$exchange=$_POST['exchange'] ;
$checkinday=$_POST['checkinday'] ;
$rstatus=$_POST['rstatus'] ;
$rgolf=$_POST['rgolf'] ;

mysql_query("INSERT INTO `Resort`(ResortName,Ric,ResortDesc, Address, Exchange, CheckinDay, RStatus, RGolf ) 
VALUES ('$resortname','$ric', '$resortdesc','$address','$exchange','$checkinday,'$rstatus','$rgolf')"); 


}
?>
</form>

Link to comment
https://forums.phpfreaks.com/topic/282838-record-insert-not-working/
Share on other sites

As AbraCadaver suggested, you should look into the alternatives for mysql_ functions since they are depreciated. More information about the alternatives can be found here:

http://www.php.net/manual/en/mysqlinfo.api.choosing.php

 

In the meantime, mysql_error() will show if the query is causing errors. An example showing how to use the function can be found here:

http://php.net/manual/en/function.mysql-error.php

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.