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="skills" method="POST" action="search.php">
Check off your web development skills:
<table width="400" border="0">
<tr>
<td><input type="checkbox" name="skills[]" value="1">php</td>
<td><input type="checkbox" name="skills[]" value="2">asp</td>
<td><input type="checkbox" name="skills[]" value="3">cgi</td></tr>
<tr><td><input type="checkbox" name="skills[]" value="4">JavaScript</td>
<td><input type="checkbox" name="skills[]" value="5">JSP</td>
<td><input type="checkbox" name="skills[]" value="6">HTML</tr>
<tr></table>
<br>
<input type="submit" value="Submit">
</form>
</body>
</html>
**************** search.php ****************
<?php
if(!empty($_POST['skills'])){
$dbcnx = @mysql_connect(
"localhost", "lucasman", "cgimaster"
if (!$dbcnx) {
echo( "<P>Unable to connect to the " .
"database server at this time.</P>" );
exit();
}
if (! @mysql_select_db("checksearch" ) {
echo( "<P>Unable to locate the database at this time.</P>" );
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
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="skills" method="POST" action="search.php">
Check off your web development skills:
<table width="400" border="0">
<tr>
<td><input type="checkbox" name="skills[]" value="1">php</td>
<td><input type="checkbox" name="skills[]" value="2">asp</td>
<td><input type="checkbox" name="skills[]" value="3">cgi</td></tr>
<tr><td><input type="checkbox" name="skills[]" value="4">JavaScript</td>
<td><input type="checkbox" name="skills[]" value="5">JSP</td>
<td><input type="checkbox" name="skills[]" value="6">HTML</tr>
<tr></table>
<br>
<input type="submit" value="Submit">
</form>
</body>
</html>
**************** search.php ****************
<?php
if(!empty($_POST['skills'])){
$dbcnx = @mysql_connect(
"localhost", "lucasman", "cgimaster"
if (!$dbcnx) {
echo( "<P>Unable to connect to the " .
"database server at this time.</P>" );
exit();
}
if (! @mysql_select_db("checksearch" ) {
echo( "<P>Unable to locate the database at this time.</P>" );
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