Jump to content
Larry Ullman's Book Forums

Search the Community

Showing results for tags 'php'.

  • 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


  1. I created a script that uses the pagination example in the book, and what is happening is that, I have 8 results, if I set the $display variable at 7. I should get a page number to the second page that has the eighth result. But I don't get that, instead it totally ignores the 8th result. I looked at the code and thought the problem might be where it says $pages = ceil($records/$display), because it rounds it off, maybe that's why I lose a result. Any idea what could be causing the problem, it is the main pagination script in the book. Maybe I have an error, but after looking for hours I can't find it. $q = "SELECT COUNT(i.invention_id), c.category_id FROM inventions AS i INNER JOIN categories AS c USING (category_id) WHERE category_id = $cat"; $r = @mysqli_query ($dbc, $q); $row = @mysqli_fetch_array ($r, MYSQLI_NUM); $records = $row[0]; // Calculate the number of pages... if ($records > $display) { // More than 1 page. $pages = ceil($records/$display); } else { $pages = 1; }
  2. After reading this book and practicing, I am creating a site that has more than one main logo, I want them to alternate when the page changes to another page or is refreshed. So I thought of using the ternary operator, but I can't get it to work. Since there is no while loop involved in my header page where this code will go, I guess that's why it doesn't work. I got it to work with php's shuffle function, but that doesn't create the effect I want exactly. Anyways here is where I am at with this, any help to get this working would be appreciated. <header> $imglogo1 = '<img src="images/logo5214.jpg" alt="logo" class="logo2">'; $imglogo2 = '<img src="images/logo5213.jpg" alt="logo" class="logo2">'; $bg = $imglogo1; $bg = ($bg==$imglogo1 ? $imglogo2 : $imglogo1); </header>
  3. I want to display images on my page from a folder called forumimages. Right now it is just showing broken images. I have tried changing the directory and it doesn't work. My images are in the folder and they are jpegs. Here is the code. $directory = "../../forumimages/"; //get all image files with a .jpg extension. $images = glob($directory . "*.jpg"); //print each file name foreach($images as $image) { echo '<img src="' . $directory . '/' . $image . '" />'; }
  4. I am working on a site, and using the scripts in this book. I keep getting the error this page has been accessed in error. The script should insert a record into the database, instead it doesn't do any validation or anything else, it just gives the error message. I thought it might be a problem with the database but I can't find the problem. Any ideas.
  5. I am trying to implement a search feature to a forum I am creating and I want users to be able to search through posts. So far users type in the search terms in a form, and they go through to my $_GET['terms']. The problem is that the IN BOOLEAN MODE search only returns posts that start with or end with one of the search terms users type into the form. I want it so that the search can also return phrases that are within posts, not necessarily starting or ending with. I have tried the boolean mode operators in all sorts of ways but it doesn't work. Is it possible to use fulltext searches in this way, or should I try a different method. Here is my Mysql query I am using: $terms = mysqli_real_escape_string($dbc, htmlentities(strip_tags($_GET['terms']))); $q = "SELECT m.message, m.posted_on, s.thread_id, s.subject FROM posts AS m LEFT JOIN threads AS s USING (thread_id) WHERE MATCH (message, subject) AGAINST('$terms*' IN BOOLEAN MODE)";
  6. I have built a forum for my own website thanks to the forum example in this book in chapter 17. Now I want the capability to search through posts and show the results of the search. I modified the search.php script included in the course files. I tested it and it doesn't work properly, the $_GET['terms'] doesn't get set when I type in search terms and click search. I tested it by echoing out 'hello' after the isset($_GET['terms']) . I don't know why it isn't set though, in the address bar it is written search.php?terms=test&submit=Submit <?php # Script 17.8 - search.php // This page displays and handles a search form. // Include the HTML header: // Show the search form: echo '<form action="search.php" method="get" accept-charset="utf-8"> <p><em>Search </em>: <input name="terms" type="text" size="30" maxlength="60" '; // Check for existing value: if (isset($_GET['terms'])) { echo 'value="' . htmlspecialchars($_GET['terms']) . '" '; } // Complete the form: echo '/><input name="submit" type="submit" value="' . $words['submit'] . '" /></p></form>'; if (isset($_GET['terms'])) { // Handle the form. echo 'hello'; // Clean the terms: $terms = mysqli_real_escape_string($dbc, htmlentities(strip_tags($_GET['terms']))); // Run the query... $q = "SELECT message FROM posts WHERE MATCH (message) AGAINST ('test' IN BOOLEAN MODE)"; $r = mysqli_query($dbc, $q); if (mysqli_num_rows($r) > 0) { $row = mysqli_fetch_array($r, MYSQLI_ASSOC); echo '<h2>Search Results</h2>'; echo '<p>' . $row['message'] . '</p>'; } else { echo '<p>No results found.</p>'; } } ?>
  7. I want to integrate the forum example in the book into my website, except I would modify it so that I could have multiple forums with different topics on my site. What I want to know is what columns and tables do you think I should add to my forum database. To add to the example in the book, I thought of creating a new forums table, and in it having the forum_id column, as well as the thread_id foreign key column. I am new at this so if you have any suggestions at populating my forums table that would be great.
  8. I am creating a site using the registration system in chapter 18, and I am using the output buffer on every page, the ob_start() is included in every page via the header.html file. In the book it says that if we use the output buffer we won't get headers already sent error messages. But I just tested it and put a space before the starting <?php tag. And I got the following error. Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/ why does it give an error message.
  9. I have just typed out index.php for chapter 17, and the language drop down menu displays funny characters instead of the language specific letters. I typed the scripts as shown in the book. How can I debug this, is it my Xampp settings, I checked and it says the language is set to US in Xampp. In the book it says to save my page using utf-8 encoding. I don't know if that is the problem, I just saved my index.php page with the name index.php, in dreamweaver I don't see an option for the encoding to use for the page. In my header file the encoding is set to utf-8 and that file is included in index.php, so won't that do it.
  10. In this book in chapter 2 script 2.4 index.php. It says to include the configuration file: require('./includes/config.inc.php'); How can you reference a file with ./, shouldn't it be ../ I tried it and it doesn't work. Is this a mistake in the book?
  11. My show_image.php script is not working. When I click on the links the popup window comes up but the images don't display, only the unavailable.jpg image displays. I checked the uploads folder and it seems ok. I am using the downloaded script from this site to make sure the code is ok. For images.php, and upload_image.php, and functions.js, I am also using this site's scripts. I tried to see the source code from the popup window and there is nothing it is blank. Here is the show_images.php code. <?php # Script 11.5 - show_image.php // This page displays an image. $name = FALSE; // Flag variable: // Check for an image name in the URL: if (isset($_GET['image'])) { // Make sure it has an image's extension: $ext = strtolower ( substr ($_GET['image'], -4)); if (($ext == '.jpg') OR ($ext == 'jpeg') OR ($ext == '.png')) { // Full image path: $image = "../../../../uploads/{$_GET['image']}"; // Check that the image exists and is a file: if (file_exists ($image) && (is_file($image))) { // Set the name as this image: $name = $_GET['image']; } // End of file_exists() IF. } // End of $ext IF. } // End of isset($_GET['image']) IF. // If there was a problem, use the default image: if (!$name) { $image = 'images/unavailable.png'; $name = 'unavailable.png'; } // Get the image information: $info = getimagesize($image); $fs = filesize($image); // Send the content information: header ("Content-Type: {$info['mime']}\n"); header ("Content-Disposition: inline; filename=\"$name\"\n"); header ("Content-Length: $fs\n"); // Send the file: readfile ($image);
  12. In Chapter 11 in the sending email script called email.php, the $_POST['name'] and $_POST['comments'] in the $body variable are wrapped in curly braces. Why are there curly braces around them. See the code below. if ($_SERVER['REQUEST_METHOD'] == 'POST'){ if (!empty($_POST['name']) && !empty($_POST['email']) && !empty($_POST['comments'])){ $body = "Name: {$_POST['name']}\n\nComments: {$_POST['comments']}"; $body = wordwrap($body, 70); } }
  13. I am building a website after reading this book, and I am having trouble with the selected="selected" part of a select menu. Nothing is getting selected. When I click on submit form it goes through but the item I selected isn't being selected in my database. In the following code, the problem lies in the following section: where the select menu is, but I can't get it to work. help would be appreciated. <?php $optionarray = array(3 => 'Children & Family', 4 => 'Home Business', 5 => 'Advertising', 6 => 'Affiliate Programs', 7 => 'Art & Photography', 9 => 'Beauty & Jewelry', 10 => 'Blogging', 11 => 'Books, Literature', 12 => 'Business & Finance', 13 => 'Computer Games', 14 => 'Computing', 15 => 'Dating & Relationships', 16 => 'Directories', 17 => 'Education', 18 => 'Electronics', 19 => 'Entertainment', 20 => 'Environment', 21 => 'Flowers', 22 => 'Food, Drink', 23 => 'Forums, chat rooms', 24 => 'Free Stuff', 25 => 'Gifts & Shopping', 26 => 'Health', 27 => 'Humor', 28 => 'Interior Design', 29 => 'Internet Marketing', 30 => 'Miscellaneous', 31 => 'Music', 32 => 'Pets', 33 => 'Real Estate', 34 => 'Religion & Spirituality', 35 => 'Science', 36 => 'Sports', 37 => 'Stocks & Trading', 38 => 'Travel', 39 => 'Vehicles', 40 => 'Web Design', 41 => 'Web Hosting', 42 => 'Work At Home', 43 => 'Psychology'); echo '<form action="edit_your_sites.php" method="post"><select name="SiteTypeID"><option value="">Select a Category</option>'; foreach ($optionarray as $key => $value){ echo '<option value="$key"'; if (isset($_POST['SiteTypeID']) && ($_POST['SiteTypeID'] == '. $key . ')) echo 'selected="selected">'; echo $value . '</option>'; } echo '</select>'; ?> <?php $page_title = 'Edit Your Account'; include ('includes/header.html'); include ('includes/functions.php'); include ('includes/config.inc.php'); if (isset($_GET['id']) && is_numeric($_GET['id'])){ $id = $_GET['id']; } elseif (isset($_POST['id']) && is_numeric($_POST['id'])) { $id = $_POST['id']; } else { echo '<p class="error">This page has been accessed in error.</p>'; include ('includes/footer.html'); exit(); } if (isset($_SESSION['UserID'])){ require (MYSQL); echo '<div class="text">'; $scrubbed = array_map('spam_scrubber', $_POST); if ($_SERVER['REQUEST_METHOD'] == 'POST'){ if (filter_var($scrubbed['url'], FILTER_VALIDATE_URL)){ $url = mysqli_real_escape_string($dbc, $scrubbed['url']); } else { $url = ""; echo '<p class="error">Please enter a valid url</p>'; } if (!empty($scrubbed['SiteTypeID'])){ $sitetypeid = $scrubbed['SiteTypeID']; } else { $sitetypeid =""; echo '<p class="error">Please select a category</p>'; } if($url && $sitetypeid){ $q = "SELECT UserID, url, SiteID FROM sites WHERE url='$url' AND SiteTypeID='$sitetypeid' AND SiteTypeID!=$id"; $query = mysqli_query ($dbc, $q); if (mysqli_num_rows($query) == 0){ $q = "UPDATE sites SET url='$url', SiteTypeID='$sitetypeid' WHERE SiteID=$id LIMIT 1"; $query = mysqli_query ($dbc, $q); if (mysqli_affected_rows($dbc) == 1){ echo '<p><b>Your url has been successfully edited</b></p>'; } elseif (mysqli_affected_rows($dbc) == 0){ echo '<p>No new details have been inserted</p>'; } else { echo '<p class="error">The user could not be edited due to a system error. We apologize for any inconvenience.</p>'; // Public message. echo '<p>' . mysqli_error($dbc) . '<br />Query: ' . $q . '</p>'; // Debugging message. } } else { echo '<p><b>That url has already been registered with that category, if you own this site you can change categories if you wish to. Please note that a website cannot be added multiple times in different categories.</b></p>'; } } } ?> <h1>Edit Your Sites</h1><p><b>Do not add duplicate urls, they will be deleted. We only accept family-safe urls. We play fair and expect our members to do the same.</b> </p> <?php $query2 = "SELECT s.SiteTypeID, u.UserID, s.SiteType FROM sitetypes AS s LEFT JOIN sites AS u USING (SiteTypeID) WHERE SiteID=$id"; $mx = mysqli_query($dbc, $query2); if (mysqli_num_rows($mx) ==1){ $row2 = mysqli_fetch_array($mx, MYSQLI_ASSOC); echo '<p>Your site\'s current category is <b>'.$row2['SiteType'] . '</b></p>'; } ?> <?php $optionarray = array(3 => 'Children & Family', 4 => 'Home Business', 5 => 'Advertising', 6 => 'Affiliate Programs', 7 => 'Art & Photography', 9 => 'Beauty & Jewelry', 10 => 'Blogging', 11 => 'Books, Literature', 12 => 'Business & Finance', 13 => 'Computer Games', 14 => 'Computing', 15 => 'Dating & Relationships', 16 => 'Directories', 17 => 'Education', 18 => 'Electronics', 19 => 'Entertainment', 20 => 'Environment', 21 => 'Flowers', 22 => 'Food, Drink', 23 => 'Forums, chat rooms', 24 => 'Free Stuff', 25 => 'Gifts & Shopping', 26 => 'Health', 27 => 'Humor', 28 => 'Interior Design', 29 => 'Internet Marketing', 30 => 'Miscellaneous', 31 => 'Music', 32 => 'Pets', 33 => 'Real Estate', 34 => 'Religion & Spirituality', 35 => 'Science', 36 => 'Sports', 37 => 'Stocks & Trading', 38 => 'Travel', 39 => 'Vehicles', 40 => 'Web Design', 41 => 'Web Hosting', 42 => 'Work At Home', 43 => 'Psychology'); echo '<form action="edit_your_sites.php" method="post"><select name="SiteTypeID"><option value="">Select a Category</option>'; foreach ($optionarray as $key => $value){ echo '<option value="$key"'; if (isset($_POST['SiteTypeID']) && ($_POST['SiteTypeID'] == '. $key . ')) echo 'selected="selected">'; echo $value . '</option>'; } echo '</select>'; ?> <?php $ms = "SELECT UserID, url, SiteID FROM sites WHERE SiteID=$id"; $msp = mysqli_query($dbc, $ms); if (mysqli_num_rows($msp) > 0){ $row = mysqli_fetch_array($msp, MYSQLI_ASSOC); echo '<p>Url:<input type="text" name="url" size="60" maxlength="80" value="' . $row['url'] .'" /><small>You can only add each url once into the database, each url must be unique.</small></p><p><input type="submit" name="submit" value="Edit Site Information!" /><input type="reset" name="reset" value="Clear Form" /> <input type="hidden" name="id" value="' . $id . '" /> </form><p><a href="delete_url.php?id=' . $row['SiteID'] . '"><b>Delete Url</b></a>'; } else { echo '<p class="error">A system error occurred, we apologize for the inconvenience.</p>'; } ?> <?php } else { $url = BASE_URL . 'index.php'; header("Location: $url"); } echo '</div>'; include ('includes/footer.html'); ?>
  14. I have bought and read larrys php for the web 4th edition, and php and javascript. I am having trouble with the example in chapter 11 of php and javascript .. accessing a javascript function form inside php. can somesone send me an email so I can describee the problem. I spend all morning typing the question in notepad but for some reason I cant copy/paste it to forum box .. tried ctrl/c-ctrl/v .. edit-copy/edit-paste .. right click copy/paste .. nothing works at 73 with arthritus in my hands, if I try to type is again it will contain typping errors. jerry gentry .. www.wa0h.com .. jerrywa0h@sbcglobal.net
  15. When I user the instanceof keyword for the Singleton class in Ch07 page 218, it is returning true. See below. // Create a second object to confirm: $TEST = Config::getInstance(); // see what instanceof thinks... if ($TEST instanceof Config) { echo '<pre>$TEST IS instance of Config</p>'; } else { echo '<pre>$TEST IS NOT instance of Config</p>'; } It is echoing that $TEST IS instance of Config. Am I doing something wrong?
  16. Hi Larray and all, I have edited this script to fit my project, which I cut off the first name and last name. I added the username field which looks like this: <form action="" method="post"> <fieldset> <legend>Sign Up </legend> <label>Choose a username</label> <input type="text" name="username" size="20" maxlength="20" value=" <?php if (isset($trimmed['username'])) echo $trimmed['username']; ?>" /> <label>Email</label> <input type = "text" name="email" size="30" maxlength="60" value ="<?php if(isset($trimmed['email'])) echo $trimmed['email']; ?>" /> <label>Select a password</label> <input type="password" name="password1" size="20" maxlength="20" value="<?php if(isset($trimmed['password1'])) echo $trimmed['password1']; ?>" /> <label>Confirm password</label> <input type="password" name="password2" size="20" maxlength="20" value="<?php if(isset($trimmed['password2'])) echo $trimmed['password2']; ?>" /> <input type = "submit" name="submit" value="Sign Up "/> </fieldset> </form> I followed the script 18.6 strickly, plus do the username validation like this (of course, I also initiate the $errors = array(); too: //validate the username if (preg_match('/^\w\S{2,20}$/', $trimmed['username']) ) { $u = mysqli_escape_string($dbc, $trimmed['username']); } else { $errors[] = 'Please enter a username'; } Assume that other variable validations are okay. I code like this: if($u && $e && $p){//OK // Check for unique username and email $q = "SELECT user_id from users where username='$u' AND email='$e'"; $r = mysqli_query($dbc, $q) or die("MySQL error: " . mysqli_error($dbc) . "<hr>\nQuery: $q"); if(mysqli_num_rows($r) == 0 ){ // Create the activation code $a = md5(uniqid(rand(), TRUE)); //Defined variable for language ID $l = $_SESSION['lid']; //retrieved already in the header //Insert into database, table users $q = " INSERT INTO users (lang_id, username, pass, email, active, registration_date) VALUES ('$l','$u', SHA1('$p'), '$e', '$a', NOW() ) "; $r = mysqli_query($dbc, $q) or die("MySQL error: " . mysqli_error($dbc) . "<hr>\nQuery: $q"); if (mysqli_affected_rows($dbc) == 1) { // everything's ok //Send the email: $body = "Thank you for your registration at askpro.com. To activate your account, please click on the link below \n\n"; $body .= BASE_URL. 'activate.php?e='.urlencode($e). "&a=$a"; mail($trimmed['email'], 'Registration Confirmation', $body, 'From: info@website.com'); //Finish the page echo '<h3>Thank you for registering! A confirmation email has been sent to your address. Please click on the link in that email in order to activate your account.</h3>'; include ('includes/footer.html'); // Include the HTML footer. exit(); // Stop the page. } else { $errors[]='You could not be registered due to a system error. We apologize for any inconvenience.'; } }else{ $errors[] = 'either the username or email has already been registered. If you have forgotten your password, use the link above to have your password sent to you.</'; } }else { // If one of the data tests failed. echo 'Error:<br />'; foreach ($errors as $msg) { // Print each error. echo "- $msg <br />"; } $error[] = 'Please try again'; } } The question is that: -/ When I enter value and click the 'sign up' button with the intention that I enter a duplicate email, i.e., email@website.com, it returned error like this: MySQL error: Duplicate entry 'email@website.com ' for key 3 --------------------------------------------------------- Query: SELECT user_id FROM users WHERE (username = 'dsfdsf' AND email = 'e') -/ Then I change the query to: $q = "SELECT user_id from users where username='$u' OR email='$e'"; It returns NO error, but it does not insert anything into the database, and no 'thank you message' is printed. Can you help me to figure this out? Am I doing anything wrong? Thank you. P/S: This is my users table:
  17. in the book it shows us how to drop an index by using the following sql statement. ALTER TABLE t DROP INDEX i i being the name of the index. I went into phpmyadmin and I don't see an option for removing an index unless there is a name attached to the index. If I would write an sql statement to drop the index how would I write it if the index doesn't have a name.
  18. Hi, I run into trouble sending html email to hotmail and aol address using php mail() function. Gmail and Yahoo are fine. But hotmail and aol are failed to receive anything. Here is my header setting $headers = "From: sales@thtc-usa.com\r\n"; $headers .= "Reply-To: sales@thtc-usa.com\r\n"; $headers .= "Return-Path:sales@thtc-usa.com\r\n"; $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n"; any suggestion please?
  19. hello everyone.. i have a form to store values for a model add having rows id name description and one is email to store email for particular entry. Now i want a contact form to send mail for that particular model values... that is to send mail to the owner of particular add.. I able to reuse contact form for that purpose but i fail to fetch saved email id for each add so that any viewer can mail for adds.. How to achive this task?? please help me someone.. let me know the how can i do this?? if any example code will be very useful to me.. Thank you.....
  20. Hi, My product page (output) in HTML is something like this: ProductImage1 ProductImage2 ProductImage3 ProductImage4 Color1 Color2 Color3 Color4 Color2 Color5 Color6 What I'm trying to do is when I hover my mouse over any color above, an original (main) image of ProductImage will switch to another image (to match the hovered color). And that original image will be back when the mouse leaves. Example: http://jsfiddle.net/4dK2x/27/ I also added another hover function on ProductImage for switching images between front view and back view and it's working well. (You would see the two src attributes of the .main class image in my php code as follows) However, the hover function on colors is not working when I run php code to create a dynamic list. Here are my category.php. ---- $sql = mysqli_query($db_connect, "SELECT p.id,p.style,c.color_palette, GROUP_CONCAT(DISTINCT CONCAT(c.color_palette) ORDER BY p.id SEPARATOR '+') color_palettes FROM product_details AS pd INNER JOIN products AS p ON p.id=pd.product_id INNER JOIN colors AS c ON c.id=pd.color_id INNER JOIN subcategories AS sub ON sub.id=p.subcategory_id INNER JOIN categories AS cat ON cat.id=sub.category_id WHERE category='$category' GROUP BY p.id LIMIT 6"); [...] $i= 0; $Output= '<table><tr>'; while($row = mysqli_fetch_array($sql, MYSQLI_ASSOC)){ $id = $row["id"]; $color_palette = $row["color_palette"]; $style = $row["style"]; $color_palettes = explode("+", $row["color_palettes"]); $Output.= '<td><div class="image"><a href="product.php?id='.$id .'&colorpalette='.$color_palette.'"><img class="main" data-alt-src="images/'.$style.'.'.$color_palette.'.BR.jpg" src="images/'.$style.'.'.$color_palette.'.FR.jpg" width="300" height="327"/></a><br />'; $Output.= '<div class="toggles">'; for ($ii=0;$ii<count($color_palettes);$ii++){ if (count($color_palettes) > 1) { $Output.= '<a href="product.php?id='.$id .'&colorpalette='.$color_palettes[$ii].'"><img data-src="images/'.$style.'.'.$color_palettes[$ii].'.FR.jpg" src="images/'.$style.'.'.$color_palettes[$ii].'.CP.jpg" /></a> '; } else { $Output.= '';} } // End for loop $Output.= '</div>'; $Output.='</div></td>'; $i++; if ($i%4==0){ $Output.= '</tr><tr>';} } // End while loop $Output.= '</tr></table>'; ---- I think my problem is probably because the array $color_palettes[$ii] is not defined in .main class image. So if that i the case, what do I do to fix it? Any help would be much appreciated.
  21. Here is the problem I have been having. I have tried numerous things to resolve it. Nothing seems to work. I have my login script from this book and I put it on a live domain to test it. And I can login fine with Internet explorer and Safari. But with Chrome and Firefox. It always fails to log me in on the first attempt, it takes 2 or sometimes 3 attempts. I am thinking of using the code from this book to build a website but I am completely clueless as to why it is doing this. I have triple-checked my code and it is like in the book. Could it be my SQL table that has a problem. I tested the query in phpmyadmin in the SQL form, and it always returns the user_id. When I try to login the page kind of jumps and it redirects me to index.php without logging me in. I have been at this for 3 days, any help would be HIGHLY appreciated.
  22. I built a login page from the model in this book, and for some reason, sometimes when I login it redirects me back to index.php and it doesn't log me in. Other times it logs me in just fine. Any idea what could be causing this? Here is my login page code. <?php $page_title = 'Login to your account'; include ('includes/header.html'); include ('includes/config.inc.php'); if ($_SERVER['REQUEST_METHOD'] == 'POST'){ require (MYSQL); $trimmed = array_map('trim', $_POST); if (!empty($trimmed['Email']) && filter_var($trimmed['Email'], FILTER_VALIDATE_EMAIL)){ $e = mysqli_real_escape_string($dbc, $trimmed['Email']); } else { $e = FALSE; echo '<p class="error">You forgot to enter your email address, or the email you entered is invalid.</p>'; } if (!empty($trimmed['Pass'])){ $p = mysqli_real_escape_string($dbc, $trimmed['Pass']); } else { $p = FALSE; echo '<p class="error">You forgot to enter your password, or the password you entered is invalid.</p>'; } if ($e && $p){ $q = "SELECT UserID, Fname FROM users WHERE (Email='$e' AND Pass=SHA1('$p')) AND Active IS NULL"; $r = mysqli_query($dbc, $q) or trigger_error("Query: $q\n<br /> Mysql Error:" . mysqli_error($dbc)); if (@mysqli_num_rows($r) == 1){ $_SESSION = mysqli_fetch_array($r, MYSQLI_ASSOC); mysqli_free_result($r); mysqli_close($dbc); $url = BASE_URL . 'index.php'; ob_end_clean(); header("Location: $url"); exit(); } else { echo '<p class="error">Either the username and password you entered do not match those we have on file, or you have not yet activated your account.</p>'; } } else { echo '<p class="error">Please Try Again</p>'; } mysqli_close($dbc); } ?> <div class="text"> <h1>Login</h1> <p>Your browser must allow cookies in order to log in.</p> <form action="login.php" method="post"> <fieldset> <p><b>Email: <input type="text" name="Email" /></b></p> <p><b>Password: <input type="password" name="Pass" /></b></p> <input type="submit" name="submit" value="Login!" /> </fieldset> </form> </div> <? include ('includes/footer.html'); ?>
  23. In the following code I am validating a url in a practice page I am using from the stuff I learned in the book­. When I enter an invalid url in my form, I get an $url undefined error when running the code below. I am guessing the error is pretty easy to spot, but I am new at this. if (filter_var($scrubbed['url'], FILTER_VALIDATE_URL)){ $url = mysqli_real_escape_string($dbc, $scrubbed['url']); } else { echo '<p class="error">Please enter a valid url</p>'; }
  24. I am on Chapter 18, I created all the files and they seem to be all like it is written in the book, when I logout I can still see the user menu, if I click on one of the user links it takes me back to the index.php (some of the time) page which is great, meaning I am logged out. But why can I still see the Logged in User links even after I click on logout, sometimes when I click on the user links I can even get to the logged in page after I am logged out. I double checked my login and logout pages and they seem the same as in the book. Is this normal??
  25. hi i uploaded a website using the includes infrastructure exampled in this book my base uri for xamp is define ('BASE_URI', '/C:xamp/htdocs/'); and it works fine but im using filezilla to upload folders to my site hosting on go daddy and when i use my httpdocs path define ('BASE_URI', '/httpdocs/'); i get this error: PHP Fatal error: require(): Failed opening required '/httpdocs/mysql.inc.test.php' (include_path='.;.\includes;.\pear') in G:\PleskVhosts\axebs.com\httpdocs\index.php on line 16 any tips on what i need to set my path to to work on filezilla??
×
×
  • Create New...