Jump to content
Larry Ullman's Book Forums

ashez2ashes

Members
  • Posts

    12
  • Joined

  • Last visited

Everything posted by ashez2ashes

  1. I'm having a silly problem with using mysql from the command line in Windows. Ocassionally, I forget a quotation mark around a string and enter the command. Then the prompt is stuck at this symbol '> How do I clear this mistake (I assume the command did not get entered into the database? or am I wrong?) without exiting sql completely?
  2. Oh, okay. So there isn't some basic syntax that I was forgetting. I had been wanting to call strip_tags for all of the variables but kept wondering if I was doing a bunch of unecessary steps. I had some vague notion that it could be done, but if every function takes a unique number of arguments then I must have been remembering one that did. Thanks that really set my head on straight.
  3. I finished PHP Visual Quick Start Guide 4th edition and now I'm on to PHP and MySQL for Dynamic Web Sites. I decided not to skip ahead to the new info and use the begining chapters as a refresher course. There's one thing I'm confused about and I admit, I really should know this. I'm confused on the syntax of how to use a function on multiple variables in the same expression. For instance, if I wanted to use the strip_tags() function on the $comments, $email, and $name variables in the same expression how would that look? I apologize in advance if I'm not using the right vocabulary to explain myself.
  4. After looking through the PHP manuel, am I correct in that scandir doesn't scan the files in subdirectories? And to do what I want to do I'd have to make an array for each chapter folder or make a new function?
  5. I'm confused. I'm on ch11 script 11.5 list_dir.php. I've been structuring my files for the books exercises differently than what is the book default. So far I've been able to adjust the code, but I'm stumped this time. The file structure I'm using on my xampp server (with htdocs being the webroot) is: htdocs/phpbook/ch1/file.php or htdocs/phpbook/ch2/file.php etc. I want the script to display all of the exercies I've done so far in the book in all of the chapter folders. The file list_dir.php is located at htdocs/phpbook/ch11/list_dir.php . I got it to show the chapter directories, but I can't get it to show the files within those chapter folders. I thought changing the directory in the second foreach loop to: $search . '/../' . $item would work but it does not. Any help you can give me would be really apprettiated. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR...ransitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Directory Contents</title> </head> <body> <?php //Script 11.5 - list_dir.php date_default_timezone_set('America/New_York'); $search_dir = '../.'; $contents = scandir($search_dir); print '<h2>Directories</h2> <ul>'; //For each loop for directories. foreach($contents as $item) { if ( (is_dir($search_dir . '/' . $item)) AND (substr($item, 0, 1) != '.') ) { print "<li>$item</li>\n"; } } print '</ul>'; //Make a table for the files print '<hr /> <h2>Files</h2> <table cellpadding="2" cellspacing="2" align="left"> <tr> <td>Name</td> <td>Size</td> <td>Last Modified</td> </tr>'; //Foreach loop for files. foreach($contents as $item) { if( (is_file($search_dir . '/' . $item)) AND (substr($item, 0, 1) != '.')) { $fs = filesize($search_dir . '/' . $item); $lm = date('F j, Y', filemtime ($search_dir . '/' . $item)); print "<tr> <td>$item</td> <td>$fs bytes</td> <td>$lm</td> </tr>\n"; } } print '</table>'; ?> </body> </html>
  6. Nevermind I feel dumb. I typed student instead of students. I'm surprised it repeated that one name instead of showing nothing or giving an error message. Weird.
  7. Just wanted to follow up. I don't know if this will be helpful or not, but I'm on Chapter 7 and I think I just now fully understand the php manuel definitions (from what I've read at least).
  8. I'm stuck. I'm on chapter 7.5 sorting. I've checked it over and over and I can't find anything different from what I typed from the book's code. But it keeps coming up like this: I also tried emptying my internet cache and restarting but that didn't help. I tried on XAMPP and on my godaddy hostserver and got the same results. Here's the code I typed. ------------ <!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" xml:lang="en" lang="en"/> <title>My Little Gradebook</title> </head> <body> <?php // Script 7.5 - sort.php //Create the initial array $grades = array ( 'Richard' => 95, 'Sherwood' => 82, 'Toni' => 98, 'Franz' => 87, 'Melissa' => 75, 'Roddy' => 85, ); //Show what the array looked like before you sort it print '<p>Originally the array looked like this: <br />'; foreach ($grades as $student => $grade) { print "$student: $grade<br />\n"; } print "</p>"; //Sort and print the array in reverese order by value to show who has the highest grade arsort ($grades); print '<p>After sorting the array by value using arsort(), the array looks like this:<br />'; foreach ($grades as $students => $grade) { print "$student: $grade<br />\n"; } print "</p>"; //Sort the array by key to put them in alphabetical order by name ksort($grades); print '<p>After sorting the array by key using ksort(), the array looks like this:<br />'; foreach ($grades as $students => $grade) { print "$student: $grade<br />\n"; } print "</p>"; ?> </body> </html> -------------
  9. I bought the fourth edition ebook. I admit, I just started reading it. The part that got overwhelming was the explanation involving how to use the PHP Manuel. There is a lot of terminolgy there that the book hadn't covered. If the book covers that terminology in context later, I'll keep reading. I understand though that its probably there to help someone who already knows a programming language or two get into the book quicker. As an example, this sentence isn't something a complete programming beginner is going to understand: "In this example, the first value, int, says that print returns an integer value (specifically, print returns 1, always). Within the parentheses, string $arg states that the function takes one required argument, which should be in the form of a string. You’ve already seen this in action." Before that everything was making perfect sense and was quite easy to understand. I know that this a description of how the manuel presents information, but the terminology within that description hasn't been explained yet. Thanks for replying to my questions so quickly.
  10. Oh shoot, I apologize. I posted here in the wrong forum. I actually ended up buying both (I know to read the PHP and MySQL one later), but my question pertains to the Quick Start Guide. Sorry again. Is it possible to move this thread to the appropriate section of the forum? If I need to learn C first or just find a tutorial on basic concepts that's fine. I would just like to know before I spend money on another ebook. I actually started with reading "PHP and My SQL..." and read in the introduction that your PHP Quick Start Guide was better for beginners who already knew html/css so I bought the PHP Quick Start Guide instead.
  11. I was under the impression a person just needed to learn html/xhtml/css before learning PHP. However, when I started to read this book and got to the part about the PHP Manual the book started throwing tons of computer terminology at me it assumed I would already know (ex. function, variable, string, integer value, etc). Do I need to learn/read something else before starting on this book?
×
×
  • Create New...