I need some help here

I need some help here

am 24.11.2006 18:44:32 von sahm

Hi evry one
I need some help with my code
What's wrong in this code



header('Content-Type: text/xml');
$dom = new DOMDocument();
$response = $dom->createElement('response');
$dom->appendChild($response);


$sub_categorys = $dom->createElement('sub_Categorys');
$response->appendChild($sub_categorys);


$conn = mysql_connect("localhost", "", "");
if (!$conn)
{
echo "Unable to connect to DB: " . mysql_error();
exit;


}


else
{
$select = mysql_select_db("yayemen", $conn);
if (!$select)
{
echo "Unable to select mydbname: " . mysql_error();
exit;
}
else
{
$sql = "SELECT * FROM sub_category";
$result = mysql_query($sql, $conn);
}


}


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

$cat_NO = $dom->createElement('cat_NO');
$st1 = $row["sub_cat_ID"];
$cat_NO_Text = $dom->createTextNode($st1);
$cat_NO->appendChild($cat_NO_Text);


$cat_Name = $dom->createElement('cat_Name');
$st2 = $row["sub_cat_Name"];
$cat_Name_Text = $dom->createTextNode($st2);
$cat_Name->appendChild($cat_Name_Text);


$sub_category = $dom->createElement('sub_category');
$sub_category->appendChild($cat_NO);
$sub_category->appendChild($cat_Name);


$sub_categorys->appendChild($sub_category);


$xmlString .= $dom->saveXML();



}


echo $xmlString;

?>


please help please

Re: I need some help here

am 24.11.2006 19:54:46 von Paul Lautman

sahm wrote:
> Hi evry one
> I need some help with my code
> What's wrong in this code
>
> >
>
> header('Content-Type: text/xml');
> $dom = new DOMDocument();
> $response = $dom->createElement('response');
> $dom->appendChild($response);
>
>
> $sub_categorys = $dom->createElement('sub_Categorys');
> $response->appendChild($sub_categorys);
>
>
> $conn = mysql_connect("localhost", "", "");
> if (!$conn)
> {
> echo "Unable to connect to DB: " . mysql_error();
> exit;
>
>
> }
>
>
> else
> {
> $select = mysql_select_db("yayemen", $conn);
> if (!$select)
> {
> echo "Unable to select mydbname: " . mysql_error();
> exit;
> }
> else
> {
> $sql = "SELECT * FROM sub_category";
> $result = mysql_query($sql, $conn);
> }
>
>
> }
>
>
> while ($row = mysql_fetch_assoc($result))
> {
>
> $cat_NO = $dom->createElement('cat_NO');
> $st1 = $row["sub_cat_ID"];
> $cat_NO_Text = $dom->createTextNode($st1);
> $cat_NO->appendChild($cat_NO_Text);
>
>
> $cat_Name = $dom->createElement('cat_Name');
> $st2 = $row["sub_cat_Name"];
> $cat_Name_Text = $dom->createTextNode($st2);
> $cat_Name->appendChild($cat_Name_Text);
>
>
> $sub_category = $dom->createElement('sub_category');
> $sub_category->appendChild($cat_NO);
> $sub_category->appendChild($cat_Name);
>
>
> $sub_categorys->appendChild($sub_category);
>
>
> $xmlString .= $dom->saveXML();
>
>
>
> }
>
>
> echo $xmlString;
>
>>
>
>
> please help please

Can you tell us what error you're seeing, that'll save us having to first
look for syntax errors, then look for logic errors, then try to guess at
whatthe data may do to it, then .....

Re: I need some help here

am 24.11.2006 20:01:21 von sahm

It's take long long long time to load
It's nver load

and no erro apper

Re: I need some help here

am 24.11.2006 22:46:36 von bma

sahm wrote:

> It's take long long long time to load
> It's nver load
> and no erro apper

It's difficult to be sure from what you say, but I reckon you have a MySQL
problem, not a PHP problem. Slow loading suggests that the query is taking
a long time for the database to deal with. Is your database large? Do you
have proper indexing implemented so that MySQL can search as quickly as
possible?

I didn't look through your PHP, but if you do not get a quick error then it
is 99% certain to be MySQL not PHP which is at fault.

BMA