I am getting a parser error whenever I try to execute a program.
Parse error: parse error, unexpected '.' in /var/www/html/spywgc/adm/ctshell/getproduct/getproduct.php on line 9
This is the code
$select_url= " select product_id from sp_url where url like '%.$url.%'";
$url is a string and I want to retrieve it from database to assign it to $select_url.
I'm not sure if you meant to have the dots in there, but you can do any of the following:
$select_url= "select product_id from sp_url where url like '%.{$url}.%'";
$select_url= "select product_id from sp_url where url like '%." . $url . ".%'";
Based on what you have presented above I am assuming you want to do something like this
/* Assuming you have a database connection already */
$result = mysql_query("SELECT product_id FROM sp_url WHERE url LIKE '%".$url."%'";
$row = mysql_fetch_assoc($result);
$select_url = $row['product_id'];
edit: you may want to escape $url as well mysql_real_escape_string($url)
Dots arent even needed, you could end with something like that:
$select_url= "SELECT product_id FROM sp_url WHERE url LIKE '%$url%'";
And then make your mysql_query with this string.
The line you posted is syntactically correct. The real error is that somewhere BEFORE that line, you have a string with an unterminated '
.
$somevar = 'blah blah <--missing ' here
... blah blah blah ...
$select_url = "...... '% <---string closes here
So you're ending up with
$somevar = 'big long string select product_id .... ' % .
% is the modulo operator, which would normally be fine, but then it's followed by a . which isn't valid.
"string modulo concatenate"
and as others have said, your string is internally incorrect. You're using a double-quoted string, so there's no need for the attempt at concatenation within the string.