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