PHP - Moved: Whats The Best Book To Learn Modern Php
This topic has been moved to Miscellaneous.
http://www.phpfreaks.com/forums/index.php?topic=314342.0 Similar TutorialsThis topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=326872.0 This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=317410.0 This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=346785.0 This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=313079.0 This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=321790.0 This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=330649.0 This topic has been moved to HTML Help. http://www.phpfreaks.com/forums/index.php?topic=315426.0 This topic has been moved to CSS Help. http://www.phpfreaks.com/forums/index.php?topic=358008.0 This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=320263.0 This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=314251.0 This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=307477.0 Should one learn object oriented programming first, before getting to learn a framework?
I have been interested in CakePHP.
The junk I've found on phpclasses is well junk and not to mention really old. I started writing my own, but I frankly don't like the plumbing involved. Anyone have a great IMAP class? Something that just does the work for you? Is this an acceptable way to instantiate classes?
//$_SESSION['product'] = {'ProductA', 'ProductB', ... 'ProductX'} $p = new $_SESSION['product'](); $p->save();I am usually used to calling out classes explicitly where class name is not a variable but a hardcoded string. Sometimes I use if/then/else in order to do this. Here it is a variable and it bothers me a little bit. But PHP allows me to do this. Is this an acceptable latest & gratest modern PHP object oriented web technology technique or not ? Hello, I found this great free php calandar script here "" by Xu and Alessandro, and I'm trying to modify the code to mark several dates(birthdays YYYY-mm-dd) from a date column in a sql database. I've played around with the _showDay() method but I can't seem to get it working.. I've also tried to create a _showBirthday() method to modify the css as well but with no luck. What I'm trying to do is loop through the database to mark the respective dates on the calendar, and have a href to display a new page with the person's name when I click the specific date. Can anyone help with this. Thanks in advance! Hello, I'm a newbie and would like to learn PHP. I have some HTML and CSS skills, but would very much like to upgrade them to PHP. How can I do that? What materials do you suggest I read?... Thanks, Ok figured I'd go out and try to write me something for my site that I want and can't seem to be able to find what I want...sooooooooooo
I'm trying to create an NFL score 'ticker' and so far I've gotten as far as fetching the xml.. that part works LOL
I have been sitting here for a few hours trying to figure out how to do a foreach statement that works... I've hit a brick wall because I just can't seem to figure it out...
I have even tried a few I've found in other places but no go...
Here is what I have so far:
<?php $url="http://www.nfl.com/liveupdate/scorestrip/postseason/ss.xml"; $ch = curl_init(); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_URL, $url); // get the url contents $data = curl_exec($ch); // execute curl request curl_close($ch); $xml = simplexml_load_string($data); print_r($xml); //just keeping this here so I can see it for now ?>I know that part is working as you can see I left the print_r in it temp so I can still see I"m getting what I need... Again the problem is I'm not getting a functional foreach that I can get to work.. I either get nothing back or an error of some kind and trust me I've tried as many as I could find LOL SimpleXMLElement Object ( [gms] => SimpleXMLElement Object ( [@attributes] => Array ( [w] => 18 [y] => 2014 [t] => POST [gd] => 0 [bf] => 0 [bph] => 0 ) [g] => Array ( [0] => SimpleXMLElement Object ( [@attributes] => Array ( [eid] => 2015010301 [gsis] => 56492 [d] => Sat [t] => 8:15 [q] => P [htn] => Pittsburgh Steelers [hnn] => steelers [h] => PIT [hs] => 0 [vtn] => Baltimore Ravens [vnn] => ravens [v] => BAL [vs] => 0 [n] => NBC [rz] => 0 [ga] => [o] => 1 [gt] => WC ) ) [1] => SimpleXMLElement Object ( [@attributes] => Array ( [eid] => 2015010400 [gsis] => 56493 [d] => Sun [t] => 1:05 [q] => P [htn] => Indianapolis Colts [hnn] => colts [h] => IND [hs] => 0 [vtn] => Cincinnati Bengals [vnn] => bengals [v] => CIN [vs] => 0 [n] => CBS [rz] => 0 [ga] => [o] => 2 [gt] => WC ) ) [2] => SimpleXMLElement Object ( [@attributes] => Array ( [eid] => 2015011000 [gsis] => 0 [d] => Jan 10 [t] => 4:35 [q] => P [htn] => New England Patriots [hnn] => patriots [h] => NE [hs] => 0 [vnn] => [v] => TBD [vs] => 0 [n] => NBC [rz] => 0 [ga] => [o] => 3 [gt] => DIV ) ) [3] => SimpleXMLElement Object ( [@attributes] => Array ( [eid] => 2015011101 [gsis] => 0 [d] => Jan 11 [t] => 4:40 [q] => P [htn] => Denver Broncos [hnn] => broncos [h] => DEN [hs] => 0 [vnn] => [v] => TBD [vs] => 0 [n] => CBS [rz] => 0 [ga] => [o] => 4 [gt] => DIV ) ) [4] => SimpleXMLElement Object ( [@attributes] => Array ( [eid] => 2015011801 [gsis] => 0 [d] => Jan 18 [t] => 6:40 [q] => P [hnn] => [h] => TBD [hs] => 0 [vnn] => [v] => TBD [vs] => 0 [n] => CBS [rz] => 0 [ga] => [o] => 5 [gt] => CON ) ) [5] => SimpleXMLElement Object ( [@attributes] => Array ( [eid] => 2015011800 [gsis] => 0 [d] => Jan 18 [t] => 3:05 [q] => P [hnn] => [h] => TBD [hs] => 0 [vnn] => [v] => TBD [vs] => 0 [n] => FOX [rz] => 0 [ga] => [o] => 6 [gt] => CON ) ) [6] => SimpleXMLElement Object ( [@attributes] => Array ( [eid] => 2015011100 [gsis] => 0 [d] => Jan 11 [t] => 1:05 [q] => P [htn] => Green Bay Packers [hnn] => packers [h] => GB [hs] => 0 [vnn] => [v] => TBD [vs] => 0 [n] => FOX [rz] => 0 [ga] => [o] => 7 [gt] => DIV ) ) [7] => SimpleXMLElement Object ( [@attributes] => Array ( [eid] => 2015011001 [gsis] => 0 [d] => Jan 10 [t] => 8:15 [q] => P [htn] => Seattle Seahawks [hnn] => seahawks [h] => SEA [hs] => 0 [vnn] => [v] => TBD [vs] => 0 [n] => FOX [rz] => 0 [ga] => [o] => 8 [gt] => DIV ) ) [8] => SimpleXMLElement Object ( [@attributes] => Array ( [eid] => 2015010401 [gsis] => 56494 [d] => Sun [t] => 4:40 [q] => P [htn] => Dallas Cowboys [hnn] => cowboys [h] => DAL [hs] => 0 [vtn] => Detroit Lions [vnn] => lions [v] => DET [vs] => 0 [n] => FOX [rz] => 0 [ga] => [o] => 9 [gt] => WC ) ) [9] => SimpleXMLElement Object ( [@attributes] => Array ( [eid] => 2015010300 [gsis] => 56491 [d] => Sat [t] => 4:35 [q] => P [htn] => Carolina Panthers [hnn] => panthers [h] => CAR [hs] => 0 [vtn] => Arizona Cardinals [vnn] => cardinals [v] => ARI [vs] => 0 [n] => ESPN [rz] => 0 [ga] => [o] => 10 [gt] => WC ) ) [10] => SimpleXMLElement Object ( [@attributes] => Array ( [eid] => 2015012500 [gsis] => 0 [d] => Jan 25 [t] => 8:00 [q] => P [htn] => Team Cris Carter [hnn] => team carter [h] => CRT [hs] => 0 [vtn] => Team Michael Irvin [vnn] => team irvin [v] => IRV [vs] => 0 [n] => ESPN [rz] => 0 [ga] => [o] => 11 [gt] => PRO ) ) [11] => SimpleXMLElement Object ( [@attributes] => Array ( [eid] => 2015020100 [gsis] => 0 [d] => Feb 1 [t] => 6:30 [q] => P [hnn] => [h] => TBD [hs] => 0 [vnn] => [v] => TBD [vs] => 0 [n] => NBC [rz] => 0 [ga] => [o] => 12 [gt] => SB ) ) ) ) [gds] => SimpleXMLElement Object ( ) )My object is returning this and that's great... but my foreach skills need a TON of work apparently... I think I've looked at it too much and too long... some suggestions would be VERY much appreciated... Probably a bit big of a project to try on my first real attempt but I just went through the foreach in my tutorial but it's just not working.... What I'm looking to do is output the d, t, htn, vtn, hs, vs... I was trying to just get it to show just one of those but no go... Thanks everyone!!
This script with minor changes came from a tutorial. I did a var dump and get a NULL result. Can anyone tell me why? <?php /** Get web page via HTTP GET using Libcurl. */ function getPageDetails($target, $referer) { $info = curl_init(); //settings curl_setopt($info, CURLOPT_HEADER, true); curl_setopt($info, CURLOPT_COOKIEJAR, "cookie_jar.txt"); curl_setopt($info, CURLOPT_COOKIEFILE, "cookies.txt"); curl_setopt($info, CURLOPT_USERAGENT, "imagimediabot2"); curl_setopt($info, CURLOPT_URL, $url); curl_setopt($info, CURLOPT_REFERER, $referer); curl_setopt($info, CURLOPT_FOLLOWLOCATION, true); curl_setopt($info, CURLOPT_MAXREDIRS, 4); curl_setopt($info, CURLOPT_RETURNTRANSFER, true); //request $output = curl_exec($info); curl_close ($info); //seperate head and body $separator = "\r\n\r\n"; $header = substr( $output, 0, strpos( $output, $separator ) ); $body_start = strlen( $header ) + strlen( $separator ); $body = substr($output, $body_start, strlen($output)-$body_start); // parse headers $header_array = Array(); foreach (explode ("\r\n", $header) as $i => $line) { if($i === 0) { $header_array['http_code'] = $line; $status_info = explode( " ", $line ); $header_array['status_info'] = $status_info; } else { list ( $key, $value ) = explode ( ': ', $line ); $header_array[$key] = $value; } } $ret = Array("headers"=>$header_array,"body"=>$body); return $ret; } $page = getPageDetails("https://imagimedia.co.za", ""); $headers = $page['headers']; $http_status_code = $headers['http_code']; $body = $page['body']; var_dump($header_array) ?>
Hello everyone - I have picked dup a book on php and SQL and have been quaking through it. I have come across a problem with a foreach statement that I can not resolve. Any help and advice is greatly appreciated!
<?php try { $pdo = new PDO('mysql:host=localhost;dbname=ijdb; charset=utf8', 'ijdbuser', 'mypassword'); $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $sql = 'SELECT `joketext` FROM `joke`'; $result = $pdo->query($sql); while ($row = $result->fetch()) { $jokes[] = $row['joketext']; } } catch (PDOException $e) { $output = 'Unable to connect to the database server: ' . $e->getMessage() . ' in ' . $e->getFile() . ':' . $e->getLine(); } include __DIR__ . '/../templates/jokes.html.php'; and the other file
<!doctype html> <html> <head> <meta charset="utf-8"> <title>List of jokes</title> </head> <body> <?php if (isset($error)): ?> <p> <?php echo $error; ?> </p> <?php else: ?> <?php foreach($jokes as $joke ): ?> <blockquote> <p> <?php echo htmlspecialchars($joke, ENT_QUOTES, 'UTF-8') ?> </p> </blockquote> <?php endforeach; ?> <?php endif; ?> </body> </html>
Hi Guys, i got the PHP and MYSQL for dummies (4th addition) and i am typing up the code examples myself just to gain the experience. Im at the end of the book nearly where it is talking about log in applications that add info to the url but for some reason the code doesn't work. Im using Xampp as a localhost server. Attached are the two scripts for the program, and below is the include file. I open up the login_url form first: form_log.inc: <?php /* Program name: form_log.inc * Description: Displays a login form */ if( isset ( $message ) ) { echo $message; } echo "<form action='$_SERVER[PHP_SELF]' method='POST' style='margin: .5in'>\n <p><label for='username' style='font-weight: bold; padding-bottom: 1em'>User ID: </label> <input type='text' name='user_name' id='user_name' value='$user_name' />\n</p> <p><label for='password' style='font-weight: bold'>Password: </label> <input type='password' name='password' id='password' value='$password' />\n</p> <p><input type='submit' value='Log In'>\n</p> <input type='hidden' name='sent' value='yes' /> </form>\n"; ?> Here are the errors i get: Warning: include(dbstuff.inc) [function.include]: failed to open stream: No such file or directory in /Applications/XAMPP/xamppfiles/htdocs/test_php/login_url.php on line 31 Warning: include() [function.include]: Failed opening 'dbstuff.inc' for inclusion (include_path='.:/Applications/XAMPP/xamppfiles/lib/php:/Applications/XAMPP/xamppfiles/lib/php/pear') in /Applications/XAMPP/xamppfiles/htdocs/test_php/login_url.php on line 31 Couldn't execute query. Any help would be appreciated thankyou Enlighten |