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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Parse error of a checkbox searchengine???

Status
Not open for further replies.

Kinob

Programmer
May 8, 2002
4
NL
Hi everybody!,

I wrote a php checkbox search engine script, but everytime I run it, I get a parse error. Does anybody know why? See below for all the files and the sql tables

**************** form.html ****************

<html>
<body>
<br>
<form name=&quot;skills&quot; method=&quot;POST&quot; action=&quot;search.php&quot;>
Check off your web development skills:
<table width=&quot;400&quot; border=&quot;0&quot;>
<tr>
<td><input type=&quot;checkbox&quot; name=&quot;skills[]&quot; value=&quot;1&quot;>php</td>
<td><input type=&quot;checkbox&quot; name=&quot;skills[]&quot; value=&quot;2&quot;>asp</td>
<td><input type=&quot;checkbox&quot; name=&quot;skills[]&quot; value=&quot;3&quot;>cgi</td></tr>
<tr><td><input type=&quot;checkbox&quot; name=&quot;skills[]&quot; value=&quot;4&quot;>JavaScript</td>
<td><input type=&quot;checkbox&quot; name=&quot;skills[]&quot; value=&quot;5&quot;>JSP</td>
<td><input type=&quot;checkbox&quot; name=&quot;skills[]&quot; value=&quot;6&quot;>HTML</tr>
<tr></table>
<br>
<input type=&quot;submit&quot; value=&quot;Submit&quot;>
</form>
</body>
</html>

**************** search.php ****************

<?php

if(!empty($_POST['skills'])){



$dbcnx = @mysql_connect(
&quot;localhost&quot;, &quot;lucasman&quot;, &quot;cgimaster&quot;);
if (!$dbcnx) {
echo( &quot;<P>Unable to connect to the &quot; .
&quot;database server at this time.</P>&quot; );
exit();
}


if (! @mysql_select_db(&quot;checksearch&quot;) ) {
echo( &quot;<P>Unable to locate the database at this time.</P>&quot; );
exit();
}
$num_skills=sizeof($_POST['skills']);
$query='SELECT DISTINCT members.membername FROM members INNER JOIN lookup_skills ON members.id=lookup_skills.uid'
.'INNER JOIN const_skills ON lookup_skills.skill_id=const_skills.id WHERE const_skills.id IN(';
$query.=join(',',$_POST['skills']);
$query.=') ORDER BY members.membername';
echo $query . '<br>';



$result=@mysql_query($query,$con)ordie('Error in query: '.mysql_error());

$numrows=@mysql_num_rows($result);

if($numrows!=0){



while($row=mysql_fetch_assoc($result)){

echo$row['membername'].'<br>';

}



}else{



echo'Sorry, but no matches were found...<br>';



}



}else{



echo'You DO want to see some skills, don\'tyou?<br>';

}
}

?>

**************** SQL: const_skills ****************

id: value:
1 PHP
2 ASP
3 Perl
4 JavaScript
5 JSP
6 Coldfusion

**************** SQL: lookup_skills ****************

id: uid: skill_id:
1 1 1
2 1 3
3 1 4
4 1 6
5 2 1
6 2 4
7 2 6
8 3 1
9 3 3
10 3 4
11 3 5
12 3 6
13 4 2

**************** SQL: members ****************

id: membername:
1 John
2 Dan
3 Bob
4 Robin

***************************************************

Hope somebody can help me....

Kinob

 
<?php

if(!empty($_POST['skills'])){



$dbcnx = @mysql_connect(
&quot;localhost&quot;, &quot;lucasman&quot;, &quot;cgimaster&quot;);
if (!$dbcnx) {
echo( &quot;<P>Unable to connect to the &quot; .
&quot;database server at this time.</P>&quot; );
exit();
}


if (! @mysql_select_db(&quot;checksearch&quot;) ) {
echo( &quot;<P>Unable to locate the database at this time.</P>&quot; );
exit();
}
$num_skills=sizeof($_POST['skills']);
$query='SELECT DISTINCT members.membername FROM members INNER JOIN lookup_skills ON members.id=lookup_skills.uid'
.'INNER JOIN const_skills ON lookup_skills.skill_id=const_skills.id WHERE const_skills.id IN(';
$query.=join(',',$_POST['skills']);
$query.=') ORDER BY members.membername';
echo $query . '<br>';



$result=@mysql_query($query,$con)or<space here> die('Error in query: '.mysql_error());

$numrows=@mysql_num_rows($result);

if($numrows!=0){



while($row=mysql_fetch_assoc($result)){

echo$row['membername'].'<br>';

}



}else{



echo'Sorry, but no matches were found...<br>';



}



}else{



echo'You DO want to see some skills, don\'tyou?<br>';

}
//}// commented out, seems to be surplus?

?>

thats some of it fixed, cant tell withou modding all the db queries tho or setting up the form . ***************************************
Party on, dudes!
[cannon]
 
yeah I know, now the script does work

but I still I have the prob, that I get the query printed and not the results, could someone help me....
 
do you have a link I could view the page ? ***************************************
Party on, dudes!
[cannon]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top