insrtsnhere13 Posted May 3, 2006 Share Posted May 3, 2006 Hey guys, recently installed WAMP on my laptop and Im having some trouble posting.i get this error:ForbiddenYou don't have permission to access /< on this server.Apache/2.0.55 (Win32) PHP/5.1.2 Server at localhost Port 80using this script:[code]<?phpif (!isset($_POST['submit'])) {?><form action="<?=$_SERVER['PHP_SELF']?>" method="post">Name of page (ex: Home, News):<br><input type="text" name="page" size="50"><br><br>Heading to appear above content ("Business Hours:, Services:,"):<br><input type="text" name="title" size="50"><br><br>Content to be displayed:<br><textarea name="content" rows=7 cols=46></textarea><br><br><input type="submit" name="submit" value="Submit"></form><?php}else {include("connect.php"); $page = $_POST['page']; $title = $_POST['title']; $content = $_POST['content']; $sql = "INSERT INTO pages VALUES ('$page', '$title', '$content')"; $result = mysql_query($sql) or die ("Error in query: $sql. ".mysql_error()); // print message with ID of inserted record echo "New record inserted with ID ".mysql_insert_id(); // close connection mysql_close($connection);}?>[/code] Quote Link to comment Share on other sites More sharing options...
judeddokoinu Posted May 3, 2006 Share Posted May 3, 2006 Not sure about the error, but you do have an extra "=" in this line:[code]<form action="<?=$_SERVER['PHP_SELF']?>"[/code]Should be:[code]<form action="<? $_SERVER['PHP_SELF'] ?>"[/code] Quote Link to comment Share on other sites More sharing options...
insrtsnhere13 Posted May 4, 2006 Author Share Posted May 4, 2006 one thing i found, i think my includes arent working for some reason.. like i said, i just installed WAMP and havent messed with any configurations.. if someone could help me..What I did was moved all of the actuall code to a file called post.php and left the form and renamed it form.htmlwhen i had an include calling my database info i got a mysql error saying it couldnt connect using OBDC@localhost or whatever... and when I moved the actuall variables into the post script itself it worked fine. So it leads me to believe that includes are turned off and something is wrong with the SERVER['SELF'] thing.. Quote Link to comment Share on other sites More sharing options...
insrtsnhere13 Posted May 4, 2006 Author Share Posted May 4, 2006 found something else.. if i do<?include("nav.php");?>i get a blank screen..if i do<?phpinclude("nav.php");?>i get what i need.. anyone know a way to disable that <?php thing so i can just do <?and if i do something like.. have part of a php script at the top, end the <? ?> somewhere in the middle to display html without having to worry about echos and the reopen the php tags.. it messes up that page and display the rest of the php coding without parsing it Quote Link to comment Share on other sites More sharing options...
neylitalo Posted May 4, 2006 Share Posted May 4, 2006 It's a php.ini setting called short_open_tag, and it needs to be set to "on". However, I suggest you keep it "off", and get in the habit of using <?php, so your code will be compatible with all servers.And judeddokoinu:[b] [/b]With short_open_tag set to "on", <?=$variable?> will echo the contents of $variable - it does the same as:[code]<?phpecho $variable;?>[/code]However, some servers do not support that syntax (the ones with short_open_tag = off) and so you should avoid that way of echoing data. Quote Link to comment 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.