Mrkay Posted October 9, 2013 Share Posted October 9, 2013 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><?phpif (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> Quote Link to comment https://forums.phpfreaks.com/topic/282838-record-insert-not-working/ Share on other sites More sharing options...
AbraCadaver Posted October 9, 2013 Share Posted October 9, 2013 Stop using mysql_ functions use mysqli_ or PDO. Use mysqli_error(). Quote Link to comment https://forums.phpfreaks.com/topic/282838-record-insert-not-working/#findComment-1453279 Share on other sites More sharing options...
cyberRobot Posted October 9, 2013 Share Posted October 9, 2013 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 Quote Link to comment https://forums.phpfreaks.com/topic/282838-record-insert-not-working/#findComment-1453283 Share on other sites More sharing options...
Mrkay Posted October 9, 2013 Author Share Posted October 9, 2013 Thanks for the advice I'll take it on-board. Still, I don't think it will solve the particular problem here. Quote Link to comment https://forums.phpfreaks.com/topic/282838-record-insert-not-working/#findComment-1453290 Share on other sites More sharing options...
AbraCadaver Posted October 9, 2013 Share Posted October 9, 2013 Thanks for the advice I'll take it on-board. Still, I don't think it will solve the particular problem here. It will tell you what the problem is! That's the first step in solving the problem. Quote Link to comment https://forums.phpfreaks.com/topic/282838-record-insert-not-working/#findComment-1453293 Share on other sites More sharing options...
Mrkay Posted October 9, 2013 Author Share Posted October 9, 2013 Thanks Abra. Quote Link to comment https://forums.phpfreaks.com/topic/282838-record-insert-not-working/#findComment-1453327 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.