Jump to content
Larry Ullman's Book Forums

Artemis

Members
  • Posts

    17
  • Joined

  • Last visited

Everything posted by Artemis

  1. Hello everyone, My boss has two websites -- one of which they wanted me to clone to replace the other. They are on two different servers. They had me transfer the website files, reconfigure to a new database on a new server, and then make cosmetic changes. However, I am finding that none of the links on the clone (apart from the home page) actually work. For instance, if you click "What's New" this should link to the Who We Are page. The URL it links to is: /who-we-are (without any php extension). There is a .php file on public_html that is titled "who-we-are.php." The absence of an extension in the URL made me think there was an .htaccess file, and there was: [/color][/color][/font][/size] Options -MultiViews Options +FollowSymLinks RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d #RewriteRule ^(.*)$ $1.php [L,QSA] RewriteRule ^search([\/]?)$ index.php?option=collection-products&section=collection&%{QUERY_STRING} [L,QSA] RewriteRule ^page\/([a-zA-Z0-9_-]+)([\/]?)$ index.php?option=pages&url=$1&%{QUERY_STRING} [L,QSA] RewriteRule ^product\/([a-zA-Z0-9_-]+)\/([a-zA-Z0-9_-]+)([\/]?)$ index.php?option=product&category=$1&producturl=$2&%{QUERY_STRING} [L,QSA] RewriteRule ^products\/([a-zA-Z0-9_-]+)([\/]?)$ index.php?option=collection-products&section=collection&productcat=$1&%{QUERY_STRING} [L,QSA] RewriteRule ^products\/([a-zA-Z0-9_-]+)\/([a-zA-Z0-9_-]+)([\/]?)$ index.php?option=collection-products&section=collection&category=$1&productcat=$2&%{QUERY_STRING} [L,QSA] RewriteRule ^products\/([a-zA-Z0-9_-]+)\/([a-zA-Z0-9_-]+)\/([a-zA-Z0-9_-]+)([\/]?)$ index.php?option=collection-products&category=$1&section=collection&subcategory=$2&productcat=$3&%{QUERY_STRING} [L,QSA] RewriteRule ^collection\/([a-zA-Z0-9_-]+)([\/]?)$ index.php?option=collection&section=collection&category=$1&%{QUERY_STRING} [L,QSA] RewriteRule ^collection\/([a-zA-Z0-9_-]+)\/([a-zA-Z0-9_-]+)([\/]?)$ index.php?option=collection&section=collection&category=$1&subcategory=$2&%{QUERY_STRING} [L,QSA] #RewriteRule ^detail\/([a-zA-Z0-9_-]+)\/([a-zA-Z0-9_-]+)([\/]?)$ index.php?option=cat_page_more&section=$1&category=$2&%{QUERY_STRING} [L,QSA] #RewriteRule ^philanthropy([\/]?)$ index.php?option=our-work&section=philanthropy&&%{QUERY_STRING} [L,QSA] RewriteRule ^philanthropy\/([a-zA-Z0-9_-]+)([\/]?)$ index.php?option=cat_pages&section=philanthropy&category=$1&%{QUERY_STRING} [L,QSA] RewriteRule ^philanthropy\/([a-zA-Z0-9_-]+)\/([a-zA-Z0-9_-]+)([\/]?)$ index.php?option=cat_page_detail&section=philanthropy&category=$1&pageurl=$2&%{QUERY_STRING} [L,QSA] RewriteRule ^our-work\/([a-zA-Z0-9_-]+)([\/]?)$ index.php?option=cat_pages&section=our-work&category=$1&%{QUERY_STRING} [L,QSA] RewriteRule ^our-work\/([a-zA-Z0-9_-]+)\/([a-zA-Z0-9_-]+)([\/]?)$ index.php?option=cat_page_detail&section=our-work&category=$1&pageurl=$2&%{QUERY_STRING} [L,QSA] RewriteRule ^([a-zA-Z0-9_-]+)\/([a-zA-Z0-9_-]+)([\/]?)$ index.php?option=cat_page_detail&section=$1&pageurl=$2&%{QUERY_STRING} [L,QSA] RewriteRule ^our-services([\/]?)$ index.php?option=cat_pages&section=our-services&%{QUERY_STRING} [L,QSA] #RewriteRule ^philanthropy([\/]?)$ index.php?option=cat_pages&section=philanthropy&%{QUERY_STRING} [L,QSA] RewriteRule ^conceptual-gift-design([\/]?)$ index.php?option=cat_pages&section=conceptual-gift-design&%{QUERY_STRING} [L,QSA] #RewriteRule ^our-services\/([a-zA-Z0-9_-]+)([\/]?)$ index.php?option=cat_page_detail&section=our-services&pageurl=$1&%{QUERY_STRING} [L,QSA] #RewriteRule ^our-work([\/]?)$ index.php?option=collection&section=our-work&%{QUERY_STRING} [L,QSA] RewriteRule ^([a-zA-Z0-9_-]+)([\/]?)$ index.php?option=$1&%{QUERY_STRING} [L,QSA] It references a symlink. On the original website, there are two symlinks in the root/ folder (not public_html) that are titled: www -> public_html; and then another called, access_logs -> ../domlogs/artmorp1. I assume I need to add the symlinks to the new server for the new site, but can anyone help me understand what is actually going on in this situation? It would help if you could point out what the problem with the clone, and give me suggestions as to how to fix it. Many thanks.
  2. Hi, this is a general question based on the user registration scripts found in the back of this book. I was trying to create a single page which could call login.php and registration.php via includes() at the beginning of index.php; and then have two areas on a single page where the user could either sign up and be taken to the activation page, or where the user could login and be taken to the backend. Is there a way to do this on a single page without having to cut and paste the entirety of the two scripts (login and registration) into index.php? Is this how includes() can be used? Any advice would be welcome and appreciated.
  3. Hi Larry, Can't thank you enough for that. I will email it to you as soon as I get back to my laptop.
  4. Hello! I hope it's alright if I have different questions about the same project. I am trying hard to try and debug these myself, but being a noob every now and then I run into a wall. I am trying to create a small user network to learn how it's done. Right now, I am working out how to add a "Add User" button to each user's profile, so if user A is viewing user B's profile, he can click the button and add the user. Now, by itself, my PHP code is fine. However, I wanted to use AJAX so a user can click on a button without taking them to a separate page and the add script (the actual insertion of a friendship into the database) can occur without anything happening on the screen aside from a small notice or something. I am using this code, but I am finding that the link does not run the script but instead goes to #. How do I prevent this? In the header I have referenced the source like this: <script type="text/javascript" src="jquery.min.js"></script> On the actual page with the user profile, the add button is here, with the AJAX before it. <script type="text/javascript"> document.getElementByID('add.php').onclick = function() { return false; } </script> <a href="#" id="add.php">Add me!</a> However it does not execute the php script, it only links to #. Any help is gratefully received. Many thanks for all the previous advice =)
  5. Hello! Thank you for your replies. I added the closing tag, which must have been erased in the furious deletion and insertion, and no luck. This is what I am trying to do so it is clear: the long script is essentially what will display a user profile in a larger community forum. The first three if statements refer to using $_GET to retrieve the right profile information from the URL's specification of the member ID... so that doesn't have anything to do with the problem. Essentially, what I am trying to do is to insert a code in here that will also allow the person whose profile it is to be able to upload a photo as well when they are viewing their own profile. I would really appreciate any help.
  6. Hi there! Thanks for your comment -- could you perhaps point me to which exact parts of my code you're referring to? I see that I'm posting the image data, but which GET superglobal am I using? Or am I missing something here?
  7. Hello there, Just wanted to tinker with it before I asked any more questions. The error messages disappeared when I changed the image upload script to this (where if (isset($_POST['image'])) was not there before). I am well and truly confused now, because nothing seems to indicate what the problem is at all. if (isset($_POST['image'])) { if (is_uploaded_file($_FILES['image']['tmp_name'])) { // Create a temporary file name... $temp = 'uploads/' . md5($_FILES['image']['name']); // Move the file over... if (move_uploaded_file($_FILES['image']['tmp_name'], $temp)) { $i = $_FILES['image']['name']; } else { } } else { } } When I say that the echo statements didn't do anything, all that happens when I try and upload something is the page refreshes back to user.php. Nothing happens, even if I try to echo every statement out. I have also tried to: 1. Make sure the user.php (long script) works perfectly without any notices before I add in the image handling code. Everything seems fine. 2. Make sure that the image.php works perfectly without any notices (which it does and it uploads to the folder). It's only when I add the image handling code to the long script that it suddenly doesn't work. However, I tried using only this code to see if anything was actually being posted at all: if (isset($_POST['image'])) { echo 'Image submitted'; } else { } And all that happened was the page user.php refreshed itself blank without any errors. Is there some problem then with actually getting the image to be posted? Many thanks for your help...
  8. Hi again, And thanks for the replies. I have tried to debug in two ways: 1. I applied error_reporting('E_ALL') to the top of both the long/short script; and it printed the following notices: a. Undefined index: image in .../users.php (this is the long script) b. Undefined variable: id in .../users.php (this refers to the if (isset($_SESSIONS('user_id'))) However only the first notice comes up in the image.php script as well, which uploads to the directory perfectly. 2. I tried to echo out each 'if' like so (and nothing came out of this either). You can see that this code is a bit different from the one used in the scripts above (essentially I just moved the $_SESSIONS echo command a bit lower to apply only to the form being shown). <?php // Check that a file was uploaded... if (is_uploaded_file($_FILES['image']['tmp_name'])) { echo 'File uploaded!'; // Create a temporary file name... $temp = 'uploads/' . md5($_FILES['image']['name']); // Move the file over... if (move_uploaded_file($_FILES['image']['tmp_name'], $temp)) { echo 'File moved!'; $i = $_FILES['image']['name']; } else { echo 'File could not be moved!'; } } else { echo 'No file has been uploaded'; } if (isset($_SESSION['user_id']) == $id) { echo ' <form enctype="multipart/form-data" action="user.php" method="post"> <input type="hidden" name="MAX_FILE_SIZE" value="524288" /> <p>Upload your photograph! <input type="file" name="image" /> <input type="submit" name="submit" value="Upload"/> <input type="hidden" name="submitted" value="TRUE"/> ' ;} ?> I'm a bit stumped! Thanks for the help and apologies for not indicating what I'd done to remedy it beforehand.
  9. Hello again! I am designing a small community for people online, and I wanted an image upload function for avatars. Naturally I referenced Larry's book and found the image upload code to help me along on my project. I first used the following code in its own right, and it uploaded the file directly to the uploads file indicated on my server. However, when I pasted the code into the script (having changed the form action to the new script's name) the image upload function stops working meaning it does not upload any file to the uploads folder. I don't know why this would happen because I don't touch the code for the upload aside from changing the form action from action="image.php" (the image upload script alone) to action="user.php" (a user edit page). Could anybody point out what I might be doing wrong here? I'm a noob so I apologise if the answer is obvious. Many thanks for all of your help! Code for the image upload script by itself (which works and uploads the file to the server) is: <?php // Check that a file was uploaded... if (is_uploaded_file($_FILES['image']['tmp_name'])) { // Create a temporary file name... $temp = 'uploads/' . md5($_FILES['image']['name']); // Move the file over... if (move_uploaded_file($_FILES['image']['tmp_name'], $temp)) { $i = $_FILES['image']['name']; } else { } } else { } echo ' <form enctype="multipart/form-data" action="user.php" method="post"> <input type="hidden" name="MAX_FILE_SIZE" value="524288" /> <p>Upload your photograph! <input type="file" name="image" /> <input type="submit" name="submit" value="Upload"/> <input type="hidden" name="submitted" value="TRUE"/> ' ?> The code which does not and is part of a larger script is the following: <?php // user.php // Include the essential files required for the profile, whether it is displayed or not... include ('includes/header.html'); // Connect to the database. require_once('mysqli_connect.php'); // Which user are we looking at? if (isset($_GET['user_id']) && is_numeric($_GET['user_id'])) { // Does the ID exist in the $_GET array? $id = (int) $_GET['user_id']; if ($id > 0) { // If the ID is greater than 1, then run the query. $q = "SELECT * FROM users WHERE user_id='$id' LIMIT 1"; $r = mysqli_query($dbc, $q); } if (mysqli_num_rows($r) == 1) { // If the query brings back the row, then store it in the row array. $row = mysqli_fetch_array ($r, MYSQLI_ASSOC); // Make sure the first name and last name are uppercase when displayed... $fn = $row['first_name']; $fn = ucfirst($fn); $ln = $row['last_name']; $ln = ucfirst($ln); } ?> <!-- Add the wrapper --> <div class="wrapper"> <!-- Add the header for the user --> <div class="header_user"> </div> <!-- The div for content --> <div class="content"> <!-- The div for middle --> <div class="middle"> <!-- The div for photo --> <div class="photo"> <!-- End photo --> </div> <!-- The div for info --> <div class="info"> <h1><?php echo "{$fn} {$ln}"?></h1> <?php if (isset($_SESSION['user_id']) == $id) // Check that a file was uploaded... if (is_uploaded_file($_FILES['image']['tmp_name'])) { // Create a temporary file name... $temp = 'uploads/' . md5($_FILES['image']['name']); // Move the file over... if (move_uploaded_file($_FILES['image']['tmp_name'], $temp)) { $i = $_FILES['image']['name']; } else { } } else { } echo ' <form enctype="multipart/form-data" action="profile.php" method="post"> <input type="hidden" name="MAX_FILE_SIZE" value="524288" /> <p>Upload your photograph! <input type="file" name="image" /> <input type="submit" name="submit" value="Upload"/> <input type="hidden" name="submitted" value="TRUE"/> ' ?> <!-- End info --> </div> <!-- End middle --> </div> <!-- End content --> </div> <!-- End wrapper --> </div> <?php ; } ?> Any help would be very much appreciated...
  10. Hello! Sorry to reply to your posts so late, but I'm very thankful for your feedback and implemented both a Java/PHP validation system on the site...
  11. Hi again! I took your advice and downloaded a generic JavaScript validator from a website as I'm not familar enough with it to do all the coding myself. The Java works in terms of validation and I thought it could be integrated with the PHP, which would handle the submit function and pass the info along to the database. But that's not happening. Any idea why? New code below and you can see what the page is doing if you visit forensicoutreach.com'signup.php. Any help is appreciated... <?php // signup.php // Include the configuration file and the HTML header. require_once('includes/config.inc.php'); $page_title = 'Sign up'; include('includes/header.html'); // Create the conditional that checks for form submission + database connection script. if (isset($_POST['submitted'])) { require_once('includes/mysqli_connect.php'); // Trim the incoming data and set some flag variables. $trimmed = array_map('trim', $_POST); $fn = $ln = $e = $p = FALSE; $fn = FALSE; $ln = FALSE; $e = FALSE; $p = FALSE; // Is this a unique email address? if ($fn && $ln && $e && $p) { $q = "SELECT user_id FROM users WHERE email='$e'"; $r = mysqli_query ($dbc, $q) or trigger_error("Query: $q\n<br/>MYSQL Error: " . mysqli_error($dbc)); // If the email address is unused, register the user: if (mysqli_num_rows($r) == 0) { $a = md5(uniqid(rand(), true)); $q = "INSERT INTO users (email, pass, first_name, last_name, active, registration_date) VALUES ('$e', SHA1('$p'), '$fn', '$ln', '$a', NOW() )"; $r = mysqli_query($dbc, $q) or trigger_error("Query: $q\n<br />MySQL Error:" . mysqli_error($dbc)); // Send an email if the query worked. if (mysqli_affected_rows($dbc) == 1) { $body = " Welcome to Forensic Outreach. To activate your account, please click here:\n\n"; $body .= BASE_URL . 'activate.php?x=' . urlencode($e) . "&y=$a"; mail($trimmed['email'], 'Welcome to Forensic Outreach', $body, 'From: admin@forensicoutreach.com'); ob_end_clean(); $url = BASE_URL . 'success.php'; header("Location: $url"); include ('includes/footer.html'); exit(); // Print errors if the query failed. } else { $error[] = '<p>You could not be registered. Please try again<p>'; } } else { $error[] = '<p>This email address has already been registered.<p>'; } } else { $error[] = '<p>Please reenter your passwords and try again.<p>'; } mysqli_close($dbc); } // End of the main submit conditional. ?> <title>Sign Up</title> <div class="content"> <div class="leftc"> <h1>Sign Up</h1> <h2>Start downloading worksheets, lesson plans and more.</h2> <p>Already signed up? <a href="login.php"><strong>Login</strong></a> now. <div class="leftcolc"> </div> <div class="leftcolc"> <h2>It's easy and free.</h2> <!-- Script for a login form --> <form action="signup.php" method="post" form id ="signup"><fieldset> <p class="form"><label for='first_name'>first name</label></p> <input type="text" name="first_name" size="20" maxlength="20" value="<?php if (isset($trimmed['first_name'])) echo $trimmed['first_name'];?>"/></p> <p class="form"><label for='last_name'>last name</label></p> <input type="text" name="last_name" size="20" maxlength="40" value="<?php if (isset($trimmed['last_name'])) echo $trimmed['last_name'];?>"/></p> <p class="form"><label for='email'>email</label></p> <input type="text" name="email" size="20" maxlength="80" value="<?php if (isset($trimmed['email'])) echo $trimmed['email'];?>"/></p> <p class="form"><label for="password1">password</label></p> <input type="password" name="password1" size="20" maxlength="20"/></p> <p class="form"><label for="password2">confirm password</label></p> <input type="password" name="password2" size="20" maxlength="20"/></p> <p><input type="submit" name="submit" value="Sign Up" /> <input type="hidden" name="submitted" value="TRUE" /> </fieldset> </form> <script type="text/javascript"> var frmvalidator = new Validator("signup"); frmvalidator.addValidation("first_name","req","Please enter your first name."); frmvalidator.addValidation("first_name","maxlen=20", "Enter a name less than 20 characters"); frmvalidator.addValidation("first_name","alpha", "Only alphabetic characters are allowed."); frmvalidator.addValidation("last_name","req", "Please enter your last name."); frmvalidator.addValidation("last_name","maxlen=40", "Enter a surname less than 40 characters."); frmvalidator.addValidation("last_name","alpha", "Only alphabetic characters are allowed."); frmvalidator.addValidation("email","maxlen=50", "The required email length is less than 50 characters."); frmvalidator.addValidation("email","req", "Please enter your email address."); frmvalidator.addValidation("email","email", "Please enter a valid email address."); frmvalidator.addValidation("password1","maxlen=20", "The required password length is less than 20 characters."); frmvalidator.addValidation("password1","req", "Please enter a password."); frmvalidator.addValidation("password1","alphanumeric", "Passwords can only contain numbers and letters."); frmvalidator.addValidation("password1", "eqelmnt=password2", "The confirmed password does not match the password."); frmvalidator.EnableOnPageErrorDisplaySingleBox(); frmvalidator.EnableMsgsTogether(); </script> </div> <div class="leftcolc"> <p> <div id='signup_errorloc'></div> </div> <!--/content --> </div> <!--footer --> <?php include('includes/footer.html'); ?> </div>
  12. Hi Stuart, Thanks again for all of your help. I'm pretty good with XHTML/CSS but I'm slowly learning how to make sites dynamic -- and thereby deal with JavaScript and PHP. I will look into using JavaScript as well for validation as it seems to make sense to do so. Thanks for the compliment as well!
  13. Hello again! I've tried to implement your suggestions and basically created this statement to print the $errors array. <?php if (empty($error)) { echo '' ; } else { for ($error = 1; $error < count($error); $error++) { print $error; } } ?> Needless to say, it's not working. I tried writing just the if statement first to check if the array was empty, and that bit worked when I just asked it to print "Empty" or "Not Empty." Then my approach was to add the for look you suggested to print the array, and that's where I'm really stuck, because it's not printing them. Do you have any more suggestions? Any help would be appreciated!
  14. Hello! Another post about the site I'm developing. Essentially I have adapted the login.php script and register.php (which I call signup.php) to use on my website. The messages that come up if you forget to type in your email, password; enter an invalid password; or enter passwords that don't match, appear the same as they would in the book if you were to attempt to sign up. See what happens here: forensicoutreach.com/signup.php. But as you can see, it does not fit in the with the look of the site and they kind of float right underneath the nav bar. How could I change this so that the messages fit in neatly with the look of the site? Perhaps so I can have them appear right next to the fields that are incomplete or invalid? You can look at my HTML/CSS of course by viewing the source. The code I used for the signup page appears below. Many thanks for your help! Amazing forum and moderators. <?php // signup.php // Include the configuration file and the HTML header. require_once('includes/config.inc.php'); $page_title = 'Sign up'; include('includes/header.html'); // Create the conditional that checks for form submission + database connection script. if (isset($_POST['submitted'])) { require_once('includes/mysqli_connect.php'); // Trim the incoming data and set some flag variables. $trimmed = array_map('trim', $_POST); $fn = $ln = $e = $p = FALSE; $fn = FALSE; $ln = FALSE; $e = FALSE; $p = FALSE; // Validate the first and last names. if (preg_match ('/^[A-Z \'.-]{2,20}$/i', $trimmed['first_name'])) { $fn = mysqli_real_escape_string($dbc, $trimmed['first_name']); } else { echo '<p>Please enter your first name.</p>'; } if (preg_match ('/^[A-Z \'.-]{2,40}$/i', $trimmed['last_name'])) { $ln = mysqli_real_escape_string($dbc, $trimmed['last_name']); } else { echo '<p>Please enter your last name.</p>'; } // Validate the email address. if (preg_match ('/^[\w.-]+@[\w.-]+\.[A-Za-z]{2,6}$/', $trimmed['email'])) { $e = mysqli_real_escape_string($dbc, $trimmed['email']); } else { echo '<p>Please enter your email address.</p>'; } // Validate the passwords. if (preg_match ('/^\w{4,20}$/', $trimmed['password1']) ) { if ($trimmed['password1'] == $trimmed['password2']) { $p = mysqli_real_escape_string ($dbc, $trimmed['password1']); } else { echo '<p>Your passwords did not match.</p>'; } } else { echo '<p>You have entered an invalid password.</p>'; } // Is this a unique email address? if ($fn && $ln && $e && $p) { $q = "SELECT user_id FROM users WHERE email='$e'"; $r = mysqli_query ($dbc, $q) or trigger_error("Query: $q\n<br/>MYSQL Error: " . mysqli_error($dbc)); // If the email address is unused, register the user: if (mysqli_num_rows($r) == 0) { $a = md5(uniqid(rand(), true)); $q = "INSERT INTO users (email, pass, first_name, last_name, active, registration_date) VALUES ('$e', SHA1('$p'), '$fn', '$ln', '$a', NOW() )"; $r = mysqli_query($dbc, $q) or trigger_error("Query: $q\n<br />MySQL Error:" . mysqli_error($dbc)); // Send an email if the query worked. if (mysqli_affected_rows($dbc) == 1) { $body = " Welcome to Forensic Outreach. To activate your account, please click here:\n\n"; $body .= BASE_URL . 'activate.php?x=' . urlencode($e) . "&y=$a"; mail($trimmed['email'], 'Welcome to Forensic Outreach', $body, 'From: admin@forensicoutreach.com'); ob_end_clean(); $url = BASE_URL . 'success.php'; header("Location: $url"); include ('includes/footer.html'); exit(); // Print errors if the query failed. } else { echo '<p>You could not be registered.</p>'; } } else { echo '<p>Email has already been registered.</p>'; } } else { echo '<p>Please reenter your passwords and try again.</p>'; } mysqli_close($dbc); } // End of the main submit conditional. ?> <title>Sign Up</title> <div class="content"> <div class="leftc"> <h1>Sign Up</h1> <h2>Start downloading worksheets, lesson plans and more.</h2> <p>Already signed up? <a href="login.php"><strong>Login</strong></a> now. <div class="leftcolc"> </div> <div class="leftcolc"> <h2>It's easy and free.</h2> <!-- Script for a login form --> <form action="signup.php" method="post" ><fieldset> <p class="form">first name</p> <input type="text" name="first_name" size="20" maxlength="20" value="<?php if (isset($trimmed['first_name'])) echo $trimmed['first_name'];?>"/></p> <p class="form">last name</p> <input type="text" name="last_name" size="20" maxlength="40" value="<?php if (isset($trimmed['last_name'])) echo $trimmed['last_name'];?>"/></p> <p class="form">email</p> <input type="text" name="email" size="20" maxlength="80" value="<?php if (isset($trimmed['email'])) echo $trimmed['email'];?>"/></p> <p class="form">password</p> <input type="password" name="password1" size="20" maxlength="20"/></p> <p class="form">confirm password</p> <input type="password" name="password2" size="20" maxlength="20"/></p> <p><input type="submit" name="submit" value="Sign Up" /> <input type="hidden" name="submitted" value="TRUE" /> </fieldset> </form> </div> <div class="leftcolc"> </div> <!--/content --> </div> <!--footer --> <?php include('includes/footer.html'); ?>
  15. Hi Stuart! Yes that was the problem. Sometimes the obvious isn't! Many thanks to both of you for your responses.
  16. Hello! I'm building a website for a small business and have tried to adapt the scripts in Chapter 16 to create a "members/users" area through which they can access otherwise locked resources. The log-in page can be found here: www.forensicoutreach.com/members.php. You will find on the website the error: Parse error: syntax error, unexpected T_REQUIRE in /websites/LinuxPackage02/fo/re/ns/forensicoutreach.com/public_html/members.php on line 3. However, I cannot locate anything wrong with any of the included files or the functions I am using. In members.php (analogous to index.php in the book): <?php - index.php require_once('includes/config.inc.php'); include('includes/header.html'); ?> In config.in.php: <?php - config.inc.php // Establish two constants for error reporting. define('LIVE', FALSE); define('EMAIL', 'myemail@hotmail.com'); // Establish two constants for site-wide settings. define('BASE_URL', 'http://www.forensicoutreach.com/'); define ('MYSQL', 'mysqli_connect.php'); // Establish other site-wide settings. date_default_timezone_set ('Europe/London'); // Begin defining the error-handling function. function my_error_handler ($e_number, $e_message, $e_file, $e_line, $e_vars) { $message = "<p>An error occurred in script '$e file' on line $e_line: $e_message\n<br />"; $message .= "Date/Time:" . date('n-j-Y H:i:s') . "\n<br />"; $message .= "<pre>" . print_r($e_vars, 1) . "</pre>\n</p>"; // Handle the error according to the value of LIVE. if (!LIVE) { echo '<div class="error">' . $message . '</div><br />'; } else { mail(EMAIL, 'Site Error!', $message, 'From: email@example.com'); if ($e_number != E_NOTICE) { echo '<div class="error">A system error occurred. We apologise for the inconvenience. </div><br />'; } } } set_error_handler ('my_error_handler'); ?> And finally, in mysqli_connect (with host/password/database removed): <?php - mysqli_connect.php // This file contains the database access information. // This file also establishes a connection to MySQL // and selects the database. // Set the database access information as constants: DEFINE ('DB_USER', 'ufor_250520_0003'); DEFINE ('DB_PASSWORD', 'PASSWORD'); DEFINE ('DB_HOST', 'HOST'); DEFINE ('DB_NAME', 'DATABASE'); // Make the connection: $dbc = @mysqli_connect (DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); if (!$dbc) { trigger_error ('Could not connect to MySQL: ' . mysqli_connect_error() ); } ?> Can anyone see what's wrong here? I am using PHP version 5.2.6 and additional information is at forensicoutreach.com/phpinfo.php. Thanks very much for your help in advance!
×
×
  • Create New...