Jump to content

WAP guestbook


Sami
 Share

Recommended Posts

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

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.)

Edited by Deirdre's Dad
Link to comment
Share on other sites

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? Edited by Sami
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...