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 have to tables that are link and i want to view contents of a single item when i select it, what is the correct syntax of using $post in yii ie SELECT tbl_emp.emp_id, tbl_emp.sname, tbl_fname, tbl_educ.empl_id FROM tbl_emp, tbl_edu WHERE tbl_emp.emp_id=$_POST['emp_id'] AND tbl_edc.emp_id=$_PSOT['emp_id'];
  2. Hi everyone, I'm building my own shopping website. I haven't figured out how to populate two dropdown lists with available sizes and colors of a product_id from database. Here is the result I've got from querying database. id product_name style size color price image sku stock 1 Neck Top 104 S White $30.00 104.jpg 104-1 5 2 Neck Top 104 S Black $30.00 104.jpg 104-2 5 3 Neck Top 104 M Red $30.00 104.jpg 104-3 10 4 Neck Top 104 L Blue $30.00 104.jpg 104-4 10 5 Neck Top 104 XL Black $30.00 104.jpg 104-5 5 And here are my tables: tblProduct tblSizes tblColors tblSpecific_Products id id id id product_name size color product_id style size_id price color_id image stock category (tops,dresses,bottoms,...) subcategory (bodycon,work,evening,cocktail) Is there any way I can have it done without duplicating the values in each dropdown list? Also for each product_id, how can I store 3 different images (front view,back view and side view) for each color? Does it mean I have to create another attribute table for those images and store their names in database? I'm confused.
  3. My question is why in the following mysql statement does the $id at the end, not have to be in single quotes, whereas other variables in this statement are in quotes. $u = "UPDATE customers SET first_name='$fn', last_name='$ln', email='$em', address='$add', zipcode='$zip', city='$city', state='$state', country='$coun' WHERE customer_id = $id";
  4. In Chapter 19, the $_SESSION['customer_id'] variable is often used for things like isset($_SESSION['customer_id']) why though can't we use other table columns that are like customer_id in the $_SESSION[] for example $_SESSION['order_id'] In chapter 19 also, the $_GET['id'] is the same id as the customer's. Why is it the same? Where does it get declared as the same, I have searched through the scripts and I don't see it. I am trying to create a script where users can view their past orders. The trouble I am having is calculating the total amount of the order in the checkout.php script, because there is no customer_id field in the order_contents table. Here is where I am at with that in the checkout.php script: $u = "SELECT price * quantity AS amount FROM order_contents WHERE order_id=?not sure what to put here"; $total = mysqli_query($dbc, $u);
  5. I am using the structure of Script 3.5 (Calculator.php) to tackle the issue of recording attendance for persons listed in a MySQL database. I am using this structure because I am attempting to create a web page that will handle a form and then display it again. Larry mentions this function on page 86. I plan to use input type="checkbox" name="checkbox[]" value="full_name". The value part is where I am having trouble. I want to select a person's name from a table in the database so that the name will appear on the form on the same line with the checkbox. The page is in two parts, the first part being for php code, and the second part being for the html form. To place on the form a checkbox I need to list a person's name with that input. I can query the database in the php section and fetch from the array of results each person's name. Can anyone suggest where in the code I can fetch the names and then use them in the input for checkboxes? I hope this makes sense. I want to record attendance for all persons in a table who are present at a meeting. I want to list the names of all persons in the table along with a checkbox that can be checked to indicate they were present. I will appreciate any guidance that can be shared to help me in designing a plan to accomplish this. Thank you. Wes (wesmith4@gmail.com)
  6. I have an HTML table generated by PHP querying from MySQL table. <table> <tr> <th>Sl</th> <th>ID</th> <th>Article Name</th> <th>Publish Status</th> </tr> <?php $i = 1; foreach ($obj->showAllFromTable('pattern') as $pattern) { extract($pattern); ?> <tr> <td><?php echo $i++; ?></td> <td><?php echo $id; ?></td> <td><?php echo $pattern_name; ?></td> <td id="publish_<?php echo $id; ?>" class="status_pattern"> <?php echo $publish; ?> </td> </tr> <?php } ?> </table> I want to change the status of any article by clicking on the 'publish' cell of the corresponding article row. I am trying to use ajax method of jquery for this purpose as shown in the following: <script type="text/javascript"> $(document).ready(function(){ $('.status_pattern').click(function(){ var thisid = $(this).attr('id'); $.ajax({ url: "status_change_pattern.php", data: { id: thisid }, success: function (response) { alert(response); } }); }); }); </script> In the "success" block, instead of "alert", I want to create a functionality to change the text of the specific cell which I clicked. The "status_change_pattern.php" has just a text "Hey Hey". Can anyone help? Please. Thanks.
  7. I am almost finished the book, and I am not totally clear on how to use the $page_title variable that appears throughout the book, do we have to include the following code in the title tag of each php script in order to use $page_title. <?php echo $page_title; ?>. In most of the examples in this book the $page_title variable is used in the script without showing the code used in the title tag. Also since the $page_title variable appears below the title tag when I load the php script in my browser I get an error message saying that $page_title isn't a valid variable. Can someone explain to me how to properly use the $page_title variable when writing php scripts. Or is it just easier to write the title in the title tag without using this variable.
  8. Hello all, I am enjoying this book, and have had all success deploying the chapter 3 department select menu scripts on my local environment. When i try to implement the same when using a bootstrap style website, where the pages are outputted through the index.php file: https://mysite.com/index.php?page=dept_form&did=1 I run into problems. In your book on chapter 3 your dept.js file has the code pulling from (get, dept_results_ajax.php?did=' + encode...). Because of the bootstrap style site I am using will this be different? Also, does it matter if using https opposed to http? Any help would be great. Thanks
  9. After exhausting searching and trying many different things and asking people about the add_print.php script in chapter 19 I am now positive that there are errors in this script. I have tried using the exact script supplied by the author in his working files and the images don't display in my uploads folder, and they also don't show up in my view_print.php page. I put the entire script up on stack overflow and got an answer that partially helped fix this. I however still don't see the images on my view_print pages. The show_image.php isn't doing it's job like it should, and I am using the exact files provided by the author. This is extremely frustrating and time consuming, one would expect the examples to be error free. Here is the fix I got on stack overflow. You need to add a couple lines of code and change one line to actually display the image in your uploads folder. The entire modified script is below. Note that this doesn't entirely fix the problem though, you still don't see the images on the view_print.php page. $path_parts = pathinfo($_FILES["image"]["name"]); $extension = $path_parts['extension']; $id = mysqli_stmt_insert_id($stmt); // Get the print ID. rename ($temp, "../../../uploads/$id.".".$extension"); <?php # Script 19.2 - add_print.php // This page allows the administrator to add a print (product). require ('../../mysqli_connect.php'); if ($_SERVER['REQUEST_METHOD'] == 'POST') { // Handle the form. // Validate the incoming data... $errors = array(); // Check for a print name: if (!empty($_POST['print_name'])) { $pn = trim($_POST['print_name']); } else { $errors[] = 'Please enter the print\'s name!'; } // Check for an 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)) { echo '<p>The file has been uploaded!</p>'; // Set the $i variable to the image's name: $i = $_FILES['image']['name']; } else { // Couldn't move the file over. $errors[] = 'The file could not be moved.'; $temp = $_FILES['image']['tmp_name']; } } else { // No uploaded file. $errors[] = 'No file was uploaded.'; $temp = NULL; } // Check for a size (not required): $s = (!empty($_POST['size'])) ? trim($_POST['size']) : NULL; // Check for a price: if (is_numeric($_POST['price']) && ($_POST['price'] > 0)) { $p = (float) $_POST['price']; } else { $errors[] = 'Please enter the print\'s price!'; } // Check for a description (not required): $d = (!empty($_POST['description'])) ? trim($_POST['description']) : NULL; // Validate the artist... if ( isset($_POST['artist']) && filter_var($_POST['artist'], FILTER_VALIDATE_INT, array('min_range' => 1)) ) { $a = $_POST['artist']; } else { // No artist selected. $errors[] = 'Please select the print\'s artist!'; } if (empty($errors)) { // If everything's OK. // Add the print to the database: $q = 'INSERT INTO prints (artist_id, print_name, price, size, description, image_name) VALUES (?, ?, ?, ?, ?, ?)'; $stmt = mysqli_prepare($dbc, $q); mysqli_stmt_bind_param($stmt, 'isdsss', $a, $pn, $p, $s, $d, $i); mysqli_stmt_execute($stmt); // Check the results... if (mysqli_stmt_affected_rows($stmt) == 1) { // Print a message: echo '<p>The print has been added.</p>'; // Rename the image: $path_parts = pathinfo($_FILES["image"]["name"]); $extension = $path_parts['extension']; $id = mysqli_stmt_insert_id($stmt); // Get the print ID. rename ($temp, "../../../uploads/$id.".".$extension"); // Clear $_POST: $_POST = array(); } else { // Error! echo '<p style="font-weight: bold; color: #C00">Your submission could not be processed due to a system error.</p>'; } mysqli_stmt_close($stmt); } // End of $errors IF. // Delete the uploaded file if it still exists: if ( isset($temp) && file_exists ($temp) && is_file($temp) ) { unlink ($temp); } } // End of the submission IF. // Check for any errors and print them: if ( !empty($errors) && is_array($errors) ) { echo '<h1>Error!</h1> <p style="font-weight: bold; color: #C00">The following error(s) occurred:<br />'; foreach ($errors as $msg) { echo " - $msg<br />\n"; } echo 'Please reselect the print image and try again.</p>'; } // Display the form... ?> <h1>Add a Print</h1> <form enctype="multipart/form-data" action="add_print.php" method="post"> <input type="hidden" name="MAX_FILE_SIZE" value="524288" /> <fieldset><legend>Fill out the form to add a print to the catalog:</legend> <p><b>Print Name:</b> <input type="text" name="print_name" size="30" maxlength="60" value="<?php if (isset($_POST['print_name'])) echo htmlspecialchars($_POST['print_name']); ?>" /></p> <p><b>Image:</b> <input type="file" name="image" /></p> <p><b>Artist:</b> <select name="artist"><option>Select One</option> <?php // Retrieve all the artists and add to the pull-down menu. $q = "SELECT artist_id, CONCAT_WS(' ', first_name, middle_name, last_name) FROM artists ORDER BY last_name, first_name ASC"; $r = mysqli_query ($dbc, $q); if (mysqli_num_rows($r) > 0) { while ($row = mysqli_fetch_array ($r, MYSQLI_NUM)) { echo "<option value=\"$row[0]\""; // Check for stickyness: if (isset($_POST['artist']) && ($_POST['artist'] == $row[0]) ) echo ' selected="selected"'; echo ">$row[1]</option>\n"; } } else { echo '<option>Please add a new artist first.</option>'; } mysqli_close($dbc); // Close the database connection. ?> </select></p> <p><b>Price:</b> <input type="text" name="price" size="10" maxlength="10" value="<?php if (isset($_POST['price'])) echo $_POST['price']; ?>" /> <small>Do not include the dollar sign or commas.</small></p> <p><b>Size:</b> <input type="text" name="size" size="30" maxlength="60" value="<?php if (isset($_POST['size'])) echo htmlspecialchars($_POST['size']); ?>" /> (optional)</p> <p><b>Description:</b> <textarea name="description" cols="40" rows="5"><?php if (isset($_POST['description'])) echo $_POST['description']; ?></textarea> (optional)</p> </fieldset> <div align="center"><input type="submit" name="submit" value="Submit" /></div> </form> </body> </html>
  10. For some reason the images I am uploading to my uploads folder are just showing as blank, the files are there but it is not showing them as images. It is written that the type of file it is is just File. and it shows the path to the image D:\xampp\htdocs\uploads. My add_print.php is just fine as far as I can tell. I tested it with the script written by Larry in the working files for this book, it doesn't work either. I checked my permissions for my uploads folder and they look fine too. I am thinking the problem is maybe because no Mime type is specified for the images being uploaded. If that isn't where the error is, it is maybe in the code below, where my uploads folder is. it is specified as ../../../uploads. any help would be appreciated. if (is_uploaded_file($_FILES['image']['tmp_name'])){ $temp = '../../../uploads/' . md5($_FILES['image']['name']); if (move_uploaded_file($_FILES['image']['tmp_name'], $temp)){ echo '<p>The file has been uploaded!</p>'; $i = $_FILES['image']['name']; or could the problem be below:? if (mysqli_stmt_affected_rows($stmt) == 1){ echo '<p>The print has been added.</p>'; $id = mysqli_stmt_insert_id($stmt); rename ($temp, "../../../uploads/$id"); $_POST = array();
  11. I am attempting to develop a PHP script to record presence at an event for those persons in a mysql table Persons. I am attempting to use checkboxes to indicate who was present. Here is the script as currently written: <?php # Script require ('includes/mysqli_connect.php'); if(isset($_POST['checkbox'])) {$checkbox = $_POST['checkbox']; if(isset($_POST['activate'])?$activate = $_POST["activate"]:$deactivate = $_POST["deactivate"]); $id = "('" . implode( "','", $checkbox ) . "');" ; echo $id; $q="UPDATE Persons SET present = '".(isset($activate)?'Y':'N')."' WHERE id IN $id" ; $r = mysqli_query($dbc,$q) or die(mysqli_error()); } $q = "SELECT * FROM Persons"; $r = @mysqli_query ($dbc,$q); $count=mysqli_num_rows($r); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns=?http="//www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset="utf-8"" /> <title>Update multiple rows in mysql with checkbox</title> <script type="text/javascript"> <!-- function un_check(){ for (var i = 0; i < document.frmactive.elements.length; i++) { var e = document.frmactive.elements; if ((e.name != 'allbox') && (e.type == 'checkbox')) { e.checked = document.frmactive.allbox.checked; }}} //--> </script> </head> <body> <table width="400" border="0" cellspacing="1" cellpadding="0"> <tr> <td><form name="frmactive" method="post" action="checkboxes.php"> <table width="400" border="0" cellpadding="3" cellspacing="1"> <tr> <td colspan="5"><input name="activate" type="submit" id="activate" value="Activate" /> <input name="deactivate" type="submit" id="deactivate" value="Deactivate" /></td> </tr> <tr> <td> </td> <td colspan="4"><strong>Update multiple rows in mysql with checkbox</strong> </td> </tr><tr> <td align="center"><input type="checkbox" name="allbox" title="Select or Deselect ALL" style="background-color:#ccc;"/></td> <td align="center"><strong>id</strong></td> <td align="center"><strong>first_name</strong></td> <td align="center"><strong>last_name</strong></td> <td align="center"><strong>present</strong></td> </tr> <?php while ($row = mysqli_fetch_array($r)) { ?> <tr> <td align="center"><input name="checkbox[]" type="checkbox" id="checkbox" id="checkbox[]" value="<? echo $rows['person_id']; ?>"></td> <td><? echo $row['person_id']; ?></td> <td><? echo $row['first_name']; ?></td> <td><? echo $row['last_name']; ?></td> <td><? echo $row['present']; ?></td> </tr> <?php } ?> <tr> <td colspan="5" align="center"> </td> </tr> </table> </form> </td> </tr> </table> </body> </html> The table Persons contains these columns: person_id, first_name,last_name,present. I inserted the echo line after the line defining $id which is copied below: $id = "('" . implode( "','", $checkbox ) . "');" ; echo $id; But $id only contains empty strings. Can anyone help me understand what I am doing wrong? Is $checkbox always ending up empty? Any direction will be appreciated. Wes Smith
  12. Can anyone provide me with a simple solution to the Pursue question in chapter 18, create a last_login field and make it so that a user can see how long it has been since they last logged in. thanks Graham
  13. Hi everyone. I've done everything I could think of to get Script 11.8 to work, but I keep getting the error message 'The username and password you entered do not match those on file'. The users.txt is where it should be (because it worked fine for register.php) and the script is almost exactly how it is in the book. I'm using the same user names and passwords as well. Is this happening because I'm on a Mac? Oh, I'm on PHP 5.3.6 and use XAMPP. <?php // Script 11.8 - login.php $file = '../users/users.txt'; if ($_SERVER['REQUEST_METHOD'] == 'POST') { // Handle the form. $loggedin = FALSE; // Not currently signed in. // Enable auto_detect_line settings: ini_set('auto_detect_line_endings', 1); // Open the file: $fp = fopen($file, 'rb'); // Loop through the file: while ( $line = fgetcsv($fp, 200, "\t") ) { // Check the file data against the submitted data: if ( ($line[0] == $_POST['username']) AND ($line[1] == md5(trim($_POST['password']))) ) { $loggedin = TRUE; // Correct username/password combination. // Stop looping through the file: break; } // End of IF. } // End of WHILE. fclose ($fp); // Close the file. // Print a message: if ($loggedin) { print '<p>You are now logged in.</p>'; } else { print '<p style="color: red;">The username and password you entered do not match those on file.</p>'; } } else { // Display the form. // Leave PHP and display the form: ?> <form action="login.php" method="post"> <p>Username: <input type="text" name="username" size="20" /></p> <p>Password: <input type="password" name="password" size="20" /></p> <input type="submit" name="submit" value="Login" /></form> <?php } // End of submission IF. ?> </body> </html>
  14. hey everybody, i have a request here,i'm a newbie in which called php and mysql.. i have finished the HTML of my website and now i want to implement a sidebar for Most Popular Posts.. i'masking if u can afford me with a tutorial from the scratch to build my sidebar? plz? thanks in advance
  15. I want to create a contact form that has an email field where the user can't enter any white space in the field, for example: test@ex ample.com I am using a spam scrubbing function taught to us in the book to clean user inputs. I am using my variable like so. $email = strip_tags($scrubbed['email']); how can I add something like this $email = preg_replace('/\s+/', '', $email); to the existing $email = strip_tags($scrubbed['email']); I tried $email = (preg_replace('/\s+/', '', $email)(strip_tags($scrubbed['email']))); and all sorts of variations to that. it doesn't work.
  16. 2 problems with my code, the filter_var doesn't seem to work at all for any of my variables, also the spam_scrubber function doesn't seem to clean \r, and \n, when put in my contact form, it cleans all the rest though just fine. <?php // resources.php function spam_scrubber($value){ $very_bad = array('to:', 'cc:', 'bcc:', 'content-type:', 'mime-version:', 'multipart-mixed:', 'content-transfer-encoding:'); foreach ($very_bad as $v){ if (stripos($value, $v) !== false) return ''; } $value = str_replace(array( "\r", "\n", "%0a", "%0d"), ' ', $value); return trim($value); }//end of spam_scrubber function $scrubbed = array_map('spam_scrubber', $_POST); $comments = strip_tags($scrubbed['comments']); $url = $scrubbed['url']; if (isset($url)){ filter_var($url, FILTER_VALIDATE_URL, FILTER_SANITIZE_URL); } else { echo NULL; } $url2 = $scrubbed['url2']; if (isset($url2)){ filter_var($url2, FILTER_VALIDATE_URL, FILTER_SANITIZE_URL); } else { echo NULL; } $linkpageurl = $scrubbed['linkpageurl']; if (isset($linkpageurl)){ filter_var($linkpageurl, FILTER_VALIDATE_URL, FILTER_SANITIZE_URL); } else { echo NULL; } $linkpageurl2 = $scrubbed['linkpageurl2']; if (isset($linkpageurl2)){ filter_var($linkpageurl2, FILTER_VALIDATE_URL, FILTER_SANITIZE_URL); } else { echo NULL; } $email = $scrubbed['email']; if (isset($email)){ filter_var($email, FILTER_VALIDATE_EMAIL, FILTER_SANITIZE_EMAIL); } else { echo NULL; } $pagerank = $scrubbed['pagerank']; if (isset($pagerank)){ filter_var($pagerank, FILTER_VALIDATE_INT, FILTER_SANITIZE_NUMBER_INT); } else { echo NULL; } if (!empty($email) && !empty($url) && !empty($linkpageurl) && !empty($comments) && !empty($pagerank)){ $body = "Email: {$email}\n\n Url: {$url}\n\n Url2: {$url2}\n\n Pagerank: {$pagerank}\n\n Linkpageurl: {$linkpageurl} \n\n Linkpageurl2: {$linkpageurl2}\n\n Comments: {$comments}"; $body = wordwrap($body, 70); $headers = "From: {$email}\r\n"; mail('email@example.com', 'Link Exchange Form Submission', $body, $headers); echo '<p><em>Thank you for contacting us.</em></p><div id="formecho"><h3>Form submission received, we will get back to you soon.</h3></div>'; $_POST = array(); } else { echo '<p style="font-weight: bold; color: #C00">Please fill out the form completely.</p>'; } ?> <div id="form"> <form action="linkexchangecontactform2.php" method="post"> <p><b>Email:</b> <input type="text" size="30" maxlength="50" name="email" value="<?php if(isset($scrubbed['submit']))echo $scrubbed['email']; ?>" /></p> <p><b>Url:</b> <input type="text" size="30" maxlength="50" name="url" value="<?php if(isset($scrubbed['url']))echo $scrubbed['url']; ?>" /></p> <p><b>2nd Url (leave empty if you have just 1 website):</b><br /> <input type="text" size="30" maxlength="50" name="url2" value="<?php if(isset($scrubbed['url2']))echo $scrubbed['url2']; ?>" /></p> <p><b>Pagerank:</b> <input type="text" size="5" maxlength="10" name="pagerank" value="<?php if(isset($scrubbed['pagerank']))echo $scrubbed['pagerank']; ?>" /></p> <p><b>Link page url:</b> <input type="text" size="30" maxlength="50" name="linkpageurl" value="<?php if(isset($scrubbed['linkpageurl']))echo $scrubbed['linkpageurl']; ?>" /></p> <p><b>2nd Link page url (leave empty if you have just 1 website):</b><br /> <input type="text" size="30" maxlength="50" name="linkpageurl2" value="<?php if(isset($scrubbed['linkpageurl2']))echo $scrubbed['linkpageurl2']; ?>" /></p> <p><b>Comments:</b><br> <textarea name="comments" rows="7" cols="40"><?php if (isset($scrubbed['comments'])) echo $scrubbed['comments']; ?></textarea></p> <p><input type="submit" name="submit" value="Submit" /></p> </form></div>
  17. Hi, I need some help with a php application. I want to write simple online scheduling/appointment application with PHP and MySQL. I am not sure how to begin. Basically these are what the application would allow: USERS : - to log in as member - choose the person (advisors) they want to make an appointment with - pick a date and time from available time slot For example, Feb 1, 2014, 8:00AM- 8:30AM - Submit the date to advisor (email confirmation) ADVISORS - to log in as an admin - set up their schedules (available date and time). - there are several advisors, each has seperate schedule. My questions are: - What tools/frameworks should be used to display Calendar and time? - What appropriate methods should I store advisors available date and time in MySQL? - If i use jquery UI to display calendar, how can I make it interact with the database? For example, GREEN is available time, RED is booked. Thanks for your input.
  18. I think my PEAR install is working and got the phpDocumentor installed but now get an error using it. "phpDocumentor.EMERGENCY: phpDocumentor detected that a requirement is missing in your system setup: The XSL writer was unable to find your XSLTProcessor: please check if you have installed the PHP XSL extension or XSLC ache extention." I have a windows 7 home premium 64 bit laptop with WAMP. My Wamp 2.2 settings are Apache: 2.2.22, PHP: 5.3.13, and MySQL: 5.5.24. I checked in my php.ini file from the wamp icon in my toolbar and it has the XSL extension on. What can I do now to get the phpDocumentor to work? Thanks.
  19. In page 99, session_regenerate_id() cause en error "Cannot regenerate session id - headers already sent". If i comment this function out, everything goes fine. Where I should check for problem? thanks
  20. Hi, After following Larry's book and getting the helps from this forum, I finally get my first web project done. It has 4k product items and 1.5k users in the database. The website is fully functional in localhost. I carefully checked and killed all of bugs. Seems everything running without problem. So I need to looking into how to upload this project to the web host. I have never done anything like that before, so I am not sure what thing will go wrong and what things will screw up the project I have spent a year into. Please give some idea of what to avoid. I assume I just export the sql file from my local database and import it into web database with same name, and straightly upload all file in local host into web host. Change the BASE_URL value to web URL, and that will be all I need to do?
  21. Hi, Here the case is when user clicks a link, if he/she is not signed in yet, then he/she will be redirected to a login page. After the user successfully logged in, user should be redirected to the page url he/she intended to visit. I have no clue how to do this, but I found article online suggesting to store url into $_SESSION array before user has logged in. So I tried to store what url visitor clicked into $_SESSION['targetPage'], then redirect to login page. When user does a successful login, then $_SESSION ['targetPage'] is plugged into header function to redirect user back to the page intend. This method doesn't work, but I think the direction might be right. So please kindly give me some thought how to make this working. thank you very much! if(!isset($_SESSION['user_id'])){ // try storing the url that user clicked in $_SESSION $_SESSION['targetPage'] = $_SERVER['REQUEST_URI']; $url = 'login_page.php'; header("Location: $url"); exit(); } else { // save the session user id into $user_id $user_id = $_SESSION['user_id']; }
  22. HI, again I tried to use the array looping technique from PHP advance book (chapter 1) on my project to output products category into <ul><li> list then apply superfish menu on them. But the output created extra <a>element which slightly messed up the superfish menu. I double check the make_list() function script and I can't tell why the extra <a> tabs are created. the code: <?php require ('includes/config.inc.php'); require (MYSQL); function make_list($parent) { global $cat_list; echo '<ul>'; foreach($parent as $catid => $c_list){ echo "<li>"; echo "<a href=\"index.php?cid=$catid\">"; echo $c_list; if(isset($cat_list[$catid])){ //$catid = parent_id make_list($cat_list[$catid]); } echo '</a></li>'; } echo '</ul>'; //close the ordered list } // end of make_list function $query = "SELECT cc.category_id, cc.parent_id, c.category FROM categories AS c INNER JOIN category_categories AS cc USING (category_id) WHERE c.publish = 1"; $result = mysqli_query($dbc, $query); if(!$result) echo mysqli_error($dbc); if(mysqli_num_rows($result)>=1){ $cat_list = []; while (list($c_id, $p_id, $cat) = mysqli_fetch_array($result, MYSQLI_NUM)){ $cat_list[$p_id][$c_id] = $cat; } } make_list($cat_list[0]); ?> the problem output(first few lines) <ul> <li> <a href="index.php?cid=1">Box Collection</a> <ul> <a href="index.php?cid=1"></a> <li> <a href="index.php?cid=1"></a> <a href="index.php?cid=32">Classic Preminum Brown Hardwood Boxes</a> </li> <li> <a href="index.php?cid=35">Hat Boxes</a> </li> <li> <a href="index.php?cid=36">Leatherette Boxes</a> </li> I expect the output to be: <ul> <li> <a href="index.php?cid=1">Box Collection</a> <ul> <li> <a href="index.php?cid=32">Classic Preminum Brown Hardwood Boxes</a> </li> <li> <a href="index.php?cid=35">Hat Boxes</a> </li> <li> <a href="index.php?cid=36">Leatherette Boxes</a> </li> From the make_list() function, which seems fine, I can't tell why the extra <a> is created. Please anyone can tell where is the problem?
  23. Hi, Larry In your Modern Javascript book, there is a dynamic select menu for picking operation system. Is that possible to create a similar menu in php? or manipulate that menu with php. I have 2 tables table 1: category contains category_id, category table 2: category_categories contains id, category_id, parent_id so I want to create a primary menu to have all categories that the parent_id equals to 0 (the top), when user select a category from primary menu, the subcategory menu become selectable and load the subcategory under the primary category that user has selected. Thank you all
  24. Hello, I have been having trouble with this for quite some time I have tired to narrow it down the best I can. I able to complete the registration process, I went and check the sql database all fields have been filled. I think that the activation page cannot access the database to remove the active code. I tried to print or echo out the query value with echo "<p>Q: $q</p>" or print "<p>Q: $q</p>" all I see on the screen is "Q:" When I click the link from my email it doesn't seem to fail as it does not redirect me to index.php. I also do not get any error on my screen either. Any would help would be greatly appreciated. Regards Alex <div id="activate"> <?php /** * @author Alex Power * @copyright 2013 */ # Script 18.7 - activate.php require ('includes/config.inc.php'); $page_title='Activate Your Account'; if (isset($_GET['x'], $_GET['y']) && filter_var($trimmed['email'],FILTER_VALIDATE_EMAIL) && (STRlen($_GET['y']) == 32 )) { require (MYSQL); $q = "UPDATE users SET active=NULL WHERE (email='" . mysqli_real_escape_string($dbc, $_GET['x']) . "' AND active='" .mysqli_real_escape_sting($dbc, $_GET['y']) . "') LIMIT 1"; print "<p> Q: $q</p>"; $r = mysqli_query($dbc, $q) or trigger_error("Query:$q\n<br />)MySQL Error:" . mysqli_error($dbc)); if (mysqli_affected_rows($dbc)== 1 ) { echo "<h3>Your account is now active. You may now login.</h3>"; } else { echo '<p class="error">Your account could not be activated. Please re-check the link or contact the system administrator.</p>'; } mysqli_close($dbc); } else { //Redirect $url = BASE_URL . 'index.php'; ob_end_clean(); header("location:$url"); exit(); } // END of main IF-ELSE ?> </div>
  25. Hello, I tried to insert multiple image into image table using a foreach loop. The images insertion have returned no problem. But I wanted to catch the image_id of each insert and putted them into an array ($iid). Here is problem, no matter what I tried, the result always return 2 separated array: Array([0]=>9193) Array([1]=>9194). Is there anyway to solve this problem? I want Array([0]=>9193 [1]=>9194). Thank you all!. CODE: // query for media $query = 'INSERT INTO media (file_title, file_mimetype, file_type, file_url, file_url_thumb, file_is_product_image, created_on) VALUES (?,?,?,?,?,?,NOW())'; $stmt = mysqli_prepare($dbc, $query); $i = 0; foreach ($image_name as $key => $value){ $dot = strpos($value, '.'); $file_title = substr($value, 0, $dot); $extension = str_replace('.','',substr($value, $dot)); $file_mime = 'image/'.$extension; $file_type = 'product'; $file_url = $value; $file_url_thumb = 'images/product/resized/'.$file_title. $upload->getSuffix().$extension; $fipi = 1; mysqli_stmt_bind_param($stmt, 'sssssi', $file_title, $file_mime, $file_type, $file_url, $file_url_thumb, $fipi); mysqli_stmt_execute($stmt); // check result: if(mysqli_stmt_affected_rows($stmt) == 1){ // get the image id $iid = array(); $iid[$i++] = mysqli_stmt_insert_id($stmt); print_r($iid); // RESULT: Array([0]=>9193)Array([0]=>9194) } else { echo 'Insertion failed' . mysqli_stmt_error($stmt); } } // End of foreach
×
×
  • Create New...