Jump to content

sql and xml


xander85

Recommended Posts

Are you getting a parse error now? Don't forget the semicolon at the end!This works for me:

$options = array(	'rootTag' => 'library',	'rowTag' => 'music',	/*'idColumn' => 'artistid',*/	'elements' => array(		'artist',		'album',		'source',		'kind',		'Added',		'stats' => array(			'rootTag' => 'library',			'rowTag' => 'stats',			/*'idColumn' => 'artistid',*/			'elements' => array(				'artists',				'albums',				'songs',				'updated',				'size', 				'playback', 				'mp3', 				'aac', 				'lossless'			)		)	));

Link to comment
Share on other sites

ok got the parse error fixed but now its got an error

Warning: require_once() [function.require-once]: URL file-access is disabled in the server configuration in /home/.reefer/xander85/acousticmushroom.com/library/library1.php on line 2Warning: require_once(http://www.acousticmushroom.com/library/XML/Query2XML.php) [function.require-once]: failed to open stream: no suitable wrapper could be found in /home/.reefer/xander85/acousticmushroom.com/library/library1.php on line 2Fatal error: require_once() [function.require]: Failed opening required 'http://www.acousticmushroom.com/library/XML/Query2XML.php' (include_path='.:/usr/local/php5/lib/php:/usr/local/lib/php') in /home/.reefer/xander85/acousticmushroom.com/library/library1.php on line 2
Link to comment
Share on other sites

Don't use the HTTP path to include or require a file, that will include the output of the PHP code, not the PHP code itself, and it can be disabled (as it is on your server). When you include a file use the local filesystem path, not the remote HTTP path.

Link to comment
Share on other sites

this is the PHP code, i dont understand PHP that much at all, im just going on what i was told to use by boen_robot

<?phprequire_once '/XML/Query2XML.php';require_once 'MDB2.php';/* Replace "user:pass" with your actual database username and password and replace "DB" with the actual database you'll be quering */$query2xml = XML_Query2XML::factory(MDB2::factory('mysql://xander:*******@acousticmushroom.com/library'));/* Replace the value of the following variable with the actual DB query you want or leave it like that to map the whole DB */$query = false;/////////////////////////////////////////The following array is where you forge the output XML file. Adjust those options depending on your DB layout//The sample here is directly copied from the documentation///////////////////////////////////////$options = array(    'rootTag' => 'library',    'rowTag' => 'music',    /*'idColumn' => 'artistid',*/    'elements' => array(        'artist',        'album',        'source',        'kind',        'Added',        'stats' => array(            'rootTag' => 'library',            'rowTag' => 'stats',            /*'idColumn' => 'artistid',*/            'elements' => array(                'artists',                'albums',                'songs',                'updated',                'size',                'playback',                'mp3',                'aac',                'lossless'            )        )    ));$xml = $query2xml->getXML($query, $options);/* This is the time to make certain adjustments to the output XML if you want to.If you have the XSL extension enabled (search php.net for "XSL"), you could perform the XSLT transformation on the server.If not, you might want to uncomment the following line to add a processing instruction in the XML, so that the XSLT transformation could be done on the client side (Changing "test.xsl" to the actual XSLT file you're using of course). */$xml->appendChild($xml->createProcessingInstruction('xml-stylesheet', 'href="library-date.xsl" type="text/xsl"'));//Serve the content as an XML document. You might want to remove this if you use the XSL extension on the server to generate HTML output//header('Content-Type: application/xml');//Display the result to the clientecho $xml->saveXML();?>

i dont get what you mean by dont use HTTP path??

Link to comment
Share on other sites

This line is the problem:require_once '/XML/Query2XML.php';Since it starts with a slash that path is a path that is relative to the server root, it will use HTTP. The error message tells you what file it is looking for.http://www.acousticmushroom.com/library/XML/Query2XML.phpThis is the path to the script that is running:/home/.reefer/xander85/acousticmushroom.com/library/library1.phpSo you can either use an absolute path to the include file:require_once '/home/.reefer/xander85/acousticmushroom.com/XML/Query2XML.php';or a relative path:require_once '../XML/Query2XML.php';

Link to comment
Share on other sites

ok i did the absolute path and it seemed to clear that error, but then i got another one.....

Fatal error: Uncaught <table border="1" cellspacing="0"> <tr><td colspan="3" bgcolor="#ff9999"> <b>XML_Query2XML_DBException</b>: Could not connect to database: [mdb2_error: message=MDB2 Error: not found" code=-4 mode=return level=notice prefix="" info="unable to find package 'MDB2_Driver_mysql' file 'MDB2/Driver/mysql.php'] in <b>/home/.reefer/xander85/acousticmushroom.com/library/XML/Query2XML.php</b> on line <b>233</b></td></tr> <tr><td colspan="3" bgcolor="#aaaaaa" align="center"><b>Exception trace</b></td></tr> <tr><td align="center" bgcolor="#cccccc" width="20"><b>#</b></td><td align="center" bgcolor="#cccccc"><b>Function</b></td><td align="center" bgcolor="#cccccc"><b>Location</b></td></tr> <tr><td align="center">0</td><td>XML_Query2XML->__construct(Object(MDB2_Error))</td><td>/home/.reefer/xander85/acousticmushroom.com/library/XML/Query2XML.php:233</td></tr> <tr><td align="center">1</td><td>XML_Query2XML::factory(Object(MDB2_Error))</td><td>/home/.reefer/xander85/acousticmushroom.co in /home/.reefer/xander85/acousticmushroom.com/library/XML/Query2XML.php on line 164
as i know no PHP really, it makes no sense to me at all, once i have this working i wont be doing anymore php loli appreciate every1's assistance
Link to comment
Share on other sites

The error message references lines 233 and lines 164 of Query2XML.php and says that it can't connect to a database because the MDB2/Driver/mysql.php file was not found. Check if that mysql.php file exists, I'll read through the thread and see if I have any other suggestions.

Link to comment
Share on other sites

cool, i fixed that, now i gots new errors, i have no idea what i am doing :) *cries*http://www.acousticmushroom.com/library/library1.php
The column "ID" used in the option "idColumn" does not exist in the result set.
Sounds like your database doesn't have an "ID" column. Then again, I see you've commented out those from the $options[].How about we try to simplify it, complicating it as it works. The simplest thing possible:
$options = array(	'rootTag' => 'library');

