Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cannot Find Cause of Error 1

Status
Not open for further replies.

ESchmidgall

Technical User
Aug 8, 2005
3
CH
I inherited some php script from a previous user and have been told to update it. I'm not very good at php so this is proving to be a challenge. I am getting this error:

Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING in /usr/local/apache2/htdocs/Emma/query186.php on line 206

which I understand is often caused by missing ; at the end of a line. However, I've checked all around line 206 and to my undiscerning eyes, everything looks okay.

This script is supposed to query a mySQL database, print out the results in the table, and allow modification of the database through the webpage. Here's the code, could you please help me find the cause of this error?

<---------------begin code------------->


$db->query($q);
while(list($RODid, $CCU, $RODtype, $Location, $OtherLoc, $Layer, $Position, $flag, $comments) = $db->data())
{
echo("<tr><td>".$RODid."</td><td>".$CCU."</td><td>".$RODtype."</td><td>".$Location."</td><td>".$OtherLoc."</td><td>".$Layer."</td><td>".$Position."</td><td>".$flag."</td><td>".$comments."</td><td><FORM METHOD=\"post\" ACTION=\"query186.php\"><input type=\"hidden\" Name=\"method\" Value=\"remove\"><input type=\"hidden\" Name=\"RODid_\" value=".$RODid."><input type=\"hidden\" Name=\"CCU_\" value=".$CCU."><input type=\"hidden\" Name=\"RODtype_\" Value=".$RODtype_."><input type=\"hidden\" Name=\"Location_\" Value=".$Location_."><input type=\"hidden\" Name=\"OtherLoc_\" Value=".$OtherLoc_."><input type=\"hidden\" Name=\"Layer_\" Value=".$Layer_."><input type=\"hidden\" Name=\"Position_\" value=".$Position_."><input type=\"hidden\" Name=<input type=\"hidden\" Name=\"flag_\" Value=".$flag_."> <input type=\"submit\" Value=\"Remove\" size=\"10\"><br></FORM></td></tr>");
}
echo("</tbody></table>");
break;

case remove:
if($Location_>0 && RODid_>0)
{
$db->query("DELETE FROM rods186 WHERE RODid=".$RODid);
****LINE206*** echo("OK, removed rod number ".$RODid "from previous location" .$Location); ****END LINE 206***********
}
else{
echo("<span style=\"color:red\"><B>Check your values!</B></span>");
}
break;

case insert:
if($Location_>0 && $Layer_>0 && $Position_>0 && $CCU_>0 && $RODid_>0)
{
$q = "INSERT INTO rods186 VALUES (".$RODid_.",".$CCU_.",'".$RODtype_."','".$Location_."', '".$OtherLoc_."', ".$Layer_.", ".$Position_.", '".$flag_."','".$comments_."');";
$results = $db->query($q);
if($results == 1)
echo("Ok. Rod inserted with: <TT>".$q."</TT><br>");
else
echo("<span style=\"color:red\"><B>Error! Rod not inserted!</B></span> (<TT>".$q."</TT>)<br>");


}
else{
echo("<span style=\"color:red\">Check your values!</span>");
}
break;

default:
break;
 
Could it be here:

Code:
 echo("OK, removed rod number ".$RODid "from previous location" .$Location);

to

Code:
 echo("OK, removed rod number ".$RODid." from previous location " .$Location);

Thanks,
 
Thanks! That worked beautifully. What's the deal with the periods? Whe does one need them and when does one not need them?

 
Well I hope you're happy now, I just spent the last 10 minutes trying to find the correct spelling...lol

Code:
con·cat·e·na·tion:
computing the linking of characters, strings, or files in a specified order to form a single entity equal to the sum of the lengths of the original entities

The error was produced because you tried to join a variable to the following string without the "." concatenation operator.

Ref:

Thanks,
 
Periods are used to concatenate Strings.

Code:
$something="World";

$text= "Hello" . $something;
this would yield "HelloWorld" as the value of the variable $text;

It just puts strings together. For example when you need to output html code but need a variable in between.
Example:
Code:
echo "<input type=text name='" . $textboxname . "' value='" . valueoftextbox(someparameter) . "'>";

This outputs:

<input type=text name='somename' value='somevalue'>

it concatenates the value of the variable $textboxname with the rest of the html code, and then adds the value returned by the function valueoftextbox(someparamters) to the string, and then closes the html tag.

tha line efectively created a textbox with a certain name and a value that was obtained by a process.

hope this clarifies the "."



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top