Jump to content
Larry Ullman's Book Forums

Search the Community

Showing results for tags 'php'.



More search options

  • 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


Found 183 results

  1. On page 117 Larry forgot to enter this line of code at the beginning of the script. if ($_SERVER['REQUEST_METHOD'] === 'POST') { Larry should post a full forum post with all the errors in this book to help us out, it is very frustrating having to try and make scripts work with errors in them, especially when we are not as experienced as Larry. I will post every error I find in this book in this forum as well as the solutions. So far I have found 3 errors in the book and I am only at chapter 5.
  2. What is the difference between mysqli_real_escape_string and escape_data(). When should we use escape_data() as opposed to mysqli_real_escape_string.
  3. In the ecommerce book, in chapter 3, you include files like so: include('./includes/header.html'); doesn't include('includes/header.html') do the same thing? Why use the ./ I don't understand. This wasn't covered in the other book I read from you php and mysql 4th edition.
  4. I'm used to using $_POST to handle my form data. In chapter 2, Mr Ullman states to use $_REQUEST. I did look up $_REQUEST on php.net and it says that it contains data for $_GET, $_POST, and $_COOKIE. Does that mean I no longer need to bother with $_GET or $_POST and just use $_REQUEST going forward? Sorry for the amateur question. I've done some PHP programming in the past and I'm trying to get back into it (hopefully in the correct way). Thank, James
  5. Here is my directory structure currently in the public html folder. uploaded_images (folder) allmyotherphpfiles.php allmyotherphpfiles.php allmyotherphpfiles.php allmyotherphpfiles.php Should the uploaded_images (folder) be stored outside the public html folder, so that hackers can't hack that folder, or is it safe to leave my folder like it is now.
  6. Spammers are sometimes visiting my new website and entering false data in my register.php script. The result is that they don't register and several php error log messages are emailed to me. I get an error message email for each form field that has an undefined index. I would like to know how to stop getting these emails. Here is a copy of a section of the error message email. An error occurred in script '/home/strawb15/public_html/examplesite.com/register.php' on line 40: Undefined index: emailArray ( [_GET] => Array ( ) [_POST] => Array ( [username] => hebirchfijose [usermail] => aulbachpuid@sohu.com [userpass] => E970d483- [usersex] => 1 [userliving] => 16 [bdayy] => 1930 [bdaym] => 3 [bdayd] => 12 [imgcode] => [formsubmit] => Y [submit] => 確定 ) [_COOKIE] => Array ( ) [_FILES] => Array [_SERVER] => Array ( [CONTENT_LENGTH] => 173 [CONTENT_TYPE] => application/x-www-form-urlencoded [DOCUMENT_ROOT] => /home/strawb15/public_html/examplesite.com [GATEWAY_INTERFACE] => CGI/1.1 [HTTP_ACCEPT] => text/html,application/xhtml+xml,application/xml;image/png,image/jpeg,image/*;q=0.9,*/*;q=0.8 [HTTP_ACCEPT_ENCODING] => gzip [HTTP_ACCEPT_LANGUAGE] => en-us;q=0.7, en;q=0.3 [HTTP_CACHE_CONTROL] => max-age=259200 [HTTP_CONNECTION] => keep-alive [HTTP_HOST] =>www.examplesite.com [HTTP_REFERER] =>http://www.examplesite.com/register.php [HTTP_USER_AGENT] => Mozilla/5.0 (Windows NT 6.1; WOW64; rv:34.0) Gecko/20100101 Firefox/34.0 [HTTP_VIA] => 1.1 117-30-149:55336 (s.r577) [HTTP_X_FORWARDED_FOR] => 162.211.122.43 [PATH] => /bin:/usr/bin [phpRC] => /home/strawb15/public_html [QUERY_STRING] => [REDIRECT_STATUS] => 200 [REMOTE_ADDR] => 218.203.13.233 [REMOTE_PORT] => 13417 [REQUEST_METHOD] => POST [REQUEST_URI] => /register.php [sCRIPT_FILENAME] => /home/strawb15/public_html/examplesite.com/register.php [sCRIPT_NAME] => /register.php [sERVER_ADDR] => 23.235.206.99 [sERVER_ADMIN] => webmaster@examplesite.com [sERVER_NAME] => www.examplesite.com [sERVER_PORT] => 80 [sERVER_PROTOCOL] => HTTP/1.0 [sERVER_SIGNATURE] => [sERVER_SOFTWARE] => Apache [uNIQUE_ID] => VXgCnBfrzmMAAHvJFtIAAAA3 [php_SELF] => /register.php [REQUEST_TIME_FLOAT] => 1433928348.53 [REQUEST_TIME] => 1433928348 [argv] => Array ( ) [argc] => 0
  7. I just built a website with the tactics in this book. I am looking for a small script to resend the activation link in case someone didn't get it. Any ideas on how I should make it.
  8. I am creating a forum for my site from the example in this book. I want to include a feature to my new forum where people can see the number of views a thread has had. Does anyone have any ideas on how I could code that.
  9. I have my own website that I am trying to install clean search engine friendly urls on. I am doing this for the article page section of my site. I have it working except for a glitch. I am comparing my setup with that of this website and others which use htaccess clean urls. So basically I have my url which is like the following. http://stackoverflow.com/questions/9183130/php-htaccess-apply-page-title-in-url it works when I click on it and everything is fine. but if I take a part of the url like so: http://stackoverflow.com/questions/9183130/php-htaccess-apply-pag and refresh it still works which is ok. but the url doesn't return to the former one, it stays like that, missing part of the title in the url. I can't figure out how to make it revert back to the original url. All pages which seem to use clean urls have it working like that. here is my htaccess rule. and then I will show you the link I am using to link to the page. RewriteEngine On RewriteRule ^article/([0-9]+)/([a-zA-Z]+) article.php?id=$1&title=$2 $punctuation = array('$', '-', ',', '/', '\\', '!', '.', ' ', '*', '&', '?', '%', '\'', '<', '>', '[', ']', '(', ')'); $real_title = str_replace($punctuation, '-', $row5['title']); $real_title = str_replace(' ', '-', $real_title); $real_title = strtolower($real_title); $real_title = mysqli_real_escape_string($dbc, $real_title); <a href="http://www.example.com/article/'.$row5['article_id'].'/'.$real_title.'">'.$row5['title'].'</a>
  10. Right now on my website I created when someone is logged in they can go to the url in the address bar and change the id number associated with the url. for example one page I have is add_image.php?id=4 4 is the id associated with the article. If someone changes the 4 to a 7 for example. Then my page will show the other user's data on my page without them even entering that other person's login info. How do I make sure people can't see other user's data when they change the id number. I am using the scripts from this book. Maybe I missed something. I am using sessions properly as far as I can tell. I really would need some help with this. please give an example of secure code to use. thank you
  11. Hello! I'm doing the appendix test PHP and SQL page and i keep getting a 'object not found' page. The requested URL was not found on this server. Can anyone fill in what i maybe doing wrong here. I checked the spelling it's not that.
  12. I want to get the primary key values of movie and actor table. When i selected values in radio button primary key has been created automatically to the movie and actor table. Now I want to get that primary key value and insert to the movie_actor table. my code connect.php <?php $dbc = mysqli_connect('localhost','root','black98765','db_name') OR die("Cannot connect to MySQL:" . mysqli_connect_error()); //insert into actor table $q = "INSERT INTO actor (name) VALUES ('$actor')"; //insert into movie table $q2 = "INSERT INTO movie (movie_name, release_year) VALUES ('$movie','$year')"; //movie_actor table $q3 = "INSERT INTO movie_actor (movie_no,actor_no,rate) VALUES ('$rate')"; //what value i need to put inside values for movie_no and actor_no? //connect and insert $q $r = mysqli_query($dbc,$q); $r2 = mysqli_query($dbc,$q2); $r3 = mysqli_query($dbc,$q3); if($r && $r2 && $r3){ echo "Inserted Successfully!"; }else{ echo "Failed to Insert Data!"; mysqli_error($dbc); } mysqli_close($dbc); ?> form.php <?php if(isset($_POST['submit'])){ if($_SERVER['REQUEST_METHOD'] == 'POST'){ $error = array(); //choose actor if(!isset($_POST['actor'])){ $error[] = "Please choose of the following actors!"; }else{ $actor = $_POST['actor']; } //choose movie if(!isset($_POST['movie'])){ $error[] = "Please choose of the following movies!"; }else { $movie = $_POST['movie']; } //choose release year if(!isset($_POST['year'])){ $error[] = "Please choose of the following release year!!"; }else{ $year = $_POST['year']; } //choose rate if(!isset($_POST['rate'])){ $error[] = "Please choose of the following rate!"; }else{ $rate = $_POST['rate']; } //if no errors if(empty($error)){ require('connect.php'); }else{ echo "<p>System Error!</p>"; foreach($error as $msg){ echo $msg."<br/>\n"; } } } } ?> <form action="form.php" method="POST"> <p>Select on the following Selections</p> <p><label for="actor">Name of Actor:</label> <input type="radio" name="actor1" value="Jet Li"/>Jet Li <input type="radio" name="actor2" value="Sylvester Stallone"/>Sylvester Stallone <input type="radio" name="actor3" value="Jason Statham"/>Jason Statham</p> <p><label for="movie">Name of Movie:</label> <input type="radio" name="movie1" value="Expendables 3"/>Expendables 3 <input type="radio" name="movie2" value="Rocky"/>Rocky <input type="radio" name="movie3" value="Kiss of the Dragon"/>Kiss of the Dragon</p> <p><label for="movie">Release Year:</label> <input type="radio" name="year1" value="2014"/>2014 <input type="radio" name="year2" value="1976"/>1976 <input type="radio" name="year3" value="2001"/>2001</p> <p><input type="submit" name="submit" value="Insert"/></p> </form>
  13. 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.
  14. Hi I am using the footer script provided often in this book. And i am getting the following error from my website's error email log message. ob_end_flush(): failed to delete and flush buffer. No buffer to delete or flushArray Is there something we need to do to prevent from getting this error. I looked online and found one answer, can anyone tell me if this is the correct thing to do for this problem. Or should I take another look at my scripts for errors. if (ob_get_level()>1){ ob_end_flush(); } thank you
  15. I have a client complaining that the php mail form I made is not working. He is not able to retrieve any mail from his web page. As a check, I substituted his email address with two of my own. They each worked as they should though he claims they still aren't reaching him. As I see it, the mail is definitely being sent from the web form page. If they are not getting to him, the only thing I can think of is Outlook is filtering them. Is mail sent from using php "mail" different enough from other mail to cause it to look like spam? Or something nefarious? thanks, for helping Chop
  16. I am using the php mail function on my site for user registration, so that the user receives an email confirmation link to click on when he registers. However during testing not every email address receives the confirmation email and sometimes after sending it, I can't send email to that email address anymore, no email gets through. what could be causing it. I am using the php mail function exactly like it says in this book.
  17. I am using a live site and the error message shouldn't be displayed on my website but it is. I don't know why. The error message it shows online is Could not connect to MySQL: Access denied for user 'moreaw32_grah2'@'localhost' (using password: YES) . When other errors occur on my site it does not show the detailed message. I don't want it to show the details of my database like my user name which it does show. Here is the line of code in my connection script. $dbc = @mysqli_connect (DB_HOST, DB_USER, DB_PASSWORD, DB_NAME) OR die ('Could not connect to MySQL: ' . mysqli_connect_error()) What can I do to prevent this.
  18. Hello, I have PHP file (file1.php) asking for a date: echo '<form action="charts.php" id="form_chart_date" method="post"> <div id="form_chart_date"> <p>Please select date. </p> <p><input name="date_looking" type="text"> <input type="submit" value="Display data" name="display_chart"></p> </div> </form>'; After submission file1.php handles the process but there is reference to JavaScript file which reads PHP generated JSON file. JavaScript file looks like: (document).ready(function() { var date = "<?php echo json_encode($_POST); ?>"; $.ajax({ data: {date_looking: date}, url: "http://localhost:8888//live_site_local/www/json.php", dataType: "JSON", type: "POST", cache: false, success: function(pieData) { var ctx = $("#chart-area").get(0).getContext("2d"); new Chart(ctx).Pie(pieData); } }); }); If I replace variable date with something like: var date = "2015-01-01"; then everything works ok. It looks like the problem is that I can not pass PHP $_POST array to JavaScript. Here is the line from PHP file (json.php) that generates JSON object. $date_looking = $_POST['date_looking']; Does anyone know what I am doing incorect? Thanks
  19. I am building a site from the info in this book. And the post I am writing as you read this has a toolbar at the top that allows me to add bold to text, and other cool options. Where could I get a toolbar like this for my website, so I can add it to form fields.? The main thing I am looking for is adding paragraphs when people type 2 carriage returns on their keyboard. So that the text area form field behaves like as if you are typing in a word processing document. Adding bold to text, italics, and underline would be great too, but as a beginner I can accept if the paragraphs is all I can handle code-wise. I do know some javascript, so if coding it involves that I might be able to. Any ideas on how to go about this would be wonderful!
  20. The select query below returns 1 row when it should be 3. I am pretty sure it is because of the AVG(k.sumtotal) field. If I rewrite the query and take out that AVG(k.sumtotal) column and take out the FROM inv_ratings AS k, I get my 3 rows. I looked online for hours trying to find information about returning results using the AVG clause and didn't find much. Do I have to use a group by clause, I tried that and only get errors. If it is a group by clause please type the exact group by clause to use if you could. thank you. $p = "SELECT i.invention_id, i.inv_title, i.date_submitted, i.category_id, i.approved, c.category_id, c.category, u.image_name, AVG(k.sumtotal) FROM inv_ratings AS k INNER JOIN inventions AS i USING (invention_id) INNER JOIN categories AS c USING (category_id) INNER JOIN images AS u USING (invention_id) WHERE c.category_id = $cat AND i.approved = 'approved' HAVING u.image_name < 2 ORDER BY date_submitted DESC LIMIT $start, $display"; $q = mysqli_query($dbc, $p) or trigger_error("Query: $p\n<br />mysqli Error: " . mysqli_error($dbc));
  21. In the following code would you leave the part in where it says or trigger error and so on, on a live site mysqli_query($dbc, $i) or trigger_error("Query: $i\n<br />mysqli Error: " . mysqli_error($dbc));
  22. I am building a forum from the example in the book, and I am having trouble getting the page numbers to work like they should, right now the thread results don't update when you click on other page numbers, it is always the same query results on every page. Here is some code where I think the problem is, but I can't find it. I would post the whole page's code, but I have done that before and didn't get many helpers for that. The query I am using is $sql = "SELECT t.thread_id, t.subject, u.username, COUNT(p.post_id) - 1 AS responses, MAX(DATE_FORMAT($last, '%e-%b-%y %l:%i %p')) AS last, MIN(DATE_FORMAT($first, '%e-%b-%y %l:%i %p')) AS first, w.forum_id FROM threads AS t INNER JOIN posts AS p USING (thread_id) INNER JOIN forums AS w ON t.forum_id = w.forum_id INNER JOIN users AS u ON t.user_id = u.user_id WHERE w.forum_id=$forumid AND t.lang_id = {$_SESSION['lid']} GROUP BY (p.thread_id) ORDER BY last DESC"; $query = mysqli_query ($dbc, $sql); At the top of my forum.php page I am using this code to identify which forum the threads belong to. if (isset($_GET['id']) && is_numeric($_GET['id'])){ $forumid = $_GET['id']; } elseif (isset($_POST['id']) && is_numeric($_POST['id'])) { $forumid = $_POST['id']; } else { echo '<p class="error">This page has been accessed in error.</p>'; include ('includes/footer.html'); exit(); } Here are the page links, modified to include the forum_id in the url. if ($pages > 1){ echo '<br /><p class="center4">'; $current_page = ($start/$display) + 1; // If it's not the first page, make a Previous button: if ($current_page != 1) { echo '<a href="forum.php?s=' . ($start - $display) . '&p=' . $pages . '&id='.$forumid.'">Previous</a> '; } // Make all the numbered pages: for ($i = 1; $i <= $pages; $i++) { if ($i != $current_page) { echo '<a href="forum.php?s=' . (($display * ($i - 1))) . '&p=' . $pages . '&id='.$forumid.'">' . $i . '</a> '; } else { echo $i . ' '; } } // End of FOR loop. // If it's not the last page, make a Next button: if ($current_page != $pages) { echo '<a href="forum.php?s=' . ($start + $display) . '&p=' . $pages . '&id='.$forumid.'">Next</a>'; } echo '</p>'; // Close the paragraph. } // End of links section. thanks for taking a look.
  23. 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; }
  24. 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>
  25. 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 . '" />'; }
×
×
  • Create New...