Jump to content
Larry Ullman's Book Forums

Ghamdan

Members
  • Posts

    55
  • Joined

  • Last visited

Everything posted by Ghamdan

  1. I am using charset utf8 for database connection, sql database, mysqli table of content and html but the question mark shows at the end of some posts and it returns one question mark only the reset of the text is fine. Some of the output: Article: المغناطيسية. الإعلان جميل جداً، ولكنه يفتقر إلى الشمولية والوضوح، فلو أن أحدهم لم يعرف عن سيرفيس وميزاته الداخلية البرمجية والصلبة من قبل، فلن يلفت انتباهه في الإعلان سوى الرقص والراقصين. وذكرت مايكروسوفت في نهاية الإعلان موعد إطلاق الحاسب رسمياً وهو السادس والعشرين م� ... This is Arabic. .............................. Thank you.
  2. I am using the charset =utf8 and the question mark returns once at the end of some posts not on all of them. The issue could be , returning the beginning letters of a word which is in set(30).
  3. There is a small issue with this, it returns a symbol as you can see � at the end. How can I remove � the question mark at the end? Thank you.
  4. Thank you Antonio Conte, You are really helpful. That is great and it is working well. And thanks to the forum.
  5. I want to retrieve the first 30 characters from mysql field text but I do not know how to do it. some of the code: echo <p> Content: ' . $row['content ']. '</p> '; How can I retrieve the first 30 characters from mysql ? Thank you.
  6. I am working on chapter 18 and trying to show some pages in the header if the user is admin but it does not show the link for admin. It just shows links for registered users but not for admin. The code is below: <?php // Display links based upon the login status: if(isset($_SESSION['user_id'])) { echo ' <li> <a href="logout.php" title="Logout">Logout</a> </li> <li> <a href="change_password.php" title="Change your password"> Change Password</a> </li>'; // Show links if the user is admin: if($_SESSION['user_id'] == 1) { echo ' <li> <a href="view_users.php" title="View all the users"> View Users </a> </li> <li> <a href="#" title=" admin page"> admin page</a> </li>'; } } else { // Not logged in. echo ' <li> <a href="register.php" title="Register for the site"> Register</a> </li> <li> <a href="login.php" title="Login"> Login </a> </li> <li> <a href="forgot_password.php" title="Reset password"> Reset Password </a> </li>'; } ?> How can I show the links for the admin? Note: the admin has got user_level of 1. Thank you.
  7. Now I am using the filter_var() to validate name as you can see below. // Validate name: if(filter_var( $trimmed['name'], FILTER_SANITIZE_STRING)) { $p_name = mysqli_real_escape_string($dbc , $trimmed['name'] ); } else { echo '<p class="error"> Please enter your name. </p>'; } Is that right? Thank you
  8. This is the code which I have defined the $trimmed array: // Trim all the incoming data: $trimmed = array_map('trim', $_POST); Thank you
  9. I mean when I use this RegExp '/^[A-Z \'.-]{2, 40}$/i' then I enter a name, it does not accept the entered name. Therefore it prints the error message: echo '<p class="error"> Please enter your name. </p>. Thank you
  10. Chapter 18 - registration form. I am working on chapter 18 registration form when I validate the name with reg exp it does not accept the input value and reset works fine. php code: // Validate name: if(preg_match( '/^[A-Z \'.-]{2, 40}$/i' , $trimmed['name'])) { $p_name = mysqli_real_escape_string($dbc , $trimmed['name'] ); } else { echo '<p class="error"> Please enter your name. </p>'; } html code: <label for="name" > Name: </label> <input type="text" id="name" name="name" size="30" maxlength="40" value="<?php if(isset($trimmed['name'])) echo $trimmed['name'] ; ?>" /> How can I solve this issue?
  11. I am not using index.php?page=index? I am trying to use the method that I have showed you. I use static links but want to use a dynamic method. Thank you
  12. <nav> <ul> <?php $pages = array( 'Home Page' => 'index.php', 'Register' => 'register.php' ); $this_page = basename($_SERVER['PHP_SELF']); foreach($pages as $k => $v) { echo '<li'; if($this_page == $k) { echo ' class="current"'; echo ' > <a href="'.$v.'"> <span> ' . $k . ' </span> </a> </li> '; } }// End of foreach loop ?> </ul> </nav>
  13. I am working on chapter 12 and I want to generate a dynamic current class for the navigation links using php for the header.html. Can you help me with that? Thank you.
  14. Even I have tried to upload a file to a live server but it is not working. display_errors error is already on. That is really strange !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ==================================================================== ; http://php.net/display-errors display_errors = On ==================================================================== ; The display of errors which occur during PHP's startup sequence are handled ; separately from display_errors. PHP's default behavior is to suppress those ; errors from clients. Turning the display of startup errors on can be useful in ; debugging configuration problems. But, it's strongly recommended that you ; leave this setting off on production servers. ; Default Value: Off ; Development Value: On ; Production Value: Off ; http://php.net/display-startup-errors display_startup_errors = On
  15. ;;;;;;;;;;;;;;;; ; File Uploads ; ;;;;;;;;;;;;;;;; ; Whether to allow HTTP file uploads. ; http://php.net/file-uploads file_uploads = On ; Temporary directory for HTTP uploaded files (will use system default if not ; specified). ; http://php.net/upload-tmp-dir upload_tmp_dir = "C:\xampp\tmp" ; Maximum allowed size for uploaded files. ; http://php.net/upload-max-filesize upload_max_filesize = 2M ; Maximum number of files that can be uploaded via a single request max_file_uploads = 20
  16. I am working on File uploads and the script does not work. I have checked for php.ini and everything is fine. file_uploads = on ;upload_tmp_dir = upload_max_filesize = 2m max_file_uploads = 20 ===================== I am using windows 7. uploads folder is inside htdoc and the web root folder inside htdoc. ============================================================ How can I fix this issue? Thank you ================================================================== <h2> Upload An Image </h2> <?php # Upload An Image scripts. if($_SERVER['REQUEST_METHOD'] == 'POST') { // Check for an uploaded file: if(isset($_FILE['upload'])) { // Validate image type: $allowed = array('image/pjpeg', 'image/jpeg', 'image/JPG', 'image/X-PNG', 'image/PNG', 'image/png', 'image/x-png' ); if(in_array($_FILES['upload']['type'], $allowed) ) { // Move the file over: if(move_uploaded_file($_FILES['upload']['tmp_name'], "../uploads/{$_FILES['upload']['name']}") ) { echo '<p> <em> The file has been uploaded! </em> </p>'; }// End of move_uploaded_file } else { // Invalid type. echo '<p> Please upload a jpeg or png image. </p>'; } }// End of if(isset($_FILE['upload'])) // Check for an error: if($_FILES['upload']['error'] > 0) { echo '<p> The file could not be uploaded because: <strong> '; // Print a message base upon the error. switch($_FILES['upload']['error']) { case 1: print 'The file exceeds the upload_max_filesize setting in php.ini'; break; case 2: print 'The file exceeds the MAX_FILE_SIZE setting in the HTML form.'; break; case 3: print 'The file was only partially uploaded.'; break; case 4: print 'No file was uploaded.'; break; case 6: print 'No temporary folder was available.'; break; case 7: print 'Unable to write to the disk'; break; case 8: print 'File upload stopped.'; break; default: print 'A system error ocurred.'; break; }// End of SWITCH. print '</strong> </p>'; } // End of error IF. // Delete the file if it still exists: if(file_exists($_FILES['upload']['tmp_name']) && is_file($_FILES['upload']['tmp_name'])) { unlink($_FILES['upload']['tmp_name']); } } // End of the main submition if statement. ?> <form style="margin:10px;" action="upload_image.php" method="post" enctype="multipart/form-data"> <input type="hidden" name="MAX_FILE_SIZE" value="524288" /> <fieldset> <legend> Select a jpeg or png image of 512KB or smaller to be uploaded: <p style="margin:10px;"> <strong>File: </strong> <input type="file" name="upload" /> </p> </legend> </fieldset> <p> <input type="submit" name="submit" value="Upload" /> </p> </form>
  17. // Process checkbox: if(isset($scrubbed['service'])) { $service = $scrubbed['service']; } else { $service = NULL; $errors[] = "<p class=\"errors\">Please check some of the boxes. </p>"; } <fieldset class="checkbox"> <p>Service type: </p> <ul> <li> <input type="checkbox" name="service" id="service-one" value="one" /> <label for="service-one"> service-one </label> </li> <li> <input type="checkbox" name="service" id="service-two" value="two" /> <label for="service-two">service-two </label> </li> <li> <input type="checkbox" name="service" id="service-three" value="three" /> <label for="ervice-three"> service-three</label> </li> <li> <input type="checkbox" name="service" id="other-service" value="other-service" /> <label for="other-service"> Other </label> </li> </ul> </fieldset>
  18. I am trying to create a form with check boxes so the data will be sent by email. When two boxes are checked, only one value is passed. Can you show me how to get and validate check boxes data so I can use a booking form on the website? Thank you
  19. I am looking for a script to add a search feature on a website. Can you help me find that script? Thank you.
×
×
  • Create New...