adamriley Posted January 9, 2010 Share Posted January 9, 2010 hi im having a little trobble with this script -------------------------------------------------------------------------------------------- error log -------------------------------------------------------------------------------------------- [sat Jan 09 17:00:16 2010] [error] [client 127.0.0.1] PHP Parse error: syntax error, unexpected T_LNUMBER, expecting T_VARIABLE or '$' in C:\\web\\htdocs\\Filey\\create.php on line 5 ------------------------------------------------------------------------------------------------ create.php --------------------------------------------------------------------------------------------- <?php $filler1 = "<html><head><title>$1</title>"; $filler2 = "<body>$3</body></html>"; $filler3 = "<div>$2</div>"; $1 = $_POST["PN"]; $2 = $_POST["Date_name"]; $3 = $_POTS["Note"]; $myFile = "notenw.html"; $fh = fopen($myFile, 'w') or die("can't open file"); $stringData = "$filler1"; $stringData1 = "$filler2"; $stringData2 = "$filler3"; fwrite($fh, "$stringData\n"); fwrite($fh, "$stringData1\n"); fwrite($fh, "$stringData2\n"); fclose($fh); header('Location: http://localhost/Docs/$myfile'); ?> code for 1.php ----------------------------------------------------------------------------------------------------------- <?php require_once('http://localhost/Login/common.php');?> <?php if ($_SESSION['userName'] == 'Adamriley') { $name = 'Adam lee riley';} else { $name = 'Nathan Warburton';} ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Untitled Page</title> <script language="JavaScript" type="text/javascript"> <!-- function ValidateForm1(theForm) { var strFilter = /^[A-Za-zÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ \t\r\n\f0-9-]*$/; var chkVal = theForm.TextArea1.value; if (!strFilter.test(chkVal)) { alert("In your note you may only have a maximum of 100 letters"); theForm.TextArea1.focus(); return false; } if (theForm.TextArea1.value == "") { alert("In your note you may only have a maximum of 100 letters"); theForm.TextArea1.focus(); return false; } if (theForm.TextArea1.value.length < 2) { alert("In your note you may only have a maximum of 100 letters"); theForm.TextArea1.focus(); return false; } if (theForm.TextArea1.value.length > 100) { alert("In your note you may only have a maximum of 100 letters"); theForm.TextArea1.focus(); return false; } return true; } //--> </script> </head> <body bgcolor="#FFFFFF" text="#000000"> <div id="bv_Form1" style="position:absolute;left:58px;top:59px;width:704px;height:356px;z-index:5;" align="left"> <form name="Form1" method="POST" action="create.php" id="Form1" onsubmit="return ValidateForm1(this)"> <input type="text" id="Editbox2" style="position:absolute;left:94px;top:36px;width:483px;font-family:Courier New;font-size:16px;z-index:0" name="Date_name" value="<?php echo date("F j, Y, g:i a"); ?> || <?php echo $name ?>" readonly="readonly"> <input type="text" id="Editbox1" style="position:absolute;left:93px;top:4px;width:489px;font-family:Courier New;font-size:16px;z-index:1" name="PN" value="Page name (title)"> <textarea name="Note" id="TextArea1" style="position:absolute;left:81px;top:63px;width:547px;height:215px;font-family:Courier New;font-size:16px;z-index:2" rows="10" cols="51"></textarea> <input type="submit" id="Button1" name="Button1" value="Save changes" style="position:absolute;left:336px;top:293px;width:194px;height:41px;border:3px #98FB98 solid;background-color:#0000FF;color:#FFFF00;font-family:Bookman Old Style;font-size:27px;z-index:3"> <input type="reset" id="Button2" name="Reset" value="Reset note" style="position:absolute;left:158px;top:291px;width:167px;height:44px;border:3px #FFFF00 dotted;background-color:#00FF00;color:#FF0000;font-family:Arial;font-size:27px;z-index:4"> </form> </div> <div id="bv_Text1" style="position:absolute;left:334px;top:9px;width:150px;height:32px;z-index:6;" align="left"> <font style="font-size:27px" color="#FF0000" face="Arial"><b>New note</b></font></div> </body> </html> Link to comment https://forums.phpfreaks.com/topic/187839-syntax-error/ Share on other sites More sharing options...
premiso Posted January 9, 2010 Share Posted January 9, 2010 You cannot use a number for a variable name. You can do $a1, but not $1 or $1a. Link to comment https://forums.phpfreaks.com/topic/187839-syntax-error/#findComment-991752 Share on other sites More sharing options...
wildteen88 Posted January 9, 2010 Share Posted January 9, 2010 <?php require_once('http://localhost/Login/common.php');?> You should not include/require files via urls, as variables/functions defined within the included file will not be inherited. Link to comment https://forums.phpfreaks.com/topic/187839-syntax-error/#findComment-991754 Share on other sites More sharing options...
adamriley Posted January 9, 2010 Author Share Posted January 9, 2010 so how would you "require_once" a file if you was on "http://localhost/Filey/2.php" and you want to require "http://localhost/Login/common.php" what would put as the url Link to comment https://forums.phpfreaks.com/topic/187839-syntax-error/#findComment-991758 Share on other sites More sharing options...
wildteen88 Posted January 9, 2010 Share Posted January 9, 2010 There are two ways absolute file path require_once $_SERVER['DOCUMENT_ROOT'] . 'Login/common.php'; Or a relative path require_once '../Login/common.php'; Link to comment https://forums.phpfreaks.com/topic/187839-syntax-error/#findComment-991760 Share on other sites More sharing options...
adamriley Posted January 9, 2010 Author Share Posted January 9, 2010 ok thanks very much Link to comment https://forums.phpfreaks.com/topic/187839-syntax-error/#findComment-991763 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.