Jump to content

attaboy

Members
  • Posts

    72
  • Joined

  • Last visited

Everything posted by attaboy

  1. fantastic had no idea it would be so simple!! thanks again you're a genius!
  2. PHP 5.3.8 XAMPP on Windows XP I have an XML file that manages the input to an mp3 player on this page http://www.jimslounge.com/segovia/ The structure looks like this <content> <auto_play>yes</auto_play> <loop>yes</loop> <volume>60</volume> <artist> <song_title><![CDATA[bach - Suite No. 3 - Allemande]]></song_title> <artist_name><![CDATA[Andre Segovia]]></artist_name> <image_path>load/images/segovia.jpg</image_path> <mp3_path>load/songs/Bach - Suite No. 3 (for solo cello, arr. Duarte)- Allemande.mp3</mp3_path> <url target="_blank" open="yes">http://en.wikipedia.org/wiki/Andr%C3%A9s_Segovia</url> </artist> <artist> ... with <artist> being the repeating element I want to be able to read and eventually write to If I run this $xml = simplexml_load_file("load.xml"); var_dump($xml); I get this object(SimpleXMLElement)#1 (4) { ["auto_play"]=> string(3) "yes" ["loop"]=> string(3) "yes" ["volume"]=> string(2) "60" ["artist"]=> array(22) { [0]=> object(SimpleXMLElement)#2 (5) { ["song_title"]=> object(SimpleXMLElement)#24 (0) { } ["artist_name"]=> object(SimpleXMLElement)#25 (0) { } ["image_path"]=> string(23) "load/images/segovia.jpg" ["mp3_path"]=> string(74) "load/songs/Bach - Suite No. 3 (for solo cello, arr. Duarte)- Allemande.mp3" ... which is overwhelming This cleans it up but doesn't give me the artist name and song name I'm looking for. $xml = simplexml_load_file("load.xml"); echo $xml->getName() . "<br />"; foreach($xml->children() as $child) { echo $child->getName() . ": " . $child . "<br />"; } The Output: content auto_play: yes loop: yes volume: 60 artist: artist: artist: My experience with simplexml only goes back a couple of hours so I'm pretty inept at this point. Any help will be greatly appreciated.
  3. on the other hand no it wasn't. thanks scootstah!! I managed to screw up a site in Dreamweaver I had 2 identical directory's in different places I totally faked myself out.
  4. yes it is
  5. it says LIBxml support is active but I get Warning: simplexml_load_file() [function.simplexml-load-file]: I/O warning : failed to load external entity "world.xml" in C:\xampp\htdocs\segovia\load\songs.php on line 8 bool(false) this is the xml <?xml version="1.0" encoding="utf-8"?> <world> <continents> <NorthAmerica> <country>US</country> <country>Mexico</country> <country>Canada</country> </NorthAmerica> <SouthAmerica> <country>Equidor</country> <country>Peru</country> <country>Argentina</country> </SouthAmerica> </continents> </world> and this is my code: <?php $xml = simplexml_load_file("world.xml"); var_dump($xml); ?>
  6. PHP v. 5.3.8 What is libxml extension and how would I know if it's enabled? My book told me Note To take advantage of SimpleXML, make sure PHP's libxml extension is enabled.
  7. What is libxml extension and how would I know if it's enabled? My book told me "Note To take advantage of SimpleXML, make sure PHP's libxml extension is enabled.
  8. I did spell it GLOBAL on the command line I just misspelled in this post, thanks for bringing that to my attention though.
  9. MySQL version 5.0.8 SET GOLBAL log_bin_trust_routine_creators = 1; Fails with ERROR 1193(HY000) unknown system variable My textbook assured me this would work in runtime. Is the an ini file where I can set binary logging?
  10. I talked with my instructor and apparently the book is in error and it's a scope issue.
  11. But the whole idea is to find only countries in Europe where Spanish is spoken. The original code I posted here is copied from the sample code of my textbook which is MySQL 5.0 Study Guide from MySQL Press I'm trying to determine if the book is wrong and you can't access an alias defined in an outer query from an inner query or if just I can't do that. Except the alias issue the query works fine. If in the inner query I replace the 'c' with 'country.Code' it works.
  12. thanks for answering but that only gives me all the countries in Europe.
  13. This doesn't work on my system mysql 5.5.16 ERROR 1054(42s22): unknown column 'c' in 'where clause' SELECT Code c, Name FROM Country WHERE Continent = 'Europe' AND EXISTS (SELECT * FROM CountryLanguage WHERE CountryCode = c AND Language = 'Spanish'); The error message states there's an unknown column 'c' in the where clause. can't subqueries handle aliases?
  14. Thank You so much! That did it. btw ORDER by num DESC also works.
  15. Thanks for the reply. I'm pretty sure it's a legitimate join and the alias is a real alias because it works and this comes straight from joins section of a book published by MySQL Press. I'm trying to get the country with the highest number of cities. SELECT COUNT(*)AS num, country.Name FROM country, city WHERE CountryCode = Code GROUP BY country.Name HAVING num > 200;
  16. this is my code: SELECT COUNT(*)AS num, country.Name FROM country, city WHERE CountryCode = Code GROUP BY country.Name HAVING num = MAX(num); it doesn't work if the last line is having num > 100 that works but I just want to show the highest number.
  17. Oh! right no I get it....Thnaks!
  18. What's undefined about deposit()? class BankAccount { private $name; var $balance = 0; private $dep = 0; function __construct() { if (array_key_exists ("deposit" , $_POST)) { $dep = $_POST['deposit']; echo $dep; deposit($dep); } } function deposit($dep) { $balance += $dep; echo $balance; } }
  19. Thank you, I was just thinking of that since the class is in a php file what else are you going to do. I'm used to Actionscript 3 it's done differently there.
  20. I would like to keep all my classes in a folder placed within the htdocs folder where my php script runs. Let's say the classes folder is com\jimslounge\classes. From my script can I instantiate a class like this $myClass = new com\jimslounge\classes\Jimsclass(); Does it work something like that? I would hate to have to use include to access classes.
  21. That did it thanks much!!!
  22. The following was working fine till put the WHERE LifeExpectancy NOT NULL clause in. CREATE VIEW loDensity AS SELECT Name, SurfaceArea, Population, Population / SurfaceArea AS popDensity, LifeExpectancy FROM country WHERE LifeExpectancy NOT NULL ORDER BY popDensity LIMIT 10;
  23. I found something that works, it includes the SELECT statement you suggested, the foreach statement you thought I didn't need and I had to replace the switch block with some if else if's for some reason. Thanks for the help. $staff_count = 0; $result_set_cnt = 0; $query = "SELECT staff FROM flight_survey WHERE staff IN ('poor', 'fair', 'good', 'excellent')"; $result = mysql_query($query); while ($get_info = mysql_fetch_row($result)){ foreach ($get_info as $field){ echo "{$field}<br>"; if ($field == "poor") { $staff_count++; $result_set_cnt++; } else if ($field == "fair") { $staff_count += 2; $result_set_cnt++; } else if ($field == "good") { $staff_count += 3; $result_set_cnt++; } else if ($field == "excellent") { $staff_count += 4; $result_set_cnt++; } else { //nothing } } } echo $staff_count."<br>"; echo $result_set_cnt."<br>"; }
  24. but how do get the info out of $get_info if I do this: echo "{$get_info[0][0]}<br>"; echo "{$get_info[0][1]}<br>"; echo "{$get_info[0][2]}<br>"; echo "{$get_info[0][3]}<br>"; I get n o o f a i r f a i r g o o d f a i r g o o d n o o n o o n o o n o o e x c e e x c e g o o d g o o d p o o r f a i r f a i r g o o d f a i r g o o d g o o d f a i r p o o r p o o r p o o r
  25. I have a table for collecting airline satisfaction survey results(see attached image). I run a query to select the staff field there are 25 rows in this column I run a switch case block to filter out a result set that includes the responses 'poor', 'fair', 'good', and 'excellent' the result set should contain 20 elements function score_staff() { $staff_count = 0; $result_set_cnt = 0; $query = "SELECT staff FROM flight_survey"; $result = mysql_query($query); while ($get_info = mysql_fetch_row($result)){ foreach ($get_info as $field){ switch($field) { case "poor": $staff_count++; $result_set_cnt++; $exit; case "fair": $staff_count+=2; $result_set_cnt++; $exit; case "good": $staff_count+=3; $result_set_cnt++; $exit; case "excellent": $staff_count+=4; $result_set_cnt++; $exit; drfault: // do nothing } } } echo $staff_count."<br>"; echo $result_set_cnt."<br>"; } For each match I add 1 to the result set so with 20 matches $result_set_cnt should be 20 and not 53 as shown at the bottom of the attached image. The array $get_info bewilders me and I can't seem to access it's elements without putting it in a while loop. Anyway I'm pretty new to php and have a lot to learn. If anyone can explain how I could change the code so that the result set would contain 20 I think I'll be alright. thanks
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.