Jump to content
Larry Ullman's Book Forums

Edward

Members
  • Posts

    1115
  • Joined

  • Last visited

  • Days Won

    27

Everything posted by Edward

  1. I have seen that the Yii framework is supposed to run 5 times faster than the Zend framework. I will take a look into it. But what if we are coding in procedural code, the framework is in OOP, can we still use procedural with that? Ah larry my mistake again, i will look at that again today Zend Framework, i thought the Zend Server included that. Will check Zend and Yii out.
  2. I tried this also i added to mysql.inc.php <?php // This file contains the database access information. // This file establishes a connection to MySQL and selects the database. // This file defines a function for making data safe to use in queries. // This file defines a function for hashing passwords. // This script is begun in Chapter 3. // Set the database access information as constants: DEFINE ('DB_USER', 'root'); DEFINE ('DB_PASSWORD', 'edward'); DEFINE ('DB_HOST', 'localhost'); DEFINE ('DB_NAME', 'knowledge_is_power'); // Make the connection: $dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); // Set the character set: mysqli_set_charset($dbc, 'utf8'); $q = "INSERT INTO users (username, email, pass, first_name, last_name, date_expires) VALUES ('1', '1', '1', '1', '1', SUBDATE(NOW(), INTERVAL 1 DAY) )"; $r = mysqli_query ($dbc, $q); etc..... and added to index.php <?php // This file is the home page. // This script is begun in Chapter 3. // Require the configuration before any PHP code as the configuration controls error reporting: require ('./includes/config.inc.php'); // The config file also starts the session. // To test the sidebars: // $_SESSION['user_id'] = 1; // $_SESSION['user_admin'] = true; // Require the database connection: require (MYSQL); $q = "INSERT INTO users (username, email, pass, first_name, last_name, date_expires) VALUES ('2', '2', '2', '2', '2', SUBDATE(NOW(), INTERVAL 1 DAY) )"; $r = mysqli_query ($dbc, $q); // Next block added in Chapter 4: // If it's a POST request, handle the login attempt: if ($_SERVER['REQUEST_METHOD'] == 'POST') { include ('./includes/login.inc.php'); } etc.... Then i run the index.php script well the values from mysql.inc.php went into the database, but again on index.php i got the error below and the values didn't make it into the database: An error occurred in script 'C:\xampp\htdocs\knowledge_is_power\www\index.php' on line 18: Undefined variable: dbc Why is dbc undefined when we already required the mysql.inc.php script in index.php i don't understand?
  3. Update, i tried running this code in my mysql.inc.php file // Make the connection: $dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); // Set the character set: mysqli_set_charset($dbc, 'utf8'); $q = "INSERT INTO users (username, email, pass, first_name, last_name, date_expires) VALUES ('Admin', 'admin', 'password', 'Admin', 'Admin', SUBDATE(NOW(), INTERVAL 1 DAY) )"; $r = mysqli_query ($dbc, $q); Now when i run the index.php file it run the require(MYSQL); and this part of the code would then run. Well the record was successfully written to the users table. Does this give anyone an idea of what the issue could be?
  4. I don't want to give up that easy, with your explaining i am sure i will make it through. I tried to add in the echo mysql_error (); But no reading comes up, i also have this error showing on the same page: An error occurred in script 'C:\xampp\htdocs\knowledge_is_power\www\index.php' on line 35: mysqli_query() expects parameter 1 to be mysqli, null given
  5. Hey everyone i wanted to start a topic on php frameworks and which ones you like the most? I like to code stuff from scratch, but i have been recommended by friends for bigger projects to build into a framework. I have just download Zend Server 5.6 and taking a look. So far it seems easy to use and it is great at error handling and monitoring your website page performance. I feel confident with Zend as it is by the makers of PHP and looks like it will be here to stay, but the downside it seems that you need a deep pocked with it, and even the impression i got when i just downloaded it and i had the 29 days left trial counter.
  6. I cleared the cache and now it is showing, wonderful, thanks
  7. Ive checked this again i can't see what the problem is? I have used mysql connections before when connecting to the database, this was the first time for me using mysql extension with objects. What test could i do for checking the mysqli connection. I have the code copied in my apache server exactly as from your book, i have just been making important notes as i read through.
  8. I included the MySql connection script, here is my index.php page up till the part when $dbc is required, <?php // This file is the home page. // This script is begun in Chapter 3. // Require the configuration before any PHP code as the configuration controls error reporting: require ('./includes/config.inc.php'); // The config file also starts the session. // To test the sidebars: // $_SESSION['user_id'] = 1; // $_SESSION['user_admin'] = true; // Require the database connection: require (MYSQL); // Next block added in Chapter 4: // If it's a POST request, handle the login attempt: if ($_SERVER['REQUEST_METHOD'] == 'POST') { include ('./includes/login.inc.php'); } // Include the header file: include ('./includes/header.html'); /* PAGE CONTENT STARTS HERE! */ ?><h3>Welcome</h3> <p>Welcome to Knowledge is Power, a site dedicated to keeping you up to date on the Web security and programming information you need to know. Blah, blah, blah. Yadda, yadda, yadda.</p> <?php // Bonus material! Referenced in Chapter 5. // Display the most popular pages: echo '<h3>Most Popular Pages</h3><p>'; $q = "SELECT COUNT(history.id) AS num, pages.id, pages.title FROM pages, history WHERE pages.id=history.page_id AND history.type='page' GROUP BY (history.page_id) ORDER BY num DESC LIMIT 10"; $r = mysqli_query($dbc, $q); I even put an echo statement in the mysql.inc.php file to make sure that the file was running, and it showed up. I am guessing i have to check if the database is connection is actually connecting or not which may be leading to it being undefined.
  9. Edward

    Introductions

    Yes the books are great, i will be purchasing a few of his others also. Interested in his new javascript book. Is that what dogtanian looks like after all these years?
  10. I just updated my profile picture, but the old one is still showing?
  11. I am getting this error coming up when i try to run my script, it is showing on all scripts that require the database dbc connection. Here is the error that is showing on the knowledge_is_power index page, does Larry or anyone here know how to fix this? An error occurred in script 'C:\xampp\htdocs\knowledge_is_power\www\index.php' on line 35: Undefined variable: dbc Array ( [0] => Array ( [file] => C:\xampp\htdocs\knowledge_is_power\www\index.php [line] => 35 [function] => my_error_handler [args] => Array ( [0] => 8 [1] => Undefined variable: dbc [2] => C:\xampp\htdocs\knowledge_is_power\www\index.php [3] => 35 [4] => Array ( [GLOBALS] => Array *RECURSION* [__utma] => 111872281.92522752.1309196757.1309196757.1309196757.1 [Drupal_toolbar_collapsed] => 0 [Drupal_tableDrag_showWeight] => 0 [sESSbce8863eabfd478fab0d5a5077b9e512] => RPzBUmLIJ_x2rxRSAkhhveaBQcp8skL0l4hpKmbNbtg [phpSESSID] => 2631qhcn4o4i6u50d6h4sdrtm0 [MIBDIRS] => C:/xampp/php/extras/mibs [MYSQL_HOME] => \xampp\mysql\bin [OPENSSL_CONF] => C:/xampp/apache/bin/openssl.cnf [php_PEAR_SYSCONF_DIR] => \xampp\php [phpRC] => \xampp\php [TMP] => \xampp\tmp [HTTP_HOST] => localhost [HTTP_USER_AGENT] => Mozilla/5.0 (Windows NT 6.1; WOW64; rv:9.0.1) Gecko/20100101 Firefox/9.0.1 [HTTP_ACCEPT] => text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 [HTTP_ACCEPT_LANGUAGE] => en-us,en;q=0.5 [HTTP_ACCEPT_ENCODING] => gzip, deflate [HTTP_ACCEPT_CHARSET] => ISO-8859-1,utf-8;q=0.7,*;q=0.7 [HTTP_CONNECTION] => keep-alive [HTTP_REFERER] => http://localhost/knowledge_is_power/www/register.php [HTTP_COOKIE] => __utma=111872281.92522752.1309196757.1309196757.1309196757.1; Drupal.toolbar.collapsed=0; Drupal.tableDrag.showWeight=0; SESSbce8863eabfd478fab0d5a5077b9e512=RPzBUmLIJ_x2rxRSAkhhveaBQcp8skL0l4hpKmbNbtg; PHPSESSID=2631qhcn4o4i6u50d6h4sdrtm0 [PATH] => C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\QuickTime\QTSystem\ [systemRoot] => C:\Windows [COMSPEC] => C:\Windows\system32\cmd.exe [PATHEXT] => .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC [WINDIR] => C:\Windows [sERVER_SIGNATURE] => Apache/2.2.17 (Win32) mod_ssl/2.2.17 OpenSSL/0.9.8o PHP/5.3.4 mod_perl/2.0.4 Perl/v5.10.1 Server at localhost Port 80 [sERVER_SOFTWARE] => Apache/2.2.17 (Win32) mod_ssl/2.2.17 OpenSSL/0.9.8o PHP/5.3.4 mod_perl/2.0.4 Perl/v5.10.1 [sERVER_NAME] => localhost [sERVER_ADDR] => 127.0.0.1 [sERVER_PORT] => 80 [REMOTE_ADDR] => 127.0.0.1 [DOCUMENT_ROOT] => C:/xampp/htdocs [sERVER_ADMIN] => postmaster@localhost [sCRIPT_FILENAME] => C:/xampp/htdocs/knowledge_is_power/www/index.php [REMOTE_PORT] => 49840 [GATEWAY_INTERFACE] => CGI/1.1 [sERVER_PROTOCOL] => HTTP/1.1 [REQUEST_METHOD] => GET [QUERY_STRING] => [REQUEST_URI] => /knowledge_is_power/www/index.php [sCRIPT_NAME] => /knowledge_is_power/www/index.php [php_SELF] => /knowledge_is_power/www/index.php [REQUEST_TIME] => 1327298686 [_POST] => Array ( ) [_GET] => Array ( ) [_COOKIE] => Array ( [__utma] => 111872281.92522752.1309196757.1309196757.1309196757.1 [Drupal_toolbar_collapsed] => 0 [Drupal_tableDrag_showWeight] => 0 [sESSbce8863eabfd478fab0d5a5077b9e512] => RPzBUmLIJ_x2rxRSAkhhveaBQcp8skL0l4hpKmbNbtg [phpSESSID] => 2631qhcn4o4i6u50d6h4sdrtm0 ) [_SERVER] => Array ( [MIBDIRS] => C:/xampp/php/extras/mibs [MYSQL_HOME] => \xampp\mysql\bin [OPENSSL_CONF] => C:/xampp/apache/bin/openssl.cnf [php_PEAR_SYSCONF_DIR] => \xampp\php [phpRC] => \xampp\php [TMP] => \xampp\tmp [HTTP_HOST] => localhost [HTTP_USER_AGENT] => Mozilla/5.0 (Windows NT 6.1; WOW64; rv:9.0.1) Gecko/20100101 Firefox/9.0.1 [HTTP_ACCEPT] => text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 [HTTP_ACCEPT_LANGUAGE] => en-us,en;q=0.5 [HTTP_ACCEPT_ENCODING] => gzip, deflate [HTTP_ACCEPT_CHARSET] => ISO-8859-1,utf-8;q=0.7,*;q=0.7 [HTTP_CONNECTION] => keep-alive [HTTP_REFERER] => http://localhost/knowledge_is_power/www/register.php [HTTP_COOKIE] => __utma=111872281.92522752.1309196757.1309196757.1309196757.1; Drupal.toolbar.collapsed=0; Drupal.tableDrag.showWeight=0; SESSbce8863eabfd478fab0d5a5077b9e512=RPzBUmLIJ_x2rxRSAkhhveaBQcp8skL0l4hpKmbNbtg; PHPSESSID=2631qhcn4o4i6u50d6h4sdrtm0 [PATH] => C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\QuickTime\QTSystem\ [systemRoot] => C:\Windows [COMSPEC] => C:\Windows\system32\cmd.exe [PATHEXT] => .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC [WINDIR] => C:\Windows [sERVER_SIGNATURE] => Apache/2.2.17 (Win32) mod_ssl/2.2.17 OpenSSL/0.9.8o PHP/5.3.4 mod_perl/2.0.4 Perl/v5.10.1 Server at localhost Port 80 [sERVER_SOFTWARE] => Apache/2.2.17 (Win32) mod_ssl/2.2.17 OpenSSL/0.9.8o PHP/5.3.4 mod_perl/2.0.4 Perl/v5.10.1 [sERVER_NAME] => localhost [sERVER_ADDR] => 127.0.0.1 [sERVER_PORT] => 80 [REMOTE_ADDR] => 127.0.0.1 [DOCUMENT_ROOT] => C:/xampp/htdocs [sERVER_ADMIN] => postmaster@localhost [sCRIPT_FILENAME] => C:/xampp/htdocs/knowledge_is_power/www/index.php [REMOTE_PORT] => 49840 [GATEWAY_INTERFACE] => CGI/1.1 [sERVER_PROTOCOL] => HTTP/1.1 [REQUEST_METHOD] => GET [QUERY_STRING] => [REQUEST_URI] => /knowledge_is_power/www/index.php [sCRIPT_NAME] => /knowledge_is_power/www/index.php [php_SELF] => /knowledge_is_power/www/index.php [REQUEST_TIME] => 1327298686 ) [_ENV] => Array ( ) [_FILES] => Array ( ) [_REQUEST] => Array ( ) [live] => [contact_email] => you@example.com [_SESSION] => Array ( ) [http_response_header] => Array ( [0] => HTTP/1.1 200 OK [1] => Date: Mon, 23 Jan 2012 06:04:47 GMT [2] => Server: Apache/2.2.17 (Win32) mod_ssl/2.2.17 OpenSSL/0.9.8o PHP/5.3.4 mod_perl/2.0.4 Perl/v5.10.1 [3] => X-Powered-By: PHP/5.3.5 [4] => Content-Length: 0 [5] => Connection: close [6] => Content-Type: text/html ) [pages] => Array ( [Home] => index.php [About] => # [Contact] => # [Register] => register.php ) [this_page] => index.php [v] => register.php [k] => Register [q] => SELECT COUNT(history.id) AS num, pages.id, pages.title FROM pages, history WHERE pages.id=history.page_id AND history.type='page' GROUP BY (history.page_id) ORDER BY num DESC LIMIT 10 ) ) ) )
  12. Edward

    Introductions

    Hey pete you have some nice website's glad you love the larry book's. I am working through Effortless Eccomerce right now, its awesome. See you around!
  13. Thank you for correcting me on the data types. Well you have some good points there, i guess there is a chance may be even i do not exist in 26 years time, lol. Well so be it, TIMESTAMP() it will be. Thanks Larry
  14. TIMESTAMP() *A timestamp. TIMESTAMP values are stored as the number of seconds since the Unix epoch ('1970-01-01 00:00:00' UTC). Format: YYYY-MM-DD HH:MM:SS Note: The supported range is from '1970-01-01 00:00:01' UTC to '2038-01-09 03:14:07' UTC "I was wondering about the TIMESTAMP() data type, well this runs out in 2038, what if we are building a site that we are planning to have longer than 2038? Should we use the TIMESTAMP() now and hope PHP will do something about this or DATETIME() which runs up to 9999?" DATETIME() *A date and time combination. Format: YYYY-MM-DD HH:MM:SS Note: The supported range is from '1000-01-01 00:00:00' to '9999-12-31 23:59:59'
  15. Hi, Everyone here ! How are you all? I would like to leave a review about the Effortless E-Commerce book. I have bought a few PHP Eccommerce books some which were written with OOP coding using the business tier model and mvc. But i have found Larry Ullman's to best the other books by far on the market. It comes with well explained clear examples of some of the most up to date PHP features which are no readily available. The book is also great for beginners to understand the Model View Controller design pattern framework as Larry starts it of in procedural code, which helps some of us less knowledgeable to get into the idea. Its funny i mention the book is good for beginners, actually i am a begginer but this book does states by Larry that its for Intermediate/Advanced for those that have a knowledge of PHP. So there you go, that's how good Larry is at explaining stuff, even someone like me with a small knowledge of PHP can get this book and work it out. Yes this book is good, i would recommend this to anyone getting into Ecommerces website's with php and mysql MVC model. Thanks Larry for dedicating your time into something useful for helping others!
×
×
  • Create New...