Jump to content

Daniel0

Staff Alumni
  • Posts

    11,885
  • Joined

  • Last visited

Everything posted by Daniel0

  1. echo $_GET['username']; 1. Buy a newer book. Your book sucks (apparently). 2. Post in the correct forum. 3. Use tags when posting code. 4. Don't end each sentence with multiple dots. 5. It is spelled "what", "your" and "you", not "wat", "ur" and "u". Only people who type [i]really[/i] slowly would benefit from such (annoying) abbreviations. 6. Its != it's.
  2. Ah ok, but another time, please just include it in a new post. Try this: <?php // connect to db here... $result = mysql_query("SELECT d.*,c.* FROM documents AS d LEFT JOIN categories AS c ON d.cat_id=c.cat_id"); $categories = array(); if(mysql_num_row($result) > 0) { while($document = mysql_fetch_assoc($result)) { if(!key_exists($document['cat_id'], $categories)) $categories[$document['cat_id']] = array(); // to prevent E_NOTICE $categories[$document['cat_id']][] = $document; } foreach($categories as $cat_id => $documents) { echo "<strong>{$documents[0]['cat_name']}</strong><ul>"; foreach($documents as $document) { echo "<li>{$document['doc_title']}</li>"; } echo "</ul>"; } } else { echo "No documents..."; } ?>
  3. Try $Results = shell_exec("mysqldump --allow-keywords --opt -u$User".!empty($Password) ? ' -p'.$Password : null." $DatabaseName > $File"); In that way you'll only send the -p argument if the password isn't empty.
  4. SELECT d.*,c.* FROM documents AS d LEFT JOIN categories AS c ON d.cat_id=c.cat_id; Should do that.
  5. Not. mysql_real_escape_string() will take care of all "dangerous" characters for queries.
  6. You probably need to install Zend Optimizer. It looks like it has been encoded with Zend Guard.
  7. [REPLY] You don't need to prefix your post with "[PROBLEM]". It is sort of obvious that it is a problem when you're posting in a help forum
  8. You shouldn't use globals like that. It'll make your code less reusable. I'd probably go with the last example.
  9. RoR isn't a language.
  10. Daniel0

    Geese

    You have to - it's an irregular word.
  11. Yes. mysql_fetch_assoc() will return false when there are no more rows left. The while loop stops if the statement is false.
  12. <?php // connect to db here $result = mysql_query("SELECT * FROM table"); if(mysql_num_rows($result) > 0) { echo "<select name='whatever'>\n"; while($r = mysql_fetch_assoc($result); { echo "\t<option value='{$r['id']}'>{$r['name']}</option>\n"; } echo "</select>"; } else { echo "No items in database"; } ?>
  13. I'm quite sure she meant it as a joke . You can use software like the one neylitalo suggested - it's free. It isn't particularly difficult. Just point, click and drag (and release).
  14. Try to echo $time1 and see what it says to check if you get the time correctly. What is the time in $time1 supposed to be? The time of the last update? What is $outtime supposed to be used for?
  15. What goes into "minus"? The prices?
  16. Make an HTML form where you can select (using a <select>) the date or enter it into an input field. Send the data to the PHP script and insert them into the query. Run the query and fetch the results and echo them.
  17. Try this <?php $con = mysql_connect("sql address","username","password") or die('Could not connect: '.mysql_error()); mysql_select_db("database", $con); $prices = array(); foreach(array('london', 'oslo', 'cairo', 'shanghai', 'paris', 'dublin', 'rio', 'stockholm', 'athens', 'montreal', 'washington') as $city) { $prices[$city] = mt_rand(99, 999); } list($time1) = mysql_fetch_array(mysql_query("SELECT pricetime FROM drugs")); $outtime = time()+(24*60*60); //24hours $time4= $time1-time(); if($time4<=0) { $sets = array(); foreach($prices as $city => $price) { $sets[] = "{$city}price='{$price}'"; } mysql_query("UPDATE drugs SET ".join(',',$sets)." WHERE drugname = 'pot'"); } mysql_close($con); echo "$outtime <br>"; echo "Time 4: $time4 <br>"; ?> You might want to reconsider your database layout. It's better to store each city as an entry for itself rather than having a lot of fields.
  18. Please use tags and not [quote] tags for code.
  19. SELECT * FROM whatever ORDER BY id ASC But it should already be sorting the results ascending.
  20. Why wouldn't you be able to do this? o_O <?php foreach($row as $r) { echo $r.'<br />'; } ?>
  21. Set it to auto increment, or is that not what you mean?
  22. ids must be unique. That's not the problem though. It should work. Try print_r($_POST); on the page which your form leads to.
  23. The point of a DDoS (distributed denial-of-service) attack is that a lot of computers (also called zombie computers) try to access the site simultaneously a lot of times to use all the bandwidth and/or system resources so other users cannot use the site (thus the name "denial-of-service"). Some sites that are submitted to sites like Digg crash if they make it to the front page. Essentially it's the same thing happening except that the intentions are not evil, and that it is not one person who controls the other computers, but a lot of visitors visiting the page within a short amount of time.
  24. That would be a bad idea. extend is for extending the functionality of a class. That is not what you wish to do in this case so you should not use extend. You should rather create a new object and access it like e.g. $db->whatever();.
×
×
  • 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.