Jump to content

Recommended Posts

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";

 

?>

Link to comment
https://forums.phpfreaks.com/topic/76481-parse-error/
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/76481-parse-error/#findComment-387367
Share on other sites

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 ;)

Link to comment
https://forums.phpfreaks.com/topic/76481-parse-error/#findComment-387369
Share on other sites

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!

Link to comment
https://forums.phpfreaks.com/topic/76481-parse-error/#findComment-387381
Share on other sites

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";

?>

Link to comment
https://forums.phpfreaks.com/topic/76481-parse-error/#findComment-387432
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/76481-parse-error/#findComment-387455
Share on other sites

$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']}')";

Link to comment
https://forums.phpfreaks.com/topic/76481-parse-error/#findComment-387457
Share on other sites

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?

Link to comment
https://forums.phpfreaks.com/topic/76481-parse-error/#findComment-387464
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/76481-parse-error/#findComment-387468
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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