PDA

View Full Version : PHP MySQL and XML Help!


masears88
08-24-2009, 04:15 PM
I am having some issues. I am still learning on PHP and MySQL. I am a fast learner and taught myself how to parse a XML file to an array. What i have is trailer_spec['number']['tagname']. My XML file is layed out like so:

<Unit rec_id="124*4691">
<web_dealer_id>124</web_dealer_id>
<stock_number>4691</stock_number>
<designation_code>N</designation_code>
<designation>NEW</designation>
<manufacturer>HUDSON</manufacturer>
<brand>HUDSON</brand>
<model>VSEBM03 16&apos;</model>
<model_year>2010</model_year>
<type_code>ETHD</type_code>
<type>EQUIPMENT TRAILER HD</type>
<status_code>A</status_code>
<status>AVAILABLE</status>
<gl_location_code>GGT</gl_location_code>
<lot_location_code>GGT</lot_location_code>
<lot_location>GOLDEN GAIT TRAILERS</lot_location>
<web_desc>Equipment Trailer with 4&apos; cleated fully adjustable ramps, 2 5/16&quot; ball hitch, diamond plat fenders, multi-leaf spring suspension, AL-Ko ultrulube axles w/brakes, electric brakes w/break-a-way kit, treated pine decking, and 4&quot; stake pockets.</web_desc>
<style>0</style>
<exterior_color>BLACK</exterior_color>
<length>16&apos;0&quot;</length>
<base_list>2659.80</base_list>
<factory_list>2659.80</factory_list>
<pdi_list>0.00</pdi_list>
<freight_list>0.00</freight_list>
<total_list>2659.8</total_list>
<Spec>
<spec_desc>WIDTH</spec_desc>
<spec_detail>8 ft. 5 in.</spec_detail>
</Spec>
<Spec>
<spec_desc>GVW</spec_desc>
<spec_detail>8950</spec_detail>
</Spec>
<Spec>
<spec_desc>WEIGHT</spec_desc>
<spec_detail>1950</spec_detail>
</Spec>
<Spec>
<spec_desc>AXLE</spec_desc>
<spec_detail>TANDEM AXLE</spec_detail>
</Spec>
</Unit>

My PHP Code is now reading the Unit and puts the information into the array. I have many units around 300 to 400. I don't need to worry about the Spec node, i have to do that differently. I am just worried about the other ones right now. Some how when I take the code and read it into the array then pass it to a variable for the sql query it doesn't like the &apos; and &quot;. It gives me an error message. I think that it is reading them as quotes or apostorphes and putting them into the code and throwing the statement off to insert into the database. Is there anyone that can help me with this? I just don't know what to do. An example is at www.goldengait.com/testing/xml/ this is what my variable looks like that I am using in the sql_query($variable, $link); any help is helpful! Thank you!