|
Posted by petersprc on 11/30/06 04:05
Try setting error_reporting(E_ALL) at the top of the script; maybe some
notices will be generated. For instance, this might be a typo:
$row['custonerId']
Damo wrote:
> Hi,
> I have resords in an access database. I want to retrieve them using php
> and generate an xml file with them. I can retrieve the records and
> generate an xml file but the xml file contains no data.
> This is the code im using:
> PHP:
>
> $query1="SELECT * FROM cust";
> $result=odbc_exec($conn , $query1)or die("Query failed: $sql<br
> />Error: ".mysql_error()."<br />");
>
>
> $xml = '';
> $xml .= '<?xml version="1.0"?>'."\n";
> $xml .= '<!DOCTYPE customer SYSTEM "customer.dtd">'."\n";
> $xml .= '<shop>'."\n";
>
> while($row = odbc_fetch_row($result))
> {
>
> $xml .= '<customer>'."\n";
> $xml .= '<customerId>'.$row['custonerId'].'</customerId>'."\n";
> $xml .= '<name>'.$row['name'].'</name>'."\n";
> ///$xml .= '<address>'."\n";
> $xml .= '<addressline1>'.$row['address1'].'</addressline1>'."\n";
> $xml .= '<addressline2>'.$row['address2'].'</addressline2>'."\n";
> $xml .= '<addressline3>'.$row['address3'].'</addressline3>'."\n";
> ///$xml .= '</address>'."\n";
> $xml .= '<phone>'.$row['phone'].'</phone>'."\n";
>
> $xml .= '</customer>'."\n";
>
> }
> $xml .= '</shop>'."\n";
> $xmlfile = "C:\\phpdev\\www\\jim\\customers.xml";
> $myfile = fopen($xmlfile,"w+");
> fwrite($myfile,$xml);
> fclose($myfile);
>
> odbc_close($conn);
>
>
> and this is the XML it generates
>
> <?xml version="1.0" ?>
> <!DOCTYPE customer (View Source for full doctype...)>
> - <shop>
> - <customer>
> <customerId />
> <name />
> <addressline1 />
> <addressline2 />
> <addressline3 />
> <phone />
> </customer>
>
> Theres no data for name address etc...
>
> Anyone know why?
> Thanks
Navigation:
[Reply to this message]
|