Jump to content

debug problem


pinochio

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.