Jump to content
Larry Ullman's Book Forums


  • Posts

  • Joined

  • Last visited

Doc's Achievements


Newbie (1/14)



  1. Larry, I ordered the latest version of your book. From Amazon's "Look inside" feature, I'm sure it will answer my MySQLi questions (not sure if it delves into PDO, which would be a great thing for you to cover -- do you do it in the 4th edition or elsewhere?). In pondering this, I think you are missing a golden opportunity. You excel as an author (hence why I've bought several of your books), but you could be a titan of the computer world by offering a service I've never before heard of (and never imagined possible until a few minutes ago), for which there would be tremendous demand. If I have time, I might code a demo of it this winter.
  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. I am still confused about what exact PHP code to use to get the column type into a string.
  4. I want to change various column names using: ALTER TABLE tablename CHANGE COLUMN oldname newname columntype; This is easy except for the last part (columntype). It seems silly to need to specify that since I don't want to change the column TYPE, only its name, but from what I've read, specifying columntype is mandatory. I need automated code, not show the table and manually view the columntype and manually input that. Thus I'd appreciate code that gives me $columntype. Thank you!
  5. Thanks, Larry, that solved the problem. I'd previously implemented the exact changes you suggested, using date_default_timezone_set('America/New_York'); and nothing above it, but it originally did not work for well over a month. In retrospect, I suspect the problem resulted from the 1and1.com server -- one of MANY they have -- but they evidently fixed it. I told them of the error but they initially dismissed my report, which is characteristic of them. BTW, if you ever start a web hosting company, I'd be your first customer and gladly pay several times what I'm paying 1and1. There must be many people like me who are frustrated with the ineptness and poor support of the major web hosting companies.
  6. After my web hosting company (1and1.com) switched from PHP 4 to 5, a script that once returned the current year A-OK no longer works; it now generates this error message that is e-mailed to me every time a page bearing this include is accessed: An error occurred in script '----------/includes/footer.php' on line 4: <br />date_default_timezone_get() [<a href='function.date-default-timezone-get'>function.date-default-timezone-get</a>]: It is not safe to rely on the system's timezone settings. Please use the date.timezone setting, the TZ environment variable or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/New_York' for 'EST/-5.0/no DST' instead <br />Date/Time: 1-30-2013 07:51:12 <br /><pre>Array .... Here is the code, including some changes I thought should correct the error or at least suppress the error messages: <?php if(function_exists("date_default_timezone_set") and function_exists("date_default_timezone_get")) @date_default_timezone_set(@date_default_timezone_get()); // date_default_timezone_set('America/New_York'); $startyear = 2009; $currentyear = date("Y"); if ($startyear == $currentyear) { echo 'Copyright © 2009'; } else { echo 'Copyright © 2009 - ' . $currentyear; } ?> How can I fix this error?
  • Create New...