Jump to content

trq

Staff Alumni
  • Posts

    30,999
  • Joined

  • Last visited

  • Days Won

    26

Everything posted by trq

  1. 1) Get a better host. 2) Configure MySql to run on a more commonly available port.
  2. Your while loop overrides the $row variable. Whats to explain? while ($row=mysql_fetch_assoc($query2)){ Needs to be.... while ($row2=mysql_fetch_assoc($query2)){ or similar.
  3. The comparison operator is == not = if ($Address_type == 'school') Also, why all the calls to stripslashes()? If there is slashes in your data you are not escaping it properly on the way into the database.
  4. You realize the while loop overrides the $row variable?
  5. Don't use short <? tags. Variables don't need to be surrounded by quotes, array index do. This... <?php echo "$row[first_name]"; ?> Should be.... <?php echo $row['first_name']; ?> I don't see any closing } barace for that while loop.
  6. Is there a particular reason you want to use this php script via the cli? You can send mail in Linux using the 'mail' command provided by mailx. Firefox does not run in cli mode per say, but you can see its options by typing.... firefox --help in a terminal.
  7. I should create an example. Allot of jQuery plugins use it to define default options, which can latter be merged with user inputted options. eg; (function($) { $.fn.say = function(options) { var ops = { 'word' : 'Hello' }; return this.each(function() { if (options) { // here I merge the users inputted 'options' object // with my 'ops' object. $.extend(ops, options); } $(this).html(ops.word); }); }; })(jQuery); This is just a simple jQuery plugin that when called like..... $(document).ready(function() { $('div').say(); }); Would make all div's within a document contain the html 'Hello'. Now, using $.extend() we can override the word hello with 'goodbye'. $(document).ready(function() { $('div').say({word: 'Goodbye'}); });
  8. jQuery.extends (as the name implies) allows you to extend one object by merging another with it. The manual is pretty clear about the subject.
  9. No, I don't get you. $i=0; while (hasposts()) { if ($i % 3 == 0) { echo "break"; } else { echo $i; } $i++; } Whats the problem?
  10. for ($i = 0; $i <= 20; $i++) { if ($i % 3 == 0) { echo "break"; } else { echo $i; } }
  11. There are better ways to split the backend (bussiness logic) from the front end (markup) and they don't involve template engines. If anything, a template engine ties your front end even further to the back end.
  12. Instead of... echo $geshi->parse_code(); Try... $geshi->parse_code();
  13. Ive not used Geshi in a long while but according to the docs, parse_code returns void. I wouldn't echo it, I'm fairly certain its going to print the code itself.
  14. $request is an argument to the routeStartup() method. It is of type Zend_Controller_Request_Abstract.
  15. Yeah, that's exactly what you asked here. Anyway, moving on. $Array1 = array($user1, $user2, $user3, $user4, $user5, $user6, $user7, $user8); $result = array_count_values($Array1); if (isset($result['APPROVED'])) { echo $result['APPROVED']; } There's always the manual too you know? http://au2.php.net/manual/en/ref.array.php It really is the best way to learn.
  16. So.. explain what you want it to return.
  17. Im not going to critique the des because quit frankly, I think it's obvious. The markup however... have you heard of external style sheets? Mixing design with markup is a big no no and makes for a terribly hard to maintain site.
  18. $Array1 = array($user1, $user2, $user3, $user4, $user5, $user6, $user7, $user8); if (in_array('APPROVED', $Array1)) { echo count($Array1); }
  19. Is that 'you want to get the total count if the value "APPROVED" appears within the array?
  20. You should make a virtual host for it and put it within that virtual hosts root. See http://httpd.apache.org/docs/2.2/vhosts/
  21. This is generally done by creating an array within your php logic, and simply including that into your 'template' code. So, you would have a template that looked like.... template.php <?php foreach ($records as $record): ?> <?php echo ($odd) ? '<tr class="odd_row">' : '<tr class="even_row">';$odd = !$odd; ?> <td style="text-align: center; width:100px;"><?php echo $record['title']; ?> <table> <tr> <th colspan="2">Shipping Information</th> </tr><tr> <td>First Name:</td> <td><?php echo $record['title']; ?></td> </tr><tr> <td>First Name:</td> <td><?php echo $record['order_qty']; ?></td> </tr><tr> <td>Last Name:</td> <td><?php echo $record['product_code']; ?></td> </tr><tr> <td>Billing Address:</td> <td><?php echo $record['email']; ?></td> <td><?php echo $record['order_id']; ?></td> </tr> </table> </tr> <?php if (!$record['feedback']): ?> <form action="reputation.php" method="POST"><p>Please give the seller feedback on how you have received your product. <td><input type="hidden" name="name_id" value="' . $row2['name_id'] . '"></td> <td><input type="hidden" name="order_id" value="' . $row2['order_id'] . '"></td> <td><input type="submit" name="submit" value="Feedback"/></td> </form> <?php endif ?> <?php endforeach; ?> And your php..... whatever.php <?php include 'auth.inc.php'; include 'db.inc.php'; include 'buy.inc.php'; //connect to database. $db = mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_PASSWORD) or die ('Unable to connect. Check your connection parameters.'); mysql_select_db(MYSQL_DB, $db) or die(mysql_error($db)); $query2 = sprintf('SELECT d.name_id, d.order_id, d.order_qty, d.product_code, feedback, p.title, c.email FROM order_details d LEFT JOIN product p ON d.product_code = p.product_code LEFT JOIN contact c ON d.name_id = c.name_id WHERE d.buyer_id = "%u"', mysql_real_escape_string($_SESSION['name_id'])); $result2 = mysql_query($query2, $db) or die(mysql_error()); $odd = true; $records = array(); while ($row2 = mysql_fetch_array($result2)) { $records[] = $row2; } include 'template.php'; ?> That is the basic idea. Plenty of room for improvement however. You should take a look at the MVC pattern and in particular how allot of frameworks handle views.
  22. I should add that this changes when your talking about php includes. browsers can only see whats within the web servers document root. So a / at the begining means look in the web servers root. PHP (which runs on the server itself) has access to the entire file system, so a path beginning with / means the root of the filesystem.
  23. /SomeFile.php will always look in the web servers root for SomeFile.php SomeFile.php will look for a file called SomeFile.php in the same directory that the page your calling it is in. /MyFolder/SomeFile.php will always look for SomeFile.php contained within the MyFolder directory which is located within your web servers root. MyFolder/SomeFile.php will always look for SomeFile.php within a directory called MyFolder which is within the same directory as the file calling it.
  24. You thought wrong. A leading slash always represents your web servers root (in html, in php (or file system paths) it would represent your OS's root).
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.