PHP parse error

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
helios76
Forum Newbie
Posts: 5
Joined: Sun Jul 20, 2003 7:45 am
Contact:

PHP parse error

Post by helios76 »

I got this error from a file I am trying to get to work:

Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING in /Users/helen/Sites/trreport.php on line 4

Here is my code. Could anyone please tell me what is wrong? I want to use this with an html form (obviously). Should this be embedded into the html or as a separate file?
<?
$db =mysql_connect ("localhost" ,"root" ,"blah" );

mysql_select_db (csttrrep);

$result =mysql_query ("INSERT INTO repinfo (empID, firstName, lastName, location, district, courseName, instructor, date, duration)
                VALUES ('$empID', '$firstName', '$lastName', '$location', '$district', '$courseName', '$instructor', '$date', '$duration')" );
if(! $result )
{
   echo "<b>Something not added:</b> " ,mysql_error ();
   exit;
}
if( $result )
    {
     mysql_close ($db );
    print "Something added sucessfully!" ;
    }
?>


Thanks in advance!
Celtis
Forum Newbie
Posts: 3
Joined: Sun Jul 20, 2003 7:55 am
Contact:

Post by Celtis »

The line that says:

mysql_select_db (csttrrep);

Needs to either read:

mysql_select_db ('csttrrep');
or
mysql_select_db ($csttrrep);

Depending on whether the csttrrep is the actual name of the database or the name of the variable containing the name of the database
helios76
Forum Newbie
Posts: 5
Joined: Sun Jul 20, 2003 7:45 am
Contact:

Post by helios76 »

Thanks!
helios76
Forum Newbie
Posts: 5
Joined: Sun Jul 20, 2003 7:45 am
Contact:

Post by helios76 »

I am now getting the error:

"The attempt to load 'Accessing URL: file://localhost/Library/Webserver/Documents/trreport.php' failed

Any ideas?
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Does that error relate only to the code posted?

Mac
Post Reply