Saving data error: Parse error: syntax error, unexpected ')'

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ehpratah
    New Member
    • Mar 2012
    • 35

    Saving data error: Parse error: syntax error, unexpected ')'

    hi im having a problem in saving data in my database and i try everything i know but still im having this error message in my page..please help me thanks guys

    Code:
    <?php
    /*$cs = mysql_connect ('localhost')or die ("not connect .". mysql_error());
    $ds = mysql_select_db ('dbase')or die ("no data .". mysql_error());
    
    $host = 'localhost';
    $username = 'globaml6';
    $password = 'Gwd_2011';
    
    $conn = mysql_connect($host, $username, $password) or die('Error connecting to mysql');
    
    $dbname = 'globaml6_gwd';
    mysql_select_db($dbname);
    */
    $dbhost = 'localhost';
    $dbuser = 'root';
    $dbpass = '';
    
    $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');
    
    $dbname = 'msic';
    mysql_select_db($dbname);
    
    
    
    
    $sql="INSERT INTO sd (Pickday, Pickmonth, Pickhour, Pickmin, Rday, Rmonth, Rhour, Rmin, Origin, Destination, Vehicle, Fname, Lname, Email, Contact, Address, Zip, City, Country) 
    VALUES ('".$_POST['txtpday']."', '".$_POST['txtpmonth']."', '".$_POST['txtphr']."', '".$_POST['txtpmin']."', '".$_POST['txtrday']."',  '".$_POST['txtrmonth']."',  '".$_POST['txtrhr']."',  '".$_POST['txtrmin']."', '".$_POST['txtorigin']."', '".$_POST['txtdestination']."',  '".$_POST['txtvehicle']."',  '".$_POST['txtfname']."', '".$_POST['txtlname']."',  '".$_POST['txtemail']."',  '".$_POST['txtcontact']."',  '".$_POST['txtadd']."', '".$_POST['txtzip']."',  '".$_POST['txtcity']."',  '".$_POST['txtcountry']);
    
    
    
    
    if (!mysql_query($sql,$conn))
      {
      die('Error: ' . mysql_error());
      }
    	header("location:index.html");
    
    
    mysql_close($conn)
    
    
    /*
    	$result=mysql_query($sql);	
    	echo $sql;
    	echo $result;
    */
    ?>
    this is the error

    Parse error: syntax error, unexpected ')' in C:\xampp\htdocs \msicweb\sdsave .php on line 27
    Last edited by Niheel; Mar 31 '12, 08:21 AM.
  • Luuk
    Recognized Expert Top Contributor
    • Mar 2012
    • 1043

    #2
    Look a the code below, and try to understand what it does,
    After understanding the quotes, you will know how to change your code:

    Code:
    <?php
            $nl="<br>".PHP_EOL;
            print 'This will only print the letter t: t'.$nl;
            print 'This will print the letter t followed by a single-quoot: t\''.$nl;
            print "This will print a single-quoot: '".$nl;
            print "This will print two single-quotes: ''".$nl;
            print 'This will print one single-quote: \''.$nl;
            print 'This should print two single-quotes: \'\''.$nl;
            print 'This will print a double-quoot: "'.$nl;
            print "This will also print a double-quoot: \"".$nl;
    ?>

    Comment

    • ehpratah
      New Member
      • Mar 2012
      • 35

      #3
      luuk can you help me pinpoint where is my error cause i already scan my code a couple of times but i still cant get it..

      Comment

      • Luuk
        Recognized Expert Top Contributor
        • Mar 2012
        • 1043

        #4
        the end of line 27:
        Code:
         '".$_POST['txtcountry']);
        change it to :
        Code:
         '".$_POST['txtcountry'].")";

        Comment

        Working...