jeg får denne fejl når jeg åbner en php side:
mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\wamp\www\mymovies_createXML.php on line 51
jeg går ud fra at jeg har misset et tegn et eller andet sted inden line 51, men jeg kan ved gud ikke se hvor og hvilket.
koden ser sådan ud:
- <?php
-
- //Connection to MySQL
- $MySQL_Host="localhost";
- $MySQL_Port="3306";
- $MySQL_User="";
- $MySQL_Passw="";
- $MySQL_Db="mymovies_pronto";
-
- // Function for connection to MySQL
- function connect_mysql() {global $MySQL_Host, $MySQL_User, $MySQL_Passw;
- if (! $linkid=@mysql_connect("$MySQL_Host","$MySQL_User","$MySQL_Passw")) {
- echo "Connection to MySQL failed ",$MySQL_Host,"<BR>";
- exit;
- }
- return $linkid;
- }
-
- //Connecting to Mysql
- $db_connect = connect_mysql();
-
- //Selecting MySQL database
- mysql_select_db($MySQL_Db , $db_connect);
-
- //Retrieving chains
- $sql_retrieve_chains = "SELECT collectionnumber FROM movies ORDER BY collectionnumber";
- $req_retrieve_chains = mysql_query($sql_retrieve_chains);
-
-
- //Functions and constants for XML
- define('EOL', "\r\n");
-
- function XML_entities($str)
- {
- return preg_replace(array("'&'", "'\"'"), array('&', '"'), $str);
- }
-
- //Creating XML-file
- header("Content-Type: text/plain");
-
- print("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>") . EOL;
- print("<Titles>") . EOL;
- while($data = mysql_fetch_array($req_retrieve_chains)) {
- print(" <Collection" . XML_entities($data['collectionnumber']) . "Number>") . EOL;
- $sql_retrieve_title = "SELECT collectionnumber, webid, title, aspect, standard, year, description
- FROM movies
- WHERE collectionnumber='" . $data['collectionnumber'] . "'
- ORDER BY collectionnumber";
-
- $req_retrieve_title = mysql_query($sql_retrieve_title);
- $array_retrieve_title = mysql_fetch_array($req_retrieve_title);
-
-
- print(" <LocalTitle>" . XML_entities($array_retrieve_title['title']) . "</LocalTitle>") . EOL;
- print(" <WebServiceID>" . XML_entities($array_retrieve_title['webid']) . "</WebServiceID>") . EOL;
- print(" <AspectRatio>" . XML_entities($array_retrieve_title['aspect']) . "</AspectRatio>") . EOL;
- print(" <VideoStandard>" . XML_entities($array_retrieve_title['standard']) . "</VideoStandard>") . EOL;
- print(" <ProductionYear>" . XML_entities($array_retrieve_title['year']) . "</ProductionYear>") . EOL;
- print(" <Description>" . XML_entities($array_retrieve_title['description']) . "</Description>") . EOL;
-
- print(" </Collection" . XML_entities($data['collectionnumber']) . "Number>") . EOL;
-
- }
- print("</Titles>") . EOL;
-
- ?>
Indlæg senest redigeret d. 26.02.2012 12:59 af Bruger #15116