Jump to content

btherl

Staff Alumni
  • Posts

    3,893
  • Joined

  • Last visited

Everything posted by btherl

  1. A class is like a template, or a description. An instance is a specific instance. For example, the Dragon class says what a dragon is like, and how a dragon works. An instance of a dragon is a specific dragon (that your hero is probably fighting). A description of a dragon can't fight a description of a hero. Only an instance of a dragon can fight an instance of a hero. Fert's code reduces the health of a specific dragon called $dragon, and a specific hero called $hero. Somewhere earlier you would have to have code like this: $dragon = new Dragon(); $hero = new Hero(); That takes the the classes that describe what dragons and heroes are, and creates one dragon and one hero from the description.
  2. Hmm.. I didn't proofread What I meant to say was "You can take things out of $_SESSION again, even during another run of your script". There's also the general rule that the thing on the left of the equals is the destination, and the thing on the right is the source (or the value). $a = $b will set $a to a new value, but $b will be unchanged.
  3. The second says "Keep the value of valid_user" The first says "Restore the value of valid_user" You can think of $_SESSION['valid_user'] as a storage place, where you can put things. But then you need to take them out again when you want to use them, even during another run of your script. $_SESSION is the storage container, and $_SESSION['valid_user'] is one particular object in the container.
  4. Can you post your new code, where you changed id to member_id? A blank page often indicates a syntax error in your php code (rather than an error in the mysql query). If you are able to, edit php.ini and set display_errors to on. Also, it's safe to write like this: echo "t<input type=\"hidden\" name=\"email\" value=\"{$row['email']}\"><br>\n"; instead of this echo "t<input type=\"hidden\" name=\"email\" value=\"$row[email]\"><br>\n"; The {} protects the variable from being misread, and the single quotes around email protect it from being misinterpreted as a defined value. Your code will usually work without those, but occasionally it may not.
  5. Better still, use die("Error in $strsql\n" . mysql_error()); That will show you the query you tried to run (which very likely has a syntax error or a mistyped column name).
  6. session_start() will allow you to store variables in the $_SESSION[] array. But I don't see that array used in your code. Variables outside of $_SESSION will not be kept between script runs.
  7. I think he is asking about use of a variable for the email address. You can do if($autotype == 1) { $header = "From: you@domain.com \r\n"; $email = "recipient@domain.com"; mail($email, "Subject", "Thank you for your request We will be in touch in 24 hours", $header); } Similarly, you can replace the subject and/or the message with a variable. If you are still having trouble, please post your full code for us to look at (for just 1 of the forms). There may be a problem with getting data from the form into the variables as well.
  8. A standard method is: 1. Generate a random name for each generated document 2. Store them all in one directory 3. Have a script run regularly that checks for old files (using fstat()) and deletes anything older than a fixed limit, say 1 hour. You can run the script from cron, or have it run each time a user accesses a particular script. That doesn't detect when the file is downloaded, because that's a very difficult task.
  9. That can be achieved by resizing the image and/or changing the format. For example, bmp is an uncompressed format, whereas gif, jpg and png are compressed formats. I can't give you the details unfortunately as I don't know them
  10. Did you get the point of my previous post? The reason PHP doesn't recognize $image_lib as an object is because $imagelib is the object.. without the underscore. It's a very common mistake to make in a language that doesn't require declaration of variables.
  11. That's because you haven't removed the tab. A tab is an invisible character that appears when you press the tab key on the keyboard. Move the cursor to immediately after your ENDOFTABLE marker and hit "del", and that should delete the tab. Do the same for the end of the heredoc and the start.
  12. There's also a stage 3, which is submission of the form from stage 2. Try printing out the filename at each stage to find out where it is disappearing.
  13. You can do: $querystate=("SELECT DISTINCT state FROM `joomla_dealers`") or die(@mysql_error());
  14. You appear to have a tab after your heredoc delimiter Edit: It's in both the start and end lines.. looks like both of them need to go to satisfy heredoc's strict syntax.
  15. Mysql has a multiple table syntax listed here: http://dev.mysql.com/doc/refman/5.1/en/update.html Look towards the end for examples.
  16. It's a matter of style, but I prefer using temporary variables to nested functions. Instead of func(func2($a), func2($b)); you can use $f_a = func2($a); $f_b = func2($b); func($f_a, $f_b); The second version is also easier for debugging for 2 reasons: 1. You can print out intermediate values. 2. The line number of the error will specify one function, not one set of nested functions.
  17. You can use "GROUP BY game" at the end, or you can use "SELECT DISTINCT game" at the start. Which is more appropriate depends on your situation. If you are selecting other columns as well, you need to think of what to do with the multiple values you have for those rows. Again, how you deal with that depends on the situation.
  18. You can use strtotime() and date() to achieve that. Both those functions are listed here: http://sg.php.net/manual/en/ref.datetime.php strtotime() will convert the mysql date into a timestamp, and date() can format the timestamp according to your specification.
  19. Write your queries like this, and you'll get helpful error messages: $sql = "UPDATE TABLE news SET title='$title' WHERE story_id='1'"; $res= mysql_query($sql) or die("Error in $sql\n" . mysql_error()); It takes more time to type, but it will save you MUCH more time in debugging. And you can just copy and paste. The other option is to make a small function that does error checking for all your queries, and use that wrapper function instead of mysql_query()
  20. btherl

    cURL

    Here's one with some of the standard examples (found via google search) http://www.higherpass.com/php/Tutorials/Using-Curl-To-Query-Remote-Servers/ I'm someone who learns best by looking at examples, so that's why I've given you that one I didn't see any video tutorials.
  21. Try working on your subquery first. Can you post the entire query? It doesn't matter if it's long. Once your subquery works properly, then you can add either GROUP BY or DISTINCT to remove the duplicates. Something like this ought to work: SELECT country FROM ( SELECT country FROM t1 UNION ALL SELECT country FROM t2 ) AS all_countries GROUP BY country The subquery will return all the countries, and then the GROUP BY will remove duplicates. You could replace the GROUP BY with a DISTINCT at the start for the same effect.
×
×
  • 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.