SitePoint Sponsor

User Tag List

Results 1 to 9 of 9

Thread: Parse error

  1. #1
    SitePoint Member
    Join Date
    Nov 2004
    Location
    Belgium
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Parse error

    Hello,

    My first insert Query in PHP...
    Can you help me find out what's the error ? on line 151.

    This is the code

    $sql = "INSERT INTO
    clients
    SET
    firme = '$firme',
    nom ='$nom',
    prenom = '$prenom',
    adresse = '$adresse',
    codepostal = '$codepostal',
    localite = '$localite',
    pays = '$pays',
    telephone = '$telephone',
    fax = '$fax',
    tva = '$tva', email = '$email',
    password = '$password', ristourne = '10', datein = '2004-11-16'
    ";

    Thanks,
    Ndagi

  2. #2
    SitePoint Wizard mark_W's Avatar
    Join Date
    Mar 2004
    Location
    West Midlands, United Kingdom
    Posts
    2,631
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Can you post the rest of the script by any chance.

    Mark

  3. #3
    SitePoint Member
    Join Date
    Nov 2004
    Location
    Belgium
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    Here is the rest of the code.
    The connection to the database works.

    Thanks,
    Ndagi

    Code :

    $firme = $_POST['firme'];
    $tva = $_POST['tva'];
    $nom = $_POST['nom'];
    $prenom = $_POST['prenom'];
    $adresse = $_POST['adresse'];
    $codepostal = $_POST['codepostal'];
    $ville = $_POST['ville'];
    $pays = $_POST['pays'];
    $telephone = $_POST['tel'];
    $fax = $_POST['fax'];

    $email = $_POST['login'];
    $mdp = $_POST['mdp'];
    $rmdp = $_POST['rmdp'];

    $dbcnx = @mysql_connect(mysite',admin,'password');
    if (!$dbcnx){echo("<b>Erreur de connexion !!!</b>.<p> Veuillez réessayer plus tard.<p> Avec toutes nos excuses pour les désagréments.");}
    else{
    mysql_select_db('tvadmin')
    $sql = "INSERT INTO
    clients
    SET
    firme = '$firme',
    nom ='$nom',
    prenom = '$prenom',
    adresse = '$adresse',
    codepostal = '$codepostal',
    localite = '$localite',
    pays = '$pays',
    telephone = '$telephone',
    fax = '$fax',
    tva = '$tva',
    email = '$email',
    password = '$password',
    ristourne = '10',
    datein = '2004-11-16'
    ";
    if(@mysql_query($sql)){
    $mlsend = @mail($email, "Inscription sur TerreVivante.be","Cher $nom $prenom, Nous vous remercions pour la confiance en notre service. Ci-dessous votre nom d'utilisateur et adresse éléctronique. Pour confirmer vos commandes sur TerreVivante.be, il vous suffira de saisir votre nom d'utilisateur et votre mot de passe.Merci de faire vos achats sur TerreVivante.be");
    if (!$mlsend){
    echo("Mail sent");
    }
    else{
    //Message à l'écran.
    echo("blabla");
    }
    }else{
    echo("ERROR.");
    }

    }

  4. #4
    SitePoint Guru
    Join Date
    Sep 2004
    Location
    NY, USA
    Posts
    712
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What's the error you're getting? One thing that jumps out at me is this

    $dbcnx = @mysql_connect(mysite',admin,'password');

    but maybe you just changed those before posting and forgot to quote properly. (Hint: Nobody knows what line 151 is. The fact that you already know the line number should make this easy enough to track down.)

  5. #5
    SitePoint Member
    Join Date
    Nov 2004
    Location
    Belgium
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I changed the connection line before posting and in my code it's right

    $dbcnx = @mysql_connect('mysite','admin,'password');

    The Line 151 is the one begining with $sql = "INSERT INTO...

  6. #6
    SitePoint Guru
    Join Date
    Sep 2004
    Location
    NY, USA
    Posts
    712
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    mysql_select_db('tvadmin'); <--- forgot semi-colon

  7. #7
    SitePoint Member
    Join Date
    Nov 2004
    Location
    Belgium
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you !

  8. #8
    SitePoint Guru
    Join Date
    Sep 2004
    Location
    NY, USA
    Posts
    712
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No problem

    As a bit of advice... for simple parse errors like that you can usually look directly above the line that threw the error. In most cases that's where you'll find it.

    If the error line number is the last line of your script then it's likely you have a broken control structure somewhere (forgot to close an if statement or a loop... double check your curly brackets)

  9. #9
    SitePoint Member
    Join Date
    Nov 2004
    Location
    Belgium
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'll keep this in mind.
    Ndagi


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •