lillizzierae Posted November 8, 2007 Share Posted November 8, 2007 i'm getting an error on my third line. the error is: Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/lizzieni/public_html/data.php on line 3 i'm not too sure what exactly is wrong... here's my code <?php DEFINE ('DB_USER' 'lizzieni_lizzie'); DEFINE ('DB_PASSWORD' 'mac45545'); DEFINE ('DB_HOST' 'localhost'); DEFINE ('DB_NAME' 'lizzieni_website'); $dbc = @mysql_connect (DB_HOST, DB_USER, DB_PASSWORD) OR die ('No Connection:') . mysql_error() ); @mysql_select_db (lizzieni_website) OR die ('No selected database: ' . mysql_error() ); $fname = $_POST['fname']; $lname = $_POST['lname']; $phone = $_POST['phone']; $dob = $_POST['dob']; $email = $_POST['email']; echo "Information sent ". $fname . " ". $lname . " ". $phone . " ". $dob . " ". email ." "; echo "You'll receive newsletters monthly"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/76481-parse-error/ Share on other sites More sharing options...
~n[EO]n~ Posted November 8, 2007 Share Posted November 8, 2007 define should be kept like this <?php define ('DB_USER' , "lizzieni_lizzie"); define ('DB_PASSWORD' , "mac45545"); define ('DB_HOST' , "localhost"); define ('DB_NAME' , "lizzieni_website"); ?> Quote Link to comment https://forums.phpfreaks.com/topic/76481-parse-error/#findComment-387358 Share on other sites More sharing options...
lillizzierae Posted November 8, 2007 Author Share Posted November 8, 2007 i'm still getting that error. this is bugging me. i was told dreamweaver could be the problem and to use notepad for this page. have you ever heard of that? i haven't tried writing the code in i only copy and pasted it into it and still came up with the error. maybe i should write it. Quote Link to comment https://forums.phpfreaks.com/topic/76481-parse-error/#findComment-387367 Share on other sites More sharing options...
~n[EO]n~ Posted November 8, 2007 Share Posted November 8, 2007 Where are you getting the error ? Try this <?php define ('DB_USER' , "lizzieni_lizzie"); define ('DB_PASSWORD' , "mac45545"); define ('DB_HOST' , "localhost"); define ('DB_NAME' , "lizzieni_website"); $dbc = mysql_connect (DB_HOST, DB_USER, DB_PASSWORD) OR die ('No Connection:') . mysql_error() ); mysql_select_db (DB_NAME) OR die ('No selected database: ' . mysql_error() ); $fname = $_POST['fname']; $lname = $_POST['lname']; $phone = $_POST['phone']; $dob = $_POST['dob']; $email = $_POST['email']; echo "Information sent ". $fname . " ". $lname . " ". $phone . " ". $dob . " ". email ." "; echo "You'll receive newsletters monthly"; ?> Yes, I didn't see that Quote Link to comment https://forums.phpfreaks.com/topic/76481-parse-error/#findComment-387369 Share on other sites More sharing options...
rajivgonsalves Posted November 8, 2007 Share Posted November 8, 2007 also this @mysql_select_db (lizzieni_website) OR die ('No selected database: ' . mysql_error() ); should be mysql_select_db (DB_NAME) OR die ('No selected database: ' . mysql_error() ); Quote Link to comment https://forums.phpfreaks.com/topic/76481-parse-error/#findComment-387370 Share on other sites More sharing options...
lillizzierae Posted November 8, 2007 Author Share Posted November 8, 2007 line 3. so the error is the first "define" i'm gonna try everything and see what happens. i'm crossing my fingers over here!! Quote Link to comment https://forums.phpfreaks.com/topic/76481-parse-error/#findComment-387379 Share on other sites More sharing options...
lillizzierae Posted November 8, 2007 Author Share Posted November 8, 2007 i'm just pulling up more and more errors. the code you gave me worked. BUT (there's always a "but") now i'm getting a new error. Parse error: syntax error, unexpected ')' in /home/lizzieni/public_html/data.php on line 8 it's line 8. so that would be the "mysql_connect" line. i always have trouble with this.. anything else i'm fine with. sorry! Quote Link to comment https://forums.phpfreaks.com/topic/76481-parse-error/#findComment-387381 Share on other sites More sharing options...
~n[EO]n~ Posted November 8, 2007 Share Posted November 8, 2007 OR should be small (or) try this $dbc = mysql_connect (DB_HOST, DB_USER, DB_PASSWORD) or die ("No Connection:<br />" . mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/76481-parse-error/#findComment-387387 Share on other sites More sharing options...
lillizzierae Posted November 8, 2007 Author Share Posted November 8, 2007 you guys are wonderful! thank you. what's the point of going to class when you all are teaching me?? jk one more question and i promise i won't be bothering you guys for.. a little while i completely forgot to select a table i wanted the data to go in. i thought this code would work but apparently not. in my table nothing is capitalized. first name is fname. <?php define ('DB_USER' , "lizzieni_lizzie"); define ('DB_PASSWORD' , "mac45545"); define ('DB_HOST' , "localhost"); define ('DB_NAME' , "lizzieni_website"); define ('TABLE_NAME' , "newsletter"); $dbc = mysql_connect (DB_HOST, DB_USER, DB_PASSWORD) or die ("No Connection:<br />" . mysql_error()); mysql_select_db (DB_NAME) OR die ('No selected database: ' . mysql_error() ); $sql="INSERT INTO newsletter (fname, lname, phone, dob, email) VALUES ('$_POST[fname]'; '$_POST[lname]'; '$_POST[phone]'; '$_POST[dob]'; '$_POST[email]')"; echo "Information sent ". $fname . " ". $lname . " ". $phone . " ". $dob . " ". email ." "; echo "You'll receive newsletters monthly"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/76481-parse-error/#findComment-387432 Share on other sites More sharing options...
~n[EO]n~ Posted November 8, 2007 Share Posted November 8, 2007 replace this part, hope it will work $sql=mysql_query("INSERT INTO newsletter (fname, lname, phone, dob, email) VALUES ('$_POST[fname]'; '$_POST[lname]'; '$_POST[phone]'; '$_POST[dob]'; '$_POST[email]')"; $result=mysql_query($sql);// you left this .... Quote Link to comment https://forums.phpfreaks.com/topic/76481-parse-error/#findComment-387440 Share on other sites More sharing options...
lillizzierae Posted November 8, 2007 Author Share Posted November 8, 2007 that makes better sense now. but we produced an error Parse error: syntax error, unexpected ';' in /home/lizzieni/public_html/data.php on line 21 which the problem is in this line somewhere: '$_POST[email]')"; if i move the semi-colon to the left, i receive an error on the next line. Quote Link to comment https://forums.phpfreaks.com/topic/76481-parse-error/#findComment-387455 Share on other sites More sharing options...
MadTechie Posted November 8, 2007 Share Posted November 8, 2007 $sql="INSERT INTO newsletter (fname, lname, phone, dob, email) VALUES ('$_POST[fname]'; '$_POST[lname]'; '$_POST[phone]'; '$_POST[dob]'; '$_POST[email]')"; should be $sql="INSERT INTO newsletter (fname, lname, phone, dob, email) VALUES ('{$_POST['fname']}', '{$_POST['lname']}', '{$_POST['phone']}', '{$_POST['dob']}', '{$_POST['email']}')"; Quote Link to comment https://forums.phpfreaks.com/topic/76481-parse-error/#findComment-387457 Share on other sites More sharing options...
~n[EO]n~ Posted November 8, 2007 Share Posted November 8, 2007 I think there was a mistake in the above code I posted , Sorry try this one now $sql="INSERT INTO newsletter (fname, lname, phone, dob, email) VALUES ('$_POST[fname]', '$_POST[lname]', '$_POST[phone]','$_POST[dob]','$_POST[email]')"; $result=mysql_query($query); Quote Link to comment https://forums.phpfreaks.com/topic/76481-parse-error/#findComment-387458 Share on other sites More sharing options...
lillizzierae Posted November 8, 2007 Author Share Posted November 8, 2007 i'm starting to wonder if something else could be wrong. neither of those worked. i doubt this is a problem but i might as well ask. you don't think there could be a problem with both the field names in the table and the input names in the form being exactly the same? Quote Link to comment https://forums.phpfreaks.com/topic/76481-parse-error/#findComment-387464 Share on other sites More sharing options...
MadTechie Posted November 8, 2007 Share Posted November 8, 2007 Try this <?php define ('DB_USER' , "lizzieni_lizzie"); define ('DB_PASSWORD' , "mac45545"); define ('DB_HOST' , "localhost"); define ('DB_NAME' , "lizzieni_website"); define ('TABLE_NAME' , "newsletter"); $dbc = mysql_connect (DB_HOST, DB_USER, DB_PASSWORD) or die ("No Connection:<br />" . mysql_error()); mysql_select_db (DB_NAME) OR die ('No selected database: ' . mysql_error() ); $sql="INSERT INTO newsletter (fname, lname, phone, dob, email) VALUES ('{$_POST['fname']}', '{$_POST['lname']}', '{$_POST['phone']}', '{$_POST['dob']}', '{$_POST['email']}')"; $result=mysql_query($sql) or die(mysql_error()); echo "Information sent {$result['fname']} {$result['lname']} {$result['phone']} {$result['dob']} {result['email']} "; echo "You'll receive newsletters monthly"; ?> EDIT: updated Quote Link to comment https://forums.phpfreaks.com/topic/76481-parse-error/#findComment-387468 Share on other sites More sharing options...
~n[EO]n~ Posted November 8, 2007 Share Posted November 8, 2007 Sorry, posted late MadTechie's code will work, I thought this i am not seeing single quote inside $_POST['fname'] in the query, that may (or may not) be the problem... Quote Link to comment https://forums.phpfreaks.com/topic/76481-parse-error/#findComment-387469 Share on other sites More sharing options...
lillizzierae Posted November 8, 2007 Author Share Posted November 8, 2007 it still didn't work. KIDDING! it definitely worked! thank you so much. Liz Quote Link to comment https://forums.phpfreaks.com/topic/76481-parse-error/#findComment-387472 Share on other sites More sharing options...
MadTechie Posted November 8, 2007 Share Posted November 8, 2007 Cool can you click solved please Bottom left Quote Link to comment https://forums.phpfreaks.com/topic/76481-parse-error/#findComment-387486 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.