Sami Posted June 19, 2010 Share Posted June 19, 2010 I'm not getting the WAP part of my guestbook working!When I'm trying it on my phone, and I press "Post", it says "500 internal error". I'll guess it's the database part in the PHP code. <?xml version="1.0"?><!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN""http://www.wapforum.org/DTD/wml_1.1.xml"><wml> <card id="card1" title="Status"><p><?php$con = mysql_connect('localhost','gbok','Linux2');$r = mysql_real_escape_string($_REQUEST["comment"], $con);$n = mysql_real_escape_string($_REQUEST["name"], $con);$d = date("d.m.Y H:i");if (!$con) { echo "Kunne ikke koble til database!"; die(); }mysql_select_db("gbok", $con);$banned=mysql_query("SELECT * FROM banned");while($row = mysql_fetch_array($banned)) { if($row['ip']==$_SERVER["REMOTE_ADDR"]) { $uban=true; } }if($uban==true){echo "Du har IP-ban!";}else{if($_REQUEST["name"] == "Sami"){echo "Navnet er reservert!"}else{$sql="INSERT INTO comments (date, name, comment, ip)VALUES('$d','$n','$r','$_SERVER[REMOTE_ADDR]')";if (!mysql_query($sql,$con)) { die(mysql_error($con)); } else { echo "Hilseses ble postet!<br><a href=\"wap.php\">Tilbake</a>"; } }}mysql_close($con);?></p></card></wml> Link to comment Share on other sites More sharing options...
jeffman Posted June 19, 2010 Share Posted June 19, 2010 A 500 error or blank screen usually means a parsing (syntax) error. Usually, this is a missing semicolon, or mismatched parentheses or braces. I do notice a missing semicolon in this line:echo "Navnet er reservert!"and that is enough to cause the error you mentioned.Also, be aware that the second argument to mysql_real_escape_string is optional, and in this case seems unnecessary. I doubt it is causing any errors, but you might remove it anyway.You could do yourself a big favor by indenting code blocks more consistently. That is the best way to track down missing, incorrect, or duplicate braces, as well as logic errors. I indented your code myself, and did not notice any missing braces, but indentation is still a good practice. (Please ignore this comment if the indentation is incorrectly reproduced in the forum.) Link to comment Share on other sites More sharing options...
Sami Posted June 19, 2010 Author Share Posted June 19, 2010 echo "Navnet er reservert!"I know that might cause errors, but I didn't detect it myself. Thx!EDIT: Didn't seem to work, and it costs to much using my phone for testing. Do you know any WAP-browsers for PC? Link to comment Share on other sites More sharing options...
wirehopper Posted June 20, 2010 Share Posted June 20, 2010 There are several WAP simulators - you can find them with Google. I used WinWAP - it works fine.You may want to look into mobileOK XHTML, instead of WML, depending on your target market. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.