Jump to content

Recommended Posts

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>

Link to comment
https://forums.phpfreaks.com/topic/175021-debug-problem/
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/175021-debug-problem/#findComment-922401
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.