Jump to content

[SOLVED] parse error


cs1h

Recommended Posts

Hi,

I'm getting the following error from my php script,

 

Parse error: syntax error, unexpected ')' in D:\Inetpub\vhost\myroho.com\httpdocs\asearching.php on line 10

 

and the code is

 

<?

//connect to your database ** EDIT REQUIRED HERE **
mysql_connect("localhost","adder","clifford"); //(host, username, password)

//specify database ** EDIT REQUIRED HERE **
mysql_select_db("real") or die("Unable to select database"); //select which database we're using

$keywords = preg_split("/[\s,]+/", trim($_POST['keyword']));
$sql = "SELECT * FROM items WHERE country='" . mysql_real_escape_string($_POST['menuFilesDMA']=) . "' AND type='" . mysql_real_escape_string($_POST['Type']=) . "' AND Abstract LIKE '%" . implode('%', $keyword) . "%'";
}
$result = mysql_query($query);
$num_rows = mysql_num_rows($result);
if($num_rows == 0) {
echo "No results<BR>n";
} else {
while($row = mysql_fetch_array($result)) {
echo "{$row['somefield']}<BR>n";
}
}
?> 

 

I'm new to php and I can't find whats wrong with it.

 

Any help would be much appriciated (even if someone can tell me if they think this script will work),

 

Thanks

Colin

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

why do you have the ='s and } ?

 

see comments

$sql = "SELECT * FROM items WHERE country='" . mysql_real_escape_string($_POST['menuFilesDMA']=) . "' AND type='" . mysql_real_escape_string($_POST['Type']=) . "' AND Abstract LIKE '%" . implode('%', $keyword) . "%'"; // why the ='s ?
} //<-- whats this for ?

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

from

$sql = "SELECT * FROM items WHERE country='" . mysql_real_escape_string($_POST['menuFilesDMA']=) . "' AND type='" . mysql_real_escape_string($_POST['Type']=) . "' AND Abstract LIKE '%" . implode('%', $keyword) . "%'"; // why the ='s ?

to

$sql = "SELECT * FROM items WHERE country='" . mysql_real_escape_string($_POST['menuFilesDMA']) . "' AND type='" . mysql_real_escape_string($_POST['Type']) . "' AND Abstract LIKE '%" . implode('%', $keyword) . "%'"; 

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

Hi,

 

That new code worked but I am now getting a new error,

 

Warning: implode() [function.implode]: Bad arguments. in D:\Inetpub\vhost\myroho.com\httpdocs\asearching.php on line 10

 

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in D:\Inetpub\vhost\myroho.com\httpdocs\asearching.php on line 13

No results

n

 

Any help is much appriciated,

 

Thanks, Colin

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

I made the change in the second surgestion and it removed the second error.

 

I think $keyword is a string because it comes from a text box (unless I misunderstand what a string is), I am not sure what you mean by do a var_dump($keyword);

 

Thanks

Colin

 

The only message I get now is

Warning: implode() [function.implode]: Bad arguments. in D:\Inetpub\vhost\myroho.com\httpdocs\asearching.php on line 10

 

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

OK if its a string i *think* your trying to do this

 

$sql = "SELECT * FROM items WHERE country='" . mysql_real_escape_string($_POST['menuFilesDMA']) . "' AND type='" . mysql_real_escape_string($_POST['Type']) . "' AND Abstract LIKE '%$keyword%'"; 

 

 

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

Archived

This topic is now archived and is closed to further replies.

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