That should probably work, but will always generate only a single <library/> element. Still, the idea is to see ANY result.If that works, progress further by adding:

'rowTag' => 'music'

to the array and see how that works. Keep on going like that with the rest of the options. Slowly, but surely...

Link to comment
Share on other sites

How about we try to simplify it, complicating it as it works. The simplest thing possible:
$options = array(	'rootTag' => 'library');

Tried that but i still get an error? http://www.acousticmushroom.com/library/library1.php - error
<?phprequire_once '/home/.reefer/xander85/acousticmushroom.com/library/XML/Query2XML.php';require_once 'MDB2.php';/* Replace "user:pass" with your actual database username and password and replace "DB" with the actual database you'll be quering */$query2xml = XML_Query2XML::factory(MDB2::factory('mysql://xander:4093275@acousticmushroom.com/library'));/* Replace the value of the following variable with the actual DB query you want or leave it like that to map the whole DB */$query = false;/////////////////////////////////////////The following array is where you forge the output XML file. Adjust those options depending on your DB layout//The sample here is directly copied from the documentation///////////////////////////////////////$options = array(	'rootTag' => 'library');$xml = $query2xml->getXML($query, $options);/* This is the time to make certain adjustments to the output XML if you want to.If you have the XSL extension enabled (search php.net for "XSL"), you could perform the XSLT transformation on the server.If not, you might want to uncomment the following line to add a processing instruction in the XML, so that the XSLT transformation could be done on the client side (Changing "test.xsl" to the actual XSLT file you're using of course). */$xml->appendChild($xml->createProcessingInstruction('xml-stylesheet', 'href="library-date.xsl" type="text/xsl"'));//Serve the content as an XML document. You might want to remove this if you use the XSL extension on the server to generate HTML output//header('Content-Type: application/xml');//Display the result to the clientecho $xml->saveXML();?>

do i need the same require_once '/home/.reefer/xander85/acousticmushroom.com/library/ for the MDB2??could it be the mysql://xander:********@acousticmushroom.com/library is incorrect?the DB is called Library w/ two tables music and stats?is it Case sensitive?could it be the xls transformation? should i comment that to display raw data, there is also a css style attached to the xsl file could that be an issue?the css makes it look like thishttp://www.acousticmushroom.com/library/library-date.xml

Link to comment
Share on other sites

do i need the same require_once '/home/.reefer/xander85/acousticmushroom.com/library/ for the MDB2??
Possibly. Try to give it a try.
could it be the mysql://xander:********@acousticmushroom.com/library is incorrect?
There doesn't seem to be a connection error, so that's probably not it.
is it Case sensitive?
The file path? I think so. Still, you seem to have got the case correctly. If you mean the DB tables. I don't know. I think yes.
could it be the xls transformation?
If it was that, you weren't going to see an exception, but you were rather going to see "Cannot process input by stylesheet" error in the browser, and when you click "View > Source" you were going to actually see the generated XML.
should i comment that to display raw data, there is also a css style attached to the xsl file could that be an issue?
The CSS has nothing to do with it. Comment it out if you wish. The exception is still going to appear.The error I seem to notice is that simply that the idColumn option is mandatory.Let's try to first map only one of the tables. Say, music, like so:
$query = 'SELECT * FROM music';
For the idColumn option, use whatever your primary key in that table is.
Link to comment
Share on other sites

ok its not the path on the MDB2, i tried it with and without, got the same error.once i added

$query = 'SELECT * FROM music';
it gots a new error you can see it herehttp://www.acousticmushroom.com/library/library1.phpi obviously thought wrong if this was going to be easy, thankyou all for your patience.[Error message: Lost connection to MySQL server during query]could it be that there is nothing wrong with the code? and that its serverside, like my server acually doesnt allow that kind of connection?i dont see why it shouldnt tho, i use wordpress and that has a connection to MySQL thru the phpMyAdmin server i got....
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...