pinochio Posted September 21, 2009 Share Posted September 21, 2009 Hi I'm trying to make a guest list that will save user names and email into .txt file. When I was trying to run a script server got me this: Parse error: syntax error, unexpected T_VARIABLE, expecting ',' or ';' in c:\program files\apache group\Apache\htdocs\CT\signguestbook.php on line 70 line 70 is in blue. Thanks a lot!!! <?php error_reporting(E_ALL); function validateName($GuestName) { if (strpos($GuestName, " ") !== FALSE) return true; else return false; } function validateEmail($GuestEmail) { //validation emaIL if ((strpos($GuestEmail, "@") !== FALSE) && (strpos($GuestEmail, ".") !== FALSE)) return true; else return false; } function checkForDuplicates($GuestbookUser) // function check for duplicates. { $GuestbookUser_Var = explode("\n", $GuestbookUser); $Count = count($GuestbookUser); $RetValue = false; $i = 0; while ($i<$Count) { $j=0; while ($j<$Count) { if ($GuestbookUser[$i] == $GuestbookUser[$j] && $i != $j) $RetValue = true; ++$j; } ++$i; } return $RetValue; } $GuestName = $_POST["GuestName"]; //else if (validateName($_POST["GuestName"]) == FALSE) if (validateName($_POST["GuestName"]) == FALSE) echo "<p> Your name is not valid. There is no space in between. Click BACK button and type a valid name.</p>"; $GuestEmail = $_POST["GuestEmail"]; if (validateEmail($_POST["GuestEmail"]) == FALSE) echo"<p>Your email address is not valid. Click BACK button and type a valid email.</p>"; $GuestbookUser = $_POST["GuestName"] && $_POST["GuestEmail"]; //checking for duplicates {mistake here} if (checkforduplicates($GuestbookUser) == TRUE) //function is here but it is still not working echo "<p>Your name is used in our guestbook. Please click your browser's BACK button to return and enter different name.</p>"; else echo "<p>$GuestbookUser</p>" $UserArray = array($GuestbookUser); // line 70 $UserArray = explode($GuestbookUser); foreach ($UserArray as $GuestbookUser){ echo "$GuestbookUser<br />"; } $GuestbookFile = fopen("./GuestbookFile.txt", "a+");//writes data into a file variable for txt file fwrite($GuestbookFile,($_POST["GuestName"])); fwrite($GuestbookFile,($_POST["GuestEmail"])); fclose($GuestbookFile); ?> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/175021-debug-problem/ Share on other sites More sharing options...
Maq Posted September 21, 2009 Share Posted September 21, 2009 You're missing a semi-colon on the echo above line 70. NOTE: When posting code please use . Quote Link to comment https://forums.phpfreaks.com/topic/175021-debug-problem/#findComment-922398 Share on other sites More sharing options...
pinochio Posted September 21, 2009 Author Share Posted September 21, 2009 Thank a lot!!! when i fixed semicolon i got this: Warning: Wrong parameter count for explode() in c:\program files\apache group\Apache\htdocs\CT\signguestbook.php on line 71 Warning: Invalid argument supplied for foreach() in c:\program files\apache group\Apache\htdocs\CT\signguestbook.php on line 72 Quote Link to comment https://forums.phpfreaks.com/topic/175021-debug-problem/#findComment-922401 Share on other sites More sharing options...
Maq Posted September 21, 2009 Share Posted September 21, 2009 You need to specify a delimiter as the first parameter. Read the manual - explode. This should fix the second error as well. Quote Link to comment https://forums.phpfreaks.com/topic/175021-debug-problem/#findComment-922408 Share on other sites More sharing options...
pinochio Posted September 21, 2009 Author Share Posted September 21, 2009 Thanks for your help!!! this is what I got right now: Parse error: syntax error, unexpected '>' in c:\program files\apache group\Apache\htdocs\CT\signguestbook.php on line 67 Quote Link to comment https://forums.phpfreaks.com/topic/175021-debug-problem/#findComment-922418 Share on other sites More sharing options...
Maq Posted September 21, 2009 Share Posted September 21, 2009 Can you post the code and some lines surrounding it? Quote Link to comment https://forums.phpfreaks.com/topic/175021-debug-problem/#findComment-922448 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.