Jump to content
Larry Ullman's Book Forums


  • Content Count

  • Joined

  • Last visited

Everything posted by leo

  1. i figure the problem out, windows localhost doesn't have the php image library, thanks for you input anyway
  2. here is my image query echoing an image.... but how do i pass this image path into the getimagesize() Function to retrieve my width and height values ive tried getimagesize($img) and getimagesize('uploads/$img') can anybody help $cquery = "SELECT * FROM img_uploaded"; $test2 = mysqli_query($dbc, $cquery); while ($comm = mysqli_fetch_array($test2, MYSQLI_ASSOC)){ $img = $comm['img_name']; $imgsize = $comm['img_size']; echo "<img class=\"blogpic\" src=\"uploads/$img\" />";
  3. i have been looking through the book and i am struggling to find were this INDEX login (username, pass) being used within the php, i think i am expecting to see some form of combination of some sort.
  4. Hi i have a slight problem, i understand how to create and index tables in mysql, but i have this table creation here below... yes the user_id is primary and the username and email are unique, but i do not understand the last line the, INDEX login (username, pass), how will this be used? is login even a column in this database table once this key has been assigned, will taking this off give me a less secure login? what does is actually do? Kind regards CREATE TABLE users ( user_id MEDIUMINT UNSIGNED NOT NULL AUTO_INCREMENT, lang_id TINYINT UNSIGNED NOT NULL, time_zone VARCHAR(30) NOT NULL, username VARCHAR(30) NOT NULL, pass CHAR(40) NOT NULL, email VARCHAR(60) NOT NULL, PRIMARY KEY (user_id), UNIQUE (username), UNIQUE (email), INDEX login (username, pass) );
  5. it has cleared things up a little but what about this random ID, how is everyones unique, i thought the "user_id" would be = to the user_id within the database, and that defines the sessions user! i have also seen code like $_SESSION['user_id'] = 1; lets say the sesssion user id is "12458" why you make this equal to one this also means that every users session will be 1, why do they do this?
  6. with sessions i am completly lost... so with this code here i can redirect a user if the user_id is not set right? so is this making my data on the file secury so the only people who can access it are users that are logged in? so can i use this code for pages that i wish to hide from unregistered users? session_start(); if (!isset($_SESSION['user_id'])) { require_once ('includes/login_functions. inc.php'); $url = absolute_url(); header("Location: $url"); exit(); }
  7. thats great paul il take alook, im glad you all could help. Kind regards
  8. and i get this error message... Timestamp: 12/11/2012 14:26:48 Error: [Exception... "'Javascript component does not have a method named: "onStatusChange"' when calling method: [nsIWebProgressListener::onStatusChange]" nsresult: "0x80570030 (NS_ERROR_XPC_JSOBJECT_HAS_NO_FUNCTION_NAMED)" location: "<unknown>" data: no]
  9. Its saying create_window is not defined, i copied the code directly from you book, is there any syntax errors here? thanks
  10. im having problems trying to load the new images into another window, the image link will not open. i do not understand how the show_image.php file works with this and how the creat_window javascript function works with this. Please take a look at my code below... <!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=iso-8859-1"/> <title>Images</title> <script language="Javascript"> <!-- // Hide from old browsers. // Make a pop-up window function: function create_window (image, width, height) { // Add some pixels to the width and height: width = width + 10; height = height + 10; // If the window is already open, // resize it to the new dimensions: if (window.popup && !window.popup.closed) { window.popup.resizeTo(width,height); } // Set the window properties: var specs = "location=no, scrollbars=no, menubars=no, toolbars=no, resizable=yes, left=0, top=0, width=" + width + ", height=" + height; // Set the URL: var url = "show_image.php?image=" + image; // Create the pop-up window: popup = window.open(url,"ImageWindow", specs); popup.focus(); } // End of function. //--></script> </head> <body> <p>Click on an image to view it in a separate window.</p> <table align="center" cellspacing="5" cellpadding="5" border="1"> <tr> <td align="center"><b>Image Name</b></td> <td align="center"><b>Image Size</b></td> </tr> <?php # Script 10.4 - images.php // This script lists the images in the uploads directory. $dir = 'uploads'; // Define the directory to view. $files = scandir($dir); // Read all the images into an array. // Display each image caption as a link to the Javascript function: foreach ($files as $image) { if (substr($image, 0, 1) != '.') { // Ignore anything starting with a period. // Get the image’s size in pixels: $image_size = getimagesize("$dir/$image"); // Calculate the image’s size in kilobytes: $file_size = round( (filesize("$dir/$image")) / 1024) . "kb"; // Make the image’s name URL-safe: $image = urlencode($image); // Print the information: echo "\t<tr>\t\t<td><a href=\"javascript:create_window('$image',$image_size[0],$image_size[1])\">$image</a></td> \t\t<td>$file_size</td>\t</tr>\n"; } // End of the IF. } // End of the foreach loop. ?> </table> </body> </html>
  11. Im geting through the book gradualy but i am have problems with image section. ive come to a halt... i can up load the images into the dir put can not diplay then in the images.php file, when i click the links nothing happens. ive copied this example exactly out the book, and the show_image.php also comes up with these two warnings: Warning: Header may not contain more than a single header, new line detected. Warning: Cannot modify header information - headers already sent by (output started at C:\AppServ\www\show_image.php:43) the images.php file links do not load the images up in the popup window, i have copied the code exactly from the book. Could someone help please.
  12. Ok, im new to php and trying to develop an app that allows me to upload image then resize them only on the output, i managed to save the image on the server in a folder, now i want to be able to display this images on the site in different sizes depending on what part of the site. like thumbnails and a bigger scale ect... so far i have this code $image_properties = getimagesize("uploads/orders.jpg"); $image_width = $image_properties[0]; $image_height = $image_properties[1]; $image_ratio = $image_width / $image_height; echo"<img src=\"$image_ratio\">"; here i trying to divide the image by half... i no im a long way off i thought this would work due to retrieving the image size properties then dividing it by half, then echoing it out in an image tag, haha.... eventually i would like to master this and be able to change the size by assigning numbers to variable, keeping the size proportions. help on this topic would be great, i serious need it breaking down, am i far off? Kind Regards
  13. Thanks guys you have been great help, makes a lot more sence now thanks margaux thanks antonio.. i think i will go back to the debugging chapter, also how do i print this should i just echo? print_r($r)
  14. thank you antonio that little trick fixed the code, it now runs the query without errors thanks, i will read further and if i get stuck il be sure to leave a feed, now its time for testing!
  15. i am very new to php, my debugging skills are zero, i need to read a little more on that chapter,my database connection seems to be fine because its working with all the previous exmaples.
  16. heres my query... $q = "SELECT last_name, first_name, ➝ DATE_FORMAT(registration_date, '%M ➝ %d, %Y') AS dr, user_id FROM users ➝ ORDER BY registration_date ASC ➝ LIMIT $start, $display"; when i remove this... DATE_FORMAT(registration_date, '%M ➝ %d, %Y') AS dr the query loads and doesnt nor show errors,so i am wondering if this capter in the book is using the correct syntax
  17. my code seems to look fine and my query, do you think it might have something to do with table names not have index's?
  18. i get this message: Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in C:\AppServ\www\view_current.php on line 73 i am not sure if the code is correct but i copied it from the book i was doing so well up until now, could someone give me a hand thanks Kind Regards while ($row = mysqli_fetch_array($r, MYSQLI_ASSOC)) { $bg = ($bg=='#eeeeee' ? '#ffffff' :
  • Create New...