webcre8tor Posted October 1, 2012 Share Posted October 1, 2012 I bought the book after reading the reviews and because it's part of the peachpit collection, I thought it would be worth buying. I've read the first few chapters and am trying to start the first example ecommerce1. I'm not new to php and sql before you ask. I think the book is great and there's not much else to choose from on the internet, which is kinda surprising considering the amount of e-commerce websites. I've already touched on subjects that I didn't fully understand before reading this so definitely worth getting and is really a useful manual to have. Please could you tell where I'm going wrong. I think that it could be something to do with my username and password. I downloaded wamp and haven't adjusted any of the settings. I also renamed the path dir in config.inc.php to the following; define ('BASE_URI', 'C:/wamp/www/'); define ('BASE_URL', 'localhost/'); define ('PDFS_DIR', BASE_URI . 'pdfs/'); // Added in Chapter 5. define ('MYSQL', BASE_URI . 'mysql.inc.php'); I saved the files in the www directory which can be seen below. These are the errors I'm getting. Thanks URL: http://localhost/eco...s_ex1/ex1/html/ An error occurred in script 'C:\wamp\www\ecom_scripts_ex1\ex1\html\index.php' on line 15: require(C:/wamp/www/mysql.inc.php): failed to open stream: No such file or directory ( ! ) SCREAM: Error suppression ignored for ( ! ) Fatal error: require(): Failed opening required 'C:/wamp/www/mysql.inc.php' (include_path='.;C:\php\pear') in C:\wamp\www\ecom_scripts_ex1\ex1\html\index.php on line 15 Call Stack # Time Memory Function Location 1 0.0017 253992 {main}( ) ..\index.php:0 index.php line 15 require (MYSQL); URL: http://localhost/eco...1/mysql.inc.php ( ! ) Warning: mysqli_connect(): (HY000/1045): Access denied for user 'username'@'localhost' (using password: YES) in C:\wamp\www\ecom_scripts_ex1\ex1\mysql.inc.php on line 16 Call Stack # Time Memory Function Location 1 0.0016 255376 {main}( ) ..\mysql.inc.php:0 2 0.0017 256512 mysqli_connect ( ) ..\mysql.inc.php:16 ( ! ) Warning: mysqli_set_charset() expects parameter 1 to be mysqli, boolean given in C:\wamp\www\ecom_scripts_ex1\ex1\mysql.inc.php on line 19 Call Stack # Time Memory Function Location 1 0.0016 255376 {main}( ) ..\mysql.inc.php:0 2 0.0164 256744 mysqli_set_charset ( ) ..\mysql.inc.php:19 mysql.inc.php line 16 $dbc = mysqli_connect (DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); mysql.inc.php line 19 mysqli_set_charset($dbc, 'utf8'); Link to comment Share on other sites More sharing options...
margaux Posted October 1, 2012 Share Posted October 1, 2012 You don't really need to post the entire error message, especially when the first line tells you what the problem is: your script, mysql.inc.php cant be located. The BASE_URI constant needs to reflect where the files are stored. Link to comment Share on other sites More sharing options...
webcre8tor Posted October 2, 2012 Author Share Posted October 2, 2012 Ok fine, I changed the BASE_URI to C:/wamp/www/ecom_scripts_ex1/ex1/ and now I have other error messages URL : http://localhost/eco...s_ex1/ex1/html/ An error occurred in script 'C:\wamp\www\ecom_scripts_ex1\ex1\mysql.inc.php' on line 16: mysqli_connect(): (HY000/1045): Access denied for user 'username'@'localhost' (using password: YES) An error occurred in script 'C:\wamp\www\ecom_scripts_ex1\ex1\mysql.inc.php' on line 19: mysqli_set_charset() expects parameter 1 to be mysqli, boolean given An error occurred in script 'C:\wamp\www\ecom_scripts_ex1\ex1\html\index.php' on line 35: mysqli_query() expects parameter 1 to be mysqli, boolean given $r = mysqli_query($dbc, $q); An error occurred in script 'C:\wamp\www\ecom_scripts_ex1\ex1\html\includes\footer.html' on line 53: mysqli_query() expects parameter 1 to be mysqli, boolean given $r = mysqli_query($dbc, $q); An error occurred in script 'C:\wamp\www\ecom_scripts_ex1\ex1\html\includes\footer.html' on line 54: mysqli_fetch_array() expects parameter 1 to be mysqli_result, null given while (list($id, $category) = mysqli_fetch_array($r, MYSQLI_NUM)) { An error occurred in script 'C:\wamp\www\ecom_scripts_ex1\ex1\html\index.php' on line 54: mysqli_query() expects parameter 1 to be mysqli, boolean given $r = mysqli_query($dbc, $q); An error occurred in script 'C:\wamp\www\ecom_scripts_ex1\ex1\html\index.php' on line 55: mysqli_fetch_array() expects parameter 1 to be mysqli_result, null given while ($row = mysqli_fetch_array($r, MYSQLI_NUM)) { And http://localhost/eco...1/mysql.inc.php is the same Link to comment Share on other sites More sharing options...
webcre8tor Posted October 2, 2012 Author Share Posted October 2, 2012 It's ok I figured it out, default wamp settings, so just used the following in the mysql.inc.php file; // Set the database access information as constants: DEFINE ('DB_USER', 'root'); DEFINE ('DB_PASSWORD', ''); DEFINE ('DB_HOST', 'localhost'); DEFINE ('DB_NAME', 'ecommerce1'); Thanks Link to comment Share on other sites More sharing options...
webcre8tor Posted October 2, 2012 Author Share Posted October 2, 2012 ok everything works until I register and submit the form, getting the following error; An error occurred in script 'C:\wamp\www\ecom_scripts_ex1\ex1\html\register.php' on line 115: mail(): Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() register.php line 115 mail($_POST['email'], 'Registration Confirmation', $body, 'From: admin@example.com'); And when I forget the password the following error occurs; An error occurred in script 'C:\wamp\www\ecom_scripts_ex1\ex1\html\forgot_password.php' on line 54: mail(): Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() forgot_password.php line 54 mail ($_POST['email'], 'Your temporary password.', $body, 'From: admin@example.com'); Obviously this will effect the change_password.php file. Making it impossible for the user to log back in once the password has been changed. What should I do there? Link to comment Share on other sites More sharing options...
Larry Posted October 3, 2012 Share Posted October 3, 2012 You need to enable and configure your mail server. Link to comment Share on other sites More sharing options...
Recommended Posts