I need some help here

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

<?php


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
sahm [ Fr, 24 November 2006 18:44 ] [ ID #1546526 ]

Re: I need some help here

sahm wrote:
> Hi evry one
> I need some help with my code
> What's wrong in this code
>
> <?php
>
>
> 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 .....
Paul Lautman [ Fr, 24 November 2006 19:54 ] [ ID #1546527 ]

Re: I need some help here

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

and no erro apper
sahm [ Fr, 24 November 2006 20:01 ] [ ID #1546528 ]

Re: I need some help here

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
bma [ Fr, 24 November 2006 22:46 ] [ ID #1546529 ]
PHP » alt.php.sql » I need some help here

Vorheriges Thema: Something like "WHERE" from SQL
Nächstes Thema: mysqli-trouble with mysql5