MikeFromRehobothBeach Posted November 8, 2013 Share Posted November 8, 2013 Hi Larry, I am running Xampp v3.1.0.3.1.0 in Windows 7Mozilla/5.0(compatable; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0.Apache/2.4.3 (Win32) OpenSSL/1.0.1cPHP/5.4.7. My username for MySQL is 'root' and my password is ''.That is how my instructor helped us configure our MySQL (I assume that prevented us from creating a password we would forget)last spring and I haven't changed it.We had a terrible textbook(not yours), and our PHP class was not optimal.I have since graduated, but want to become proficient enough in PHP and other languages to eventually make a living using them.I have been frustrated by the quirks of xampp and related issues, but need to master this before I can justify purchasing a server, etc. and doing it right. When I run this script on page 269, "PHP and MySQL for Dynamic Web Sites, 4th edition", I get this error message. http://localhost/mysqli_connect.php <?php # Script 9.2 - mysqli_connect.php // This file contains the database access information. // this file also establishes a connection to MySQL, // selects the database, and sets the encoding. // Set the database access information as constants:DEFINE ('DB_USER', 'root');DEFINE ('DB_PASSWORD', '');DEFINE ('DB_HOST', 'localhost');DEFINE ('DB_NAME', 'sitename'); // Make the connection:$dbc = @mysqli_connect (DB_HOST, DB_USER, DB_PASSWORD, DB_NAME) OR die ('Could not connect to MySQL: ' . mysqli_connect_error() ); // Set the encoding ...mysql_set_charset($dbc, 'utf8'); Message: Warning: mysql_set_charset() expects parameter 1 to be string, object given in C:\xampp\htdocs\mysqli_connect.php on line 18 I have inserted and removed single and double quotes throughout the script.I have placed the script in the htdocs file, where it runs, and outside the htdocs file, where it is not found through localhost. If I comment out the ... /* // Set the encoding ... mysql_set_charset($dbc, 'utf8'); */ I get a blank page, as it should appear, I believe. I have hundreds of questions, but will limit them to these.If I leave this in my htdocs and comment out the 'mysqli_set_charset' as above, will I be able to complete the text book and have working scripts? I understand that in real life, with a live server, this is not optimal.Hopefully, once I master PHP enough to make an e-commerce site run and have a server with Apache on it, not xampp, I will be able to configure my files correctly and in a safe manner. I believe there are only a few instances of the charset being different than utf-8 in our files for this textbook.Can I run the script as is and maybe remove the comments when I get a flukey answer? Do I need to upgrade to the latest versions of PHP and MySQL and start from scratch? MikeFromRehobothBeach. Link to comment Share on other sites More sharing options...
HartleySan Posted November 8, 2013 Share Posted November 8, 2013 Hello, and welcome to the forums. Try using the mysqli_set_charset function instead of the mysql_set_charset function (note the i after mysql), and let us know if that helps. Thanks. Link to comment Share on other sites More sharing options...
MikeFromRehobothBeach Posted November 8, 2013 Author Share Posted November 8, 2013 Hi, mysqli was the trick. I think that I did see somewhere in my quest that 'mysql_set_charset' was deprecated in newer versions. I now have a beautiful blank page! Thanks, MikeFromRehobothBeach Link to comment Share on other sites More sharing options...
HartleySan Posted November 8, 2013 Share Posted November 8, 2013 Nothing like a beautifully blank page that is devoid of errors. Good luck from here on out (and don't be shy around the forums if you encounter any other issues). Link to comment Share on other sites More sharing options...
Larry Posted November 8, 2013 Share Posted November 8, 2013 Thanks for the help, Hartley! (By the way, spent many fun days at Rehoboth Beach myself!) Link to comment Share on other sites More sharing options...
Recommended Posts