• Resolved charlesp123

    (@charlesp123)


    I can’t figure this out … I have a simple php code
    here:
    $error=””; // Variable To Store Error Message
    if (isset($_POST[‘submited’])) {
    if (empty($_POST[‘username’]) || empty($_POST[‘password’])) {
    $error= “Utilisateur ou Mot de passe invalide”;
    }
    else
    {
    $username=$_POST[‘username’];
    $password=$_POST[‘password’];
    $username = stripslashes($username);
    $password = stripslashes($password);

    if ($username == “XXXX” && $password == “XXXX”) {
    $_SESSION[‘login_user’]=$username; // Initializing Session
    header(“location: https://mysite.ca/fr/$username”); // Redirecting To Other Page
    } else {
    $error= “Utilisateur ou Mot de passe invalide”;
    }
    }
    }
    ///// fin user login

    there is no error with that code right ? well I got this :
    Parse error: syntax error, unexpected ‘;’ in …mysite/wp-content/plugins/insert-php/insert_php.php(48) : eval()’d code on line 17

    I tried everything im thinking about an other way to insert php …what do u suggest ?

    • This topic was modified 8 years, 3 months ago by charlesp123.
Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author WillBontrager

    (@willbontrager)

    Charles, like you, I don’t see an error. But it’s there, on line 17, or the parser wouldn’t flag it. Maybe something earlier affects quotes or parenthesis.

    Perhaps a change was made in the WordPress edit box.

    Copy the code directly from your WordPress edit box and paste it into a reply. And use the “code” button above the support editing box so your code is properly formatted. I’ll paste it into my dev WP installation and see what I can see.

    Will

    Thread Starter charlesp123

    (@charlesp123)

    [insert_php]
    /// user login ///

    session_start(); // Starting Session
    $error=””; // Variable To Store Error Message
    if (isset($_POST[‘submited’])) {
    if (empty($_POST[‘username’]) || empty($_POST[‘password’])) {
    $error= “Utilisateur ou Mot de passe invalide”;
    }
    else
    {
    $username=$_POST[‘username’];
    $password=$_POST[‘password’];
    $username = stripslashes($username);
    $password = stripslashes($password);

    if ($username == “groupesanteducore” && $password == “admin”) {
    $_SESSION[‘login_user’]=$username; // Initializing Session
    header(“location: https://mysite/fr/$username”); // Redirecting To Other Page
    } else {
    $error= “Utilisateur ou Mot de passe invalide”;
    }
    }
    }
    ///// fin user login
    [/insert_php]
    <div style=”margin: auto; width: 300px;”><form method=”post”>
    <div class=””><label><b>Username</b></label>
    <input name=”username” type=”text” placeholder=”Enter Username” /></div>
    <label><b>Password</b></label>
    <input name=”password” type=”password” placeholder=”Enter Password” />

    <button name=”submited” type=”submit”>Envoyer</button>
    [insert_php]echo $error;[/insert_php]

    (If I put this code into a template page it is all working) but since I want it to “echo” any errors it doesn’t speak with [insert_php]echo $error;[/insert_php] when placed into the template thaw why I want to use insert php) any help ?
    </form></div>

    Thread Starter charlesp123

    (@charlesp123)

    oh and I use this with visual composer.

    Plugin Author WillBontrager

    (@willbontrager)

    Hi Charles,

    Thanks for telling me you’re using Visual Composer. It makes a different. That plugin does seem to provide grief for Insert PHP users, changing things even when they’re pasted in with the “Text” tab instead of the “Visual” tab. For example, it might expand "&" into "& amp;" (which would provide an unexpected semicolon). You could try using “and” instead of “&” and see if it will get you past that point.

    Regarding [insert_php]echo $error;[/insert_php]: $error probably won’t be accessible at that point. Variables aren’t carried from one [insert_php] block to another [insert_php] block. See https://www.willmaster.com/software/WPplugins/insert-php-wordpress-plugin-instructions.php#inandofitself

    Will

    Plugin Author WillBontrager

    (@willbontrager)

    The system won’t let me do any more edits to the above reply.

    The reason the “&” and the “amp;” have a space between them is because the rendering engine won’t print the HTML ampersand entity, insisting on changing it to “&”, even when it’s put into a ‘code’ block.

    Just venting frustration ??

    Oh, and
    using “and” instead of “&”
    in the above reply should read
    using “and” instead of “&&”

    Will

    Thread Starter charlesp123

    (@charlesp123)

    aha OMG you are right it does add amp; but using “and” just solved the problem it is working now thank you ! and yes my error in the second [insert_php]echo $error;[/insert_php] is working too ??

    thx very much !

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘parse error (;)’ is closed to new replies.