Jump to content

Alex

Staff Alumni
  • Posts

    2,467
  • Joined

  • Last visited

Everything posted by Alex

  1. There's really no clear answer. Some people will argue for the single quotes, and some will suggest just the opposite. It also depends on your version of PHP. Either way there's no difference that you'll ever experience so it's really just up to user preference and convenience. For example, if you have a long string containing many double quotes it would be much easier to just use single quotes and avoid having to escape all the other double quotes.
  2. AJAX really isn't all that complicated, but it can be intimidating at first, if you're actually interested in learning the basics of it I'd suggest this tutorial. Is there any particular reason that you're using a JavaScript prompt? This seems like a much more appropriate task for a simple form, that way you don't need to mess around with cookies (which seem a bit unnecessary when just storing information for such a short period of time). If you insist on continuing with this method I suppose you could force a refresh to the page after the prompt is submitted with: location.reload(true); Then on the page using PHP you'd check to see if the cookie has a value, if it does get that value and send the email, clear the cookie, then output the prompt as normal. I'd really suggest just creating a simple form though.
  3. What you must understand is that PHP is a server-side language that runs once, sends the information to the browser and that's it. JavaScript is a client-side language that runs after the browser has received the output from the server. One way to accomplish this would be to do one at a time. Using JavaScript you would create the prompt, assign the cookie then query a page through AJAX to actually send the email.
  4. That shouldn't be happening. Is that the exact code that you're seeing this error with? I suspect not because you have a parse error there.. $echo $cat . " is " . $c . " years old."; Should be echo... (no $)
  5. I'm not gonna hold my breath, but yeah, it might be interesting..
  6. Do you just want to track this for personal knowledge just because you're curious? If that's the case it would really be easier to use some type of web analytic, personally I use Google Analytics, they'll give you that information and everything else you can think of. If you want the data to display it or something and you're going to go through with geoip just check out the manual, there are very clear examples such as this one here: geoip_country_code_by_name(). It's pretty straightforward.
  7. You can use PHP geoip if your server has it installed. Otherwise there's a lot of APIs you can take advantage of.
  8. No problem. By the way, there's a "Topic solved" feature, whenever a topic you posted is solved just make sure to mark it as solved, there's a button in the bottom left to do so.
  9. You're never setting $row, right after this line: $result = $database->query($q); You should have: $row = mysql_fetch_assoc($result); edit: That's my fault for not including it in my original code. :s
  10. Yea, or just changed it to COUNT(numbers) and $row['COUNT(numbers)'];
  11. Once you changed the table and column name to yours you would just do: $result = mysql_query($sql); $row = mysql_fetch_assoc($result); echo $row['COUNT(id)'];
  12. Something like this should do it: $sql = "SELECT question FROM table2 WHERE question_id NOT IN (SELECT question_id FROM table1 WHERE emailaddress = 'test@test.com') ORDER BY RAND() LIMIT 1"; $result = mysql_query($sql); echo $row['question'];
  13. Here's an example: $input = '251'; $sql = "SELECT COUNT(id) FROM table WHERE column LIKE '%" . implode("%' OR '%", str_split($input)) . "%'"; I misunderstood what you were asking. Instead try something like: $input = '251'; $sql = "SELECT COUNT(id) FROM table WHERE column LIKE '%" . implode("%' AND '%", str_split($input)) . "%'";
  14. Alex

    WTF!?

    Nearly 100 lines of more or less creating alias functions.. wonderful. Unfortunately this happens a lot.
  15. Actually, judging by the output the OP stated there's no delimiters used in the database record. The spaces you're seeing are actually the spaces separating first and last names.
  16. It's because implode() takes an array and separates each element and makes a string using the first parameter as a delimiter. In your code $arr only contains one element( $row_getJournalAuthors['name'] ), so nothing is actually done. Can you show us an example of what $row_getJournalAuthors['name'] contains?
  17. There are ridiculous amounts of typos in programming books (At least in all the ones that I've read). You'd think they would've been proofread by at least a few people who have enough experience to catch these things..
  18. Alex

    The || trap

    $id = '0'; $id !='0' || $id !='1' The literal is if $id is not 0 or $id is not 1. Only one of the two conditionals must hold true for the or to evaluate to true completely. So if $id is not 0, it's true, but if $id is not 1 it is also true.
  19. Besides the fact that it's vulnerable to mysql injections (Which you can correct by escaping $id with mysql_real_escape_string()) I don't see anything immediately wrong with that code. Exactly what isn't working?
  20. Oh, now I understand what you mean. You might consider using imagettftext() as it includes an angle parameter for drawing the text.
  21. Well that's because imagestringup() (as you can see in the manual) returns true or false depending on whether or not the operation was successful, which is not what imageroate() expects Exactly what're are you trying to do?
  22. Your problem isn't with how fast PHP runs, it's more than likely a problem with your code. Post your code so we can help you correct it.
  23. Yes it'll work as long as you're including the file before you're trying to use the variable. You would use it the same as any other variable.
×
×
  • 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.