Jump to content
Larry Ullman's Book Forums

Search the Community

Showing results for tags 'error'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Single Editions
    • Modern Javascript: Develop and Design
    • The Yii Book
    • Effortless Flex 4 Development
    • Building a Web Site with Ajax: Visual QuickProject
    • Ruby: Visual QuickStart Guide
    • C++ Programming: Visual QuickStart Guide
    • C Programming: Visual QuickStart Guide
    • Adobe AIR: Visual QuickPro Guide
  • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (5th Edition)
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (4th Edition)
    • PHP 6 and MySQL 5 for Dynamic Web Sites: Visual QuickPro Guide (3rd Edition)
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (2nd Edition)
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (1st Edition)
  • PHP for the Web: Visual QuickStart Guide
    • PHP for the Web: Visual QuickStart Guide (5th Edition)
    • PHP for the Web: Visual QuickStart Guide (4th Edition)
    • PHP for the Web: Visual QuickStart Guide (3rd Edition)
    • PHP for the World Wide Web: Visual QuickStart Guide (2nd Edition)
    • PHP for the World Wide Web: Visual QuickStart Guide (1st Edition)
  • Effortless E-commerce with PHP and MySQL
    • Effortless E-Commerce with PHP and MySQL (2nd Edition)
    • Effortless E-Commerce with PHP and MySQL
  • PHP Advanced: Visual QuickPro Guide
    • PHP Advanced and Object-Oriented Programming: Visual QuickPro Guide (3rd Edition)
    • PHP 5 Advanced: Visual QuickPro Guide (2nd Edition)
    • PHP Advanced: Visual QuickPro Guide
  • MySQL: Visual QuickStart Guide
    • MySQL: Visual QuickStart Guide (2nd Edition)
    • MySQL: Visual QuickStart Guide (1st Edition)
  • Other
    • Announcements
    • Newsletter, Blog, and Other Topics
    • Forum Issues
    • Social

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Found 13 results

  1. I'm running PHP files of example 2 from my computer and I got those following errors across pages. An error occurred in script 'D:\XAMPP\htdocs\ex2\html\views\home.html' on line 14: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given Array An error occurred in script 'D:\XAMPP\htdocs\ex2\html\shop.php' on line 32: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given Array An error occurred in script 'D:\XAMPP\htdocs\ex2\html\sales.php' on line 20: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given Array An error occurred in script 'D:\XAMPP\htdocs\ex2\html\wishlist.php' on line 80: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given Array An error occurred in script 'D:\XAMPP\htdocs\ex2\html\cart.php' on line 81: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given Array Can someone please tell me how to fix it? Thanks.
  2. I created various websites (based on Larry's code) that worked fine for years, but after my web hosting company upgraded to PHP Version 5.6.27, I repeatedly receive this error message: "An error occurred in script '.../mysql_connect.php' on line 8: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead" I was able to suppress that error message on one website by prepending the "@" symbol to the expression, but strangely it did not work on another site. I'd like to know why (as a quick fix), and whether I can do something to suppress error messages for an entire site instead of using "@" multiple times. I'd also love to know how to change my code to work with PDO (preferably) or MySQLi; my web host supports both. It would be great to see an example of PHP handling data with old MySQL code and PHP working with PDO or MySQLi, to see how to "translate" it, so to speak. However, I don't want to use PDO if that requires me to learn Object-Oriented PHP; all my sites are based on procedural PHP. The above error message is generated in response to this mysql_connect.php code: <?php error_reporting(0); // didn't suppress error message ini_set('display_errors',0); // didn't suppress error message DEFINE ('DB_USER', '***'); DEFINE ('DB_PASSWORD', '***'); DEFINE ('DB_HOST', '***'); DEFINE ('DB_NAME', '***'); if ($dbc = @mysql_connect (DB_HOST, DB_USER, DB_PASSWORD)) { // this is the line generating the error message if (@!mysql_select_db (DB_NAME)) { trigger_error("Could not select the database!\n<br />MySQL Error: " . mysql_error()); exit(); } } else { trigger_error("Could not connect to MySQL!\n<br />MySQL Error: " . mysql_error()); exit(); } function escape_data ($data) { if (ini_get('magic_quotes_gpc')) { $data = stripslashes($data); } if (function_exists('mysql_real_escape_string')) { global $dbc; $data = @mysql_real_escape_string (trim($data), $dbc); } else { $data = @mysql_escape_string (trim($data)); } return $data; } ?> Thank you!
  3. Ok I haven't followed the code 100% by which I mean only that I didn't include the XHTML parts in the <!DOCTYPE> tag. I understand that this is not vital however. Other than that I think I have followed it correctly. I keep getting http error 500 in the browser however when I try to load it. However other php scripts seem to load fine so I don't think it's a problem with MAMP. Here is my code: <!DOCTYPE html> <html> <head> <meta charset="utf-8" http-equiv="Content-Type" content="text/html"> <title>Calendar</title> </head> <body> <form action="calendar.php" method="post"> <?php # Script 2.6 - Calendar.php //This script makes 3 pulldown menus //For an html form: months, days, years. //make months array $months = array (1 => 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'); //make the days and years array $days = range (1, 31); $years = range (2011, 2021); //make the months pull down menu: echo '<select name="month">'; for each ($months as $key => $value) { echo "<option value=\"$key\">$value</option>\n"; } echo '</select>'; //make the days pull-down menu: echo '<select name="day">'; foreach ($days as $value) { echo "<option value=\"$value\">$value</option>\n"; } echo '</select>'; //make the years pull-down menu: echo '<select name="year">'; foreach ($year as $value) { echo "<option value=\"$value\"> $value</option>\n"; } echo "</select>"; ?> </form> </body> </html> It's probably something incredibly obvious and embarrassing but any help would be gratefully received. I'm going to skip ahead and read the section of bug fixing while I wait for a response so maybe I will find the answer there. Thanks in advance.
  4. Please see below: I am copying the information from the book, but for some reason I keep getting errors for the following 2 lines. Any suggestions? ** Error on this line** - function my_error_handler($e_number, $e_message, $e_file, –$e_line, $e_vars){ $message = "An error occurred in script '$e_file' on line $e_line:\n$e_message\n"; $message .= "<pre>" .print_r(debug_backtrace(), 1) . "</pre>\n"; if (!LIVE){ echo 'div class="alert alert-danger">' .nl2br($message) . '/div'; }else{ error_log($message, 1, CONTACT_EMAIL, ** Error on this line** – 'From:admin@example.com'); if ($e_number !=E_NOTICE){ echo '<div class="alert alert-danger">A system error occurred. We apologize for the inconvenience.</div>'; } }//End of $live IF-ELSE. return true; }//End of my_error_handler() definition.
  5. Spammers are sometimes visiting my new website and entering false data in my register.php script. The result is that they don't register and several php error log messages are emailed to me. I get an error message email for each form field that has an undefined index. I would like to know how to stop getting these emails. Here is a copy of a section of the error message email. An error occurred in script '/home/strawb15/public_html/examplesite.com/register.php' on line 40: Undefined index: emailArray ( [_GET] => Array ( ) [_POST] => Array ( [username] => hebirchfijose [usermail] => aulbachpuid@sohu.com [userpass] => E970d483- [usersex] => 1 [userliving] => 16 [bdayy] => 1930 [bdaym] => 3 [bdayd] => 12 [imgcode] => [formsubmit] => Y [submit] => 確定 ) [_COOKIE] => Array ( ) [_FILES] => Array [_SERVER] => Array ( [CONTENT_LENGTH] => 173 [CONTENT_TYPE] => application/x-www-form-urlencoded [DOCUMENT_ROOT] => /home/strawb15/public_html/examplesite.com [GATEWAY_INTERFACE] => CGI/1.1 [HTTP_ACCEPT] => text/html,application/xhtml+xml,application/xml;image/png,image/jpeg,image/*;q=0.9,*/*;q=0.8 [HTTP_ACCEPT_ENCODING] => gzip [HTTP_ACCEPT_LANGUAGE] => en-us;q=0.7, en;q=0.3 [HTTP_CACHE_CONTROL] => max-age=259200 [HTTP_CONNECTION] => keep-alive [HTTP_HOST] =>www.examplesite.com [HTTP_REFERER] =>http://www.examplesite.com/register.php [HTTP_USER_AGENT] => Mozilla/5.0 (Windows NT 6.1; WOW64; rv:34.0) Gecko/20100101 Firefox/34.0 [HTTP_VIA] => 1.1 117-30-149:55336 (s.r577) [HTTP_X_FORWARDED_FOR] => 162.211.122.43 [PATH] => /bin:/usr/bin [phpRC] => /home/strawb15/public_html [QUERY_STRING] => [REDIRECT_STATUS] => 200 [REMOTE_ADDR] => 218.203.13.233 [REMOTE_PORT] => 13417 [REQUEST_METHOD] => POST [REQUEST_URI] => /register.php [sCRIPT_FILENAME] => /home/strawb15/public_html/examplesite.com/register.php [sCRIPT_NAME] => /register.php [sERVER_ADDR] => 23.235.206.99 [sERVER_ADMIN] => webmaster@examplesite.com [sERVER_NAME] => www.examplesite.com [sERVER_PORT] => 80 [sERVER_PROTOCOL] => HTTP/1.0 [sERVER_SIGNATURE] => [sERVER_SOFTWARE] => Apache [uNIQUE_ID] => VXgCnBfrzmMAAHvJFtIAAAA3 [php_SELF] => /register.php [REQUEST_TIME_FLOAT] => 1433928348.53 [REQUEST_TIME] => 1433928348 [argv] => Array ( ) [argc] => 0
  6. In the following code would you leave the part in where it says or trigger error and so on, on a live site mysqli_query($dbc, $i) or trigger_error("Query: $i\n<br />mysqli Error: " . mysqli_error($dbc));
  7. To Whom It May Concern, I ran the code on page 369 and 370 (var interval = setInterval(doThis, 10000); and I only see four dialog boxes pop up. This is certainly a typo, right (to make it five, n==6 not n==5 would have to appear in doThis() )? Sincerely, Alex
  8. I am having problems with password.php script. I believe that I have followed the book precisely, but maybe not since I am here. Nonetheless, I continue to receive an error msg after I submit the form for the new password. the msg is that - The email address and the password do not match those on file. I have double and triple, and quadruple checked to make sure that I am submitting the correct info that I registered with. My other two scripts associated with the password.php are operating properly (view_users.php & register.php); including populating the correct error msgs when forms are not correctly filled in. The only thing that I believe might be an issue outside of the script, is that it calls for an interaction with the user_id (database I'm guessing), which was not coded for per the book (I double checked a number of times). I did update the view_users.php so that it counts the number of users but I still do not see where it calls for an id in the script. And also, how do I get my script to show up as the colors of my text editor without manually changing. I use TextWrangler and have a Mac - Thanx again <?php # script 9.7 - password.php // this script allows users to change password $page_title = 'Change Your Password'; include ('include/header.html'); //check for submission: if ($_SERVER['REQUEST_METHOD'] == 'POST') { require ('mysqli_connect.php'); // connect to database $errors = array(); // initalize an error array if (empty($_POST['email'])) { $errors[] = 'you forgot to enter a email.'; } else { $e = mysqli_real_escape_string($dbc, trim($_POST['email'])); } // Check for the current password if (empty($_POST['pass'])) { $errors[] = 'you forgot to enter your current password.'; } else { $p = mysqli_real_escape_string($dbc, trim($_POST['pass'])); } // check for a new password and match against the confirmed password if (!empty($_POST['pass1'])) { if ($_POST['pass1'] != $_POST['pass2']) { $errors[] = 'your new password does not match your confirmed password.'; } else { $np = mysqli_real_escape_string($dbc, trim($_POST['pass1'])); } } else { $errors[] = 'you forgot to enter your a new password.'; } if (empty($errors)) { // if there are no errors // Check that they've enetered the right email address/password combination //make the query $q = "SELECT users_id FROM users_info WHERE (email='$e' AND pass=SHA1('$p') )"; $r = mysqli_query($dbc, $q); //@ $num = mysqli_num_rows($r); //@ if ($num == 1) { // match was made // get user_id $row = mysqli_fetch_array($r, MYSQLI_NUM); // make the UPDATE query $q = "UPDATE users_info SET pass=SHA1('$np') WHERE user_id=$row[0]"; $r = mysqli_query($dbc, $q); //@ if (mysqli_affected_rows($dbc) == 1) { // if it ran ok // print a message echo '<h3>Thank You!</h3> <p>Your password has been changed/updated.</p> <p><br /></p>'; } else { // if it did not run OK // public message echo '<h2>system error</h2> <p class="error"> your password could not be changed due to a system error. We apologize for any inconvenience.</p>'; //debugging msg echo '<p>' . mysqli_error($dbc) . '<br /><br />Query: ' . $q . '</p>'; } mysqli_close($dbc); // //close db connection include ('include/footer.html'); // include the footer and quit the script (to not show the form). exit(); } else { // Invalid email address/password combination - return error echo '<h1>Error!</h1> <p class="error">The email address and the password do not match those on file<p/>'; } } else { echo '<h1>Error!</h1> <p class="error">The following error(s) occurred:<br />'; foreach ($errors as $msg) { // print each error. echo " - $msg<br />\n"; } echo '</p><p>Please try again.</p><p><br /><p>'; } // end of if (empty($error)) IF. mysqli_close($dbc); // close database connection } // end of main submit conditional. ?> <h1>Change your password</h1> <form action="password.php" method="post"> <p>Email: <input type="text" name="email" size="19" maxlength="16" placeholder="email" value="<?php if (isset($_POST['email'])) echo $_POST['email']; ?>" /></p> <p>Current Password: <input type="password" name="pass" size="15" maxlength="10" placeholder="current" value="<?php if (isset($_POST['pass'])) echo $_POST['pass']; ?>" /></p> <p>New Password: <input type="password" name="pass1" size="15" maxlength="10" placeholder="password" value="<?php if (isset($_POST['pass1'])) echo $_POST['pass1']; ?>" /></p> <p>Confirm Password: <input type="password" name="pass2" size="15" maxlength="15" placeholder="re-password" value="<?php if (isset($_POST['pass2'])) echo $_POST['pass2']; ?>" /></p> <p><input type="submit" value="update/change" /></p> </form> <?php include ('include/footer.html'); ?>
  9. I have followed the book closely and looked over the code to make sure it matches Larry's. However, no matter what I do, I am not able to load the session into the database when I run the sessions.php file as per the book. I was hoping on some help to figure out what the issue is. I am running PHP 5.4.10 and Mysql 5.5.29. Thanks for the help in advance! ******This is my db_sessions.inc.php file:********* <?php # Script 3.1 - db_sessions.inc.php /* * This page creates the functional interface for * storing session data in a database. * This page also starts the session. */ // Global variable used for the database // connections in all session functions: $sdbc = NULL; //diff than DBC bc this is meant for sessions... make global for session connections (does not have to be and in fact would only use one in general so change code accordingly) function open_session() { global $sdbc; $sdbc = mysqli_connect( 'localhost', 'root', 'pass', 'advPHP' ) ; return true; //always return somethign except for read function (indicate success Boolean rather than just true) } function close_session() { global $sdbc; return mysqli_close( $sdbc ); } function read_session( $sid ) { global $sdbc; $q = sprintf( 'SELECT data FROM sessions WHERE id="%s"', mysqli_real_escape_string($sdbc, $sid) ); $r = mysqli_query( $sdbc, $q ); if( mysqli_num_rows($r) == 1) { list($data) = mysqli_fetch_array($r, MYSQLI_NUM); return $data; } else { return ''; } } function write_session($sid, $data) { global $sdbc; $q = sprintf( 'REPLACE INTO sessions (id, data) VALUES("%s", %s")', mysqli_real_escape_string($sdbc, $sid), mysqli_real_escape_string($sdbc, $data) ); $r = mysqli_query($sdbc, $q); return true; } function delete_session( $sid ) { global $sdbc; $q = sprintf( 'DELETE FROM sessions WHERE id="%s"', mysqli_real_escape_string($sdbc, $sid) ); $r = mysqli_query( $sdbc, $q ); $_SESSION = []; // return mysqli_affected_rows($sdbc) ; return true; } function clean_session($expire) { global $sdbc; $q = sprintf('DELETE FROM sessions WHERE DATE_ADD (last_accessed, INTERVAL %d SECOND) < NOW()', (int) $expire); $r = mysqli_query($sdbc, $q); return true; } session_set_save_handler( 'open_session', 'close_session', 'read_session', 'write_session', 'delete_session', 'clean_session' ); session_start(); ******And this is my sessions.php file******** <?php # Script 3.2 - sessions.php /* This page does some silly things with sessions. * It includes the db_sessions.inc.php script * so that the session data will be stored in a database. */ // Include the sessions file: // The file already starts the session. require('db_sessions.inc.php'); ?><!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>DB Session Test</title> <link rel="stylesheet" href="style.css"> </head> <body> <?php print_r($_SESSION); // Store some dummy data in the session, if no data is present: if( empty($_SESSION) ) { $_SESSION['blah'] = 'umlaut'; $_SESSION['this'] = 3615684.45; $_SESSION['that'] = 'blue'; echo '<p> Session data stored. </p>'; } else { echo '<p>Curren session contains <pre>' . print_r($_SESSION, 1) . '</pre> </p>'; } if( isset($_GET['logout']) ) { session_destroy(); echo '<p>Session destroyed.</p>'; } else { echo '<a href="sessions.php?logout=true"> Log Out </a>'; } echo '<p> Session data: <pre>' . print_r($_SESSION, 1) . '</pre></p>'; echo '</body> </html>'; session_write_close(); ?>
  10. Hello, This is a beginner's question regarding the "creating errors messages" (pp 381) and the "putting it all together" (pp 415). I'd appreciate if someone could clarify some of the code. In page 318, in the HTML after the paragraph "With that HTML, elem.parentNode refers to the DIV, so appending a new child results in: ..." 1) Shouldn't the span in this HTML have a class = 'error', which was assigned in step 4 ? 2) Why do we need to add a class = 'error' to the span and to the label anyway? I am assuming it is for changing the CSS but I don't see it used in the "Putting it all together" code of page 415. In page 415-420, "Putting it all together": 1) Why do we need the class = "two" in each DIV ? 2) How the CSS was manipulated to change the labels with error to red color. Thank you very much for your help.
  11. Hi there. I'm just having some trouble with the chapter 10 forms 'putting it all together' task. I created the register.js file as guided by the book, which has validation using regular expressions. However, when I load the form in a browser, and try to create some errors by incorrectly filling it in, I just get the generic HTML5 error messages, which say "Please fill out this field". I want the form to validate dynamically using the validateForm() function inside of register.js, not the standard HTML '<required>' validation. How can I make my form use these regular expression validations to give me the 'inline' errors using <span> which the book refers to on page 415, as opposed to the HTML5 errors? My code appears to be identical to the book, so I won't put my code in here unless it's necessary? Thanks
  12. Hi Larry In your book you create a my_error_handler which sends error messages to an e-mail address (and it works very well). Just one question - would it be possible in php to write the error message to a file and save it on the server? e.g. error0001.txt error0002.txt error0003.txt etc. etc
  13. Hello, I am keep getting this error, can any one help? [Warning]: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/datee0/public_html/prgsearch.php:1) in /home/datee0/public_html//init.php:0 Stack Dump: errorHandler(integer(2), string("session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/datee0/public_html/prgsearch.php:1)"), string("/home/datee0/public_html//init.php"), integer(0), array(array)) [/home/datee0/public_html//init.php:0] include(string("/home/datee0/public_html//init.php")) [/home/datee0/public_html/db_connect.php:96] include(string("/home/datee0/public_html/db_connect.php")) [/home/datee0/public_html/prgsearch.php:21]
×
×
  • Create New...