Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9196869
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T21:56:42+00:00 2026-06-17T21:56:42+00:00

I wonder whether someone can help me please. I’ve found this tutorial to create

  • 0

I wonder whether someone can help me please.

I’ve found this tutorial to create a drop down menu using mySQL table data, which, in turn returns a list of results on the page.

Following this tutorial I’ve put together the tables in my database and the required scripts which are shown below:

Search Form

<html>
<head>

<script type="text/javascript">
function ajaxFunction()
{

//document.writeln(val)
var httpxml;
try
{
// Firefox, Opera 8.0+, Safari
httpxml=new XMLHttpRequest();
}
catch (e)
{
// Internet Explorer
try
{
httpxml=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
try
{
httpxml=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e)
{
alert("Your browser does not support AJAX!");
return false;
}
}
}

function stateChanged(){
if(httpxml.readyState==4){

var myObject = eval('(' + httpxml.responseText + ')');


//var myObject = httpxml.responseText;
//document.getElementById("display").innerHTML=myObject;





var msg=myObject.value[0].message;
if(msg.length > 0){document.getElementById("msg").innerHTML=msg;}
else{document.getElementById("msg").style.display='none';}

var str="<table width='50%' bgcolor='#ffffff' align=center><tr><th>ID</th><th>Name</th></tr>";
var color="#f1f1f1";
for(i=0;i<myObject.data.length;i++)
{ 
if((i%2)==0){color="#ffffff";}
else{color="#f1f1f1";}
str = str + "<tr bgcolor="+color+"><td>" + myObject.data[i].subcat_id + " </td><td>"+ myObject.data[i].subcat_name + "</a></td></tr>"

}



str = str + "</table>" ;


document.getElementById("display").innerHTML=str;
}
}

var url="subcat2.php";
var cat_id=document.myForm.cat_id.value;
url=url+"?cat_id="+cat_id;

url=url+"&kid="+Math.random();
//alert(url)
httpxml.onreadystatechange=stateChanged;
httpxml.open("GET",url,true);
httpxml.send(null);
// document.getElementById("display").innerHTML="Please Wait....";
document.getElementById("msg").style.background='#f1f1f1';
document.getElementById("msg").innerHTML="Please Wait ... ";
document.getElementById("msg").style.display='inline';
}

</script>

<?php
require "z_db.php";
echo "</head><body onload="ajaxFunction()";>";
echo "<center><table border='0' width='100%' cellspacing='0' cellpadding='0' > <tr bgcolor='#ffffcc'><form name=myForm method='post' onSubmit="ajaxFunction(this.form); return false">


<td align='center' colspan=2><font face='verdana, arial, helvetica' size='2' ><b> Select a Category</b> </font></td></tr>";
echo "<tr>";
echo "<td align='center'>";
$query="SELECT * FROM plus2_cat order by cat_name";
$result=mysql_query($query);
echo mysql_error();
echo "<select name=cat_id onChange="ajaxFunction()"><option value=0>Show All</option>";
while($nt=mysql_fetch_array($result)){
echo "<option value=$nt[cat_id]>$nt[cat_name]</option>";
}

echo "</select>";
echo "</font></td>";
echo "</tr></form>";
echo "</table>";


?>
<div id=msg style="position:absolute; z-index:1; left: 1100px; top: 0px;" >This is message area</div>

<div id="display"><b>Records will be displayed here</b></div>

</body>
</html>

subcat2.php

<?php
////// Your Database Details here /////////
require ("z_db.php"); 
//Your database details here
//////////////////////////// Main Code sarts ///////////////
$cat_id=$_GET['cat_id'];
//$cat_id=11;

if(!is_numeric($cat_id)){
$message.="Data Error |";
exit;
}

//$message.=" :Status = $status";
if($cat_id>0){
$q=mysql_query("select subcat_id, subcat_name from plus2_subcat where cat_id=$cat_id order by subcat_name");
}else{
$q=mysql_query("select subcat_id, subcat_name from plus2_subcat order by subcat_name ");
$cat_id=0;
}
//$message .=" Cat_id=$cat_id ";
$message .= mysql_error();

$str= "{ "data" : [ ";

while($nt=mysql_fetch_array($q)){
$str=$str."{"subcat_id" : "$nt[subcat_id]", "subcat_name" : "$nt[subcat_name]"},";
//$str=$str."{"myclass" : "$nt[class]"},";

}
$str=substr($str,0,(strLen($str)-1));
$message=$message. " Records displayed";
$str=$str."],"value" : [{"cat_id" : $cat_id,"message" : "$message"}]}";
//echo json_encode($str);

echo $str;
?>

z_db.php

<?php
mysql_connect("host", "user", "password")or
die(mysql_error());
mysql_select_db("database");
?>

The problem I ahve is that when I try and run this, I receive the following error:
Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /homepages/2/d333603417/htdocs/development/catsearch.php on line 91 which is this line in the search form: echo "</head><body onload="ajaxFunction()";>";.

I must admit I’ve guessed as to the structure of the’z_db.php’ file should look like because this is not shown so perhaps this is the problem.

I just wondered wether someone could perhaps take a look at this please and let me know where I’ve gone wrong.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T21:56:43+00:00Added an answer on June 17, 2026 at 9:56 pm

    Try:

    echo "</head><body onload='ajaxFunction()';>";
    

    You cannot nest single/double quotes.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wonder whether someone can help me please. I'm using the following script to
I wonder whether someone can help me please. I've put together this page, which
I wonder whether someone can help me please. I'm using the code below to
I wonder whether someone can help me please. I've put together this page which
I wonder whether someone can help me please. I'm using the following script to
I wonder whether someone may be able to help me please. I'm using this
I wonder whether someone may be able to help me please. I'm using this
I wonder whether someone can help me please. I've created this form which allows
I wonder whether someone could help me please, From a tutorial I found online
I wonder whether someone may be able to help me please. I'm using the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.