twitch987 Posted January 13, 2009 Share Posted January 13, 2009 after an exhausting post figuring out what was wrong and finally getting everything to work, its all gone downhill. all i tried to do was add more fields to the database table + the input page and now the thing aint working. can anyone spot where i've messed up? i get no errors but it doesnt insert the info. input page <form action="insert.php" method="post"> bedrooms: <input type="text" name="bedrooms"><br> bathrooms: <input type="text" name="bathrooms"><br> area: <input type="text" name="area"><br> postcode: <input type="text" name="postcode"><br> ref: <input type="text" name="ref"><br> description:<input type="text" name="description"></textarea><br> rent pw: <input type="text" name="rentpw"><br> rentpm: <input type="text" name="rentpm"><br> deposit: <input type="text" name="deposit"><br> availability: <input type="text" name="availability"><br> type: <input type="text" name=type"><br> address: <input type="text" name="address"><br> image: <input type="text" name="image"><br> <input type="Submit"> </form> insert.php <? include("dbinfo.inc.php"); mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die(mysql_error()); $bedrooms=$_POST['bedrooms']; $bathrooms=$_POST['bathrooms']; $area=$_POST['area']; $postcode=$_POST['postcode']; $ref=$_POST['refs']; $description=$_POST['description']; $rentpw=$_POST['rentpw']; $rentpm=$_POST['rentpm']; $deposit=$_POST['deposit']; $propertynear=$_POST['propertynear']; $availability=$_POST['availability']; $type=$_POST['type']; $address=$_POST['address']; $image=$_POST['image']; $query = "INSERT INTO properties VALUES ('','$bedrooms','$bathrooms','$area','$postcode','$ref','$description','$rentpw','$rentpm','$deposit','$propertynear','$availability,'$type','$address','$image')"; mysql_query($query); echo("Success."); mysql_close(); ?> Quote Link to comment https://forums.phpfreaks.com/topic/140736-solved-phpmysql-question-de-ja-vu/ Share on other sites More sharing options...
gevans Posted January 13, 2009 Share Posted January 13, 2009 description:<input type="text" name="description"></textarea><br> should be description:<textarea type="text" name="description"></textarea><br> Quote Link to comment https://forums.phpfreaks.com/topic/140736-solved-phpmysql-question-de-ja-vu/#findComment-736591 Share on other sites More sharing options...
twitch987 Posted January 13, 2009 Author Share Posted January 13, 2009 ah man its been a long day - well spotted.. i sorted that but still having the same problem Quote Link to comment https://forums.phpfreaks.com/topic/140736-solved-phpmysql-question-de-ja-vu/#findComment-736594 Share on other sites More sharing options...
gevans Posted January 13, 2009 Share Posted January 13, 2009 type: <input type="text" name=type"><br> should be type: <input type="text" name="type"><br> Quote Link to comment https://forums.phpfreaks.com/topic/140736-solved-phpmysql-question-de-ja-vu/#findComment-736598 Share on other sites More sharing options...
twitch987 Posted January 13, 2009 Author Share Posted January 13, 2009 a REAL long day.. didnt solve the problem though Quote Link to comment https://forums.phpfreaks.com/topic/140736-solved-phpmysql-question-de-ja-vu/#findComment-736600 Share on other sites More sharing options...
revraz Posted January 13, 2009 Share Posted January 13, 2009 echo $query and check the variables put mysql_error after your query command to check for errors. Quote Link to comment https://forums.phpfreaks.com/topic/140736-solved-phpmysql-question-de-ja-vu/#findComment-736602 Share on other sites More sharing options...
gevans Posted January 13, 2009 Share Posted January 13, 2009 change insert.php to this <?php include("dbinfo.inc.php"); $link = mysql_connect('localhost', $username, $password); if (!$link) { die('Could not connect: ' . mysql_error()); } $db_selected = mysql_select_db($database, $link); if (!$db_selected) { die("Can't use $database : " . mysql_error()); } $bedrooms=$_POST['bedrooms']; $bathrooms=$_POST['bathrooms']; $area=$_POST['area']; $postcode=$_POST['postcode']; $ref=$_POST['refs']; $description=$_POST['description']; $rentpw=$_POST['rentpw']; $rentpm=$_POST['rentpm']; $deposit=$_POST['deposit']; $propertynear=$_POST['propertynear']; $availability=$_POST['availability']; $type=$_POST['type']; $address=$_POST['address']; $image=$_POST['image']; $query = "INSERT INTO properties VALUES ('','$bedrooms','$bathrooms','$area','$postcode','$ref','$description','$rentpw','$rentpm','$deposit','$propertynear','$availability,'$type','$address','$image')"; $result = mysql_query($query); if (!$result) { die('Invalid query: ' . mysql_error()); } else { echo("Success."); } ?> and see what happens, if you get an error post it Quote Link to comment https://forums.phpfreaks.com/topic/140736-solved-phpmysql-question-de-ja-vu/#findComment-736603 Share on other sites More sharing options...
revraz Posted January 13, 2009 Share Posted January 13, 2009 Missing single quote in the query string '$availability Quote Link to comment https://forums.phpfreaks.com/topic/140736-solved-phpmysql-question-de-ja-vu/#findComment-736605 Share on other sites More sharing options...
twitch987 Posted January 13, 2009 Author Share Posted January 13, 2009 still showing "success" but doing not entering anything.. im confused. Quote Link to comment https://forums.phpfreaks.com/topic/140736-solved-phpmysql-question-de-ja-vu/#findComment-736612 Share on other sites More sharing options...
revraz Posted January 13, 2009 Share Posted January 13, 2009 echo $query and check the variables put mysql_error after your query command to check for errors. Quote Link to comment https://forums.phpfreaks.com/topic/140736-solved-phpmysql-question-de-ja-vu/#findComment-736613 Share on other sites More sharing options...
gevans Posted January 13, 2009 Share Posted January 13, 2009 Did you do what I said or what Revraz said?? If you did as Revraz said I'm guessing you didn't add the error reporting as you mentioned. Also, just as a note you're echoing 2success2 out at the end of the page, as long as there's not a fatal error that will always print not matter what happens Quote Link to comment https://forums.phpfreaks.com/topic/140736-solved-phpmysql-question-de-ja-vu/#findComment-736615 Share on other sites More sharing options...
twitch987 Posted January 13, 2009 Author Share Posted January 13, 2009 sorry i think i just read the last post.. like i said - long day INSERT INTO properties VALUES ('','','','','','','','','','','','','','','') Quote Link to comment https://forums.phpfreaks.com/topic/140736-solved-phpmysql-question-de-ja-vu/#findComment-736618 Share on other sites More sharing options...
revraz Posted January 13, 2009 Share Posted January 13, 2009 So now you know your form isn't posting. Troubleshoot why. Quote Link to comment https://forums.phpfreaks.com/topic/140736-solved-phpmysql-question-de-ja-vu/#findComment-736619 Share on other sites More sharing options...
twitch987 Posted January 13, 2009 Author Share Posted January 13, 2009 i honestly dont have the php knowledge to find the problem.. i've looked gone over and over it in dreamweaver trying to see something out of place buti got nothin.. Quote Link to comment https://forums.phpfreaks.com/topic/140736-solved-phpmysql-question-de-ja-vu/#findComment-736627 Share on other sites More sharing options...
revraz Posted January 14, 2009 Share Posted January 14, 2009 Has nothing to do with PHP, the form is HTML. Quote Link to comment https://forums.phpfreaks.com/topic/140736-solved-phpmysql-question-de-ja-vu/#findComment-736638 Share on other sites More sharing options...
twitch987 Posted January 14, 2009 Author Share Posted January 14, 2009 well yeah obviously but i cant see anything wrong with the HTML and dreamweaver doesnt seem to have any objections to it.. as for what happens after submission i havent a clue about that.. aside from the previous typo's which were ammended i dont see anything wrong <form action="insert.php" method="post"> bedrooms: <input type="text" name="bedrooms"><br> bathrooms: <input type="text" name="bathrooms"><br> area: <input type="text" name="area"><br> postcode: <input type="text" name="postcode"><br> ref: <input type="text" name="ref"><br> description:<input type="text" name="description"><br> rent pw: <input type="text" name="rentpw"><br> rentpm: <input type="text" name="rentpm"><br> deposit: <input type="text" name="deposit"><br> availability: <input type="text" name="availability"><br> type: <input type="text" name="type"><br> address: <input type="text" name="address"><br> image: <input type="text" name="image"><br> <input type="Submit"> </form> Quote Link to comment https://forums.phpfreaks.com/topic/140736-solved-phpmysql-question-de-ja-vu/#findComment-736650 Share on other sites More sharing options...
premiso Posted January 14, 2009 Share Posted January 14, 2009 In the insert.php page do a print_r($_POST); and report back what it prints. See if the data is even coming through. Quote Link to comment https://forums.phpfreaks.com/topic/140736-solved-phpmysql-question-de-ja-vu/#findComment-736657 Share on other sites More sharing options...
twitch987 Posted January 14, 2009 Author Share Posted January 14, 2009 had to echo($_POST) as print_r has been disable for some security reason.. does this make a difference? It just says "Array" Quote Link to comment https://forums.phpfreaks.com/topic/140736-solved-phpmysql-question-de-ja-vu/#findComment-736662 Share on other sites More sharing options...
premiso Posted January 14, 2009 Share Posted January 14, 2009 had to echo($_POST) as print_r has been disable for some security reason.. does this make a difference? It just says "Array" Yea, if print_r is disabled do this: foreach ($_POST as $key => $val) echo "key :: $key => value :: $val <br />"; And see what that prints. Quote Link to comment https://forums.phpfreaks.com/topic/140736-solved-phpmysql-question-de-ja-vu/#findComment-736666 Share on other sites More sharing options...
twitch987 Posted January 14, 2009 Author Share Posted January 14, 2009 done.. nothing comes up Quote Link to comment https://forums.phpfreaks.com/topic/140736-solved-phpmysql-question-de-ja-vu/#findComment-736669 Share on other sites More sharing options...
trq Posted January 14, 2009 Share Posted January 14, 2009 Place this at the top of your script then submit your form. <?php echo "form submitted"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/140736-solved-phpmysql-question-de-ja-vu/#findComment-736674 Share on other sites More sharing options...
twitch987 Posted January 14, 2009 Author Share Posted January 14, 2009 echoes "form submitted" also its still telling me the query INSERT INTO lettings VALUES ('','','','','','','','','','','','','','','') after going into PHPMyAdmin i noticed it does insert the data, but obviously the fields are left blank Quote Link to comment https://forums.phpfreaks.com/topic/140736-solved-phpmysql-question-de-ja-vu/#findComment-736677 Share on other sites More sharing options...
premiso Posted January 14, 2009 Share Posted January 14, 2009 There is something wrong with the post variables contact your host and ask about it. Quote Link to comment https://forums.phpfreaks.com/topic/140736-solved-phpmysql-question-de-ja-vu/#findComment-736683 Share on other sites More sharing options...
dawsba Posted January 14, 2009 Share Posted January 14, 2009 sounds like your safe moded up the wazu, had similar prob on goverment intranet, had to use $_REQUEST instead of $_POST. Quote Link to comment https://forums.phpfreaks.com/topic/140736-solved-phpmysql-question-de-ja-vu/#findComment-736699 Share on other sites More sharing options...
twitch987 Posted January 14, 2009 Author Share Posted January 14, 2009 wow, thats annoying. wish i wasnt with UK2 they take like 3 hours to say "we're looking into it" thanks for your help Quote Link to comment https://forums.phpfreaks.com/topic/140736-solved-phpmysql-question-de-ja-vu/#findComment-736701 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.