Jump to content

requinix

Administrators
  • Posts

    15,229
  • Joined

  • Last visited

  • Days Won

    427

Everything posted by requinix

  1. That response is all messed up. JSON and a PHP dump? Wrong Content-Type? Or maybe it's just what you posted here? json_decode the response body.
  2. mcrypt_create_iv() and openssl_random_pseudo_bytes() can both do it. Unless Jacques says something, in which case I won't come back in here.
  3. None of that makes any sense. Are you in the right thread?
  4. What's onEventDeleted? Something is firing off that event and that is where you need to put the confirmation dialog.
  5. If you don't manage the server then there's nothing you can do. As for how to use cURL, here is a basic example.
  6. The page is being refreshed because of that location.reload(), so if you don't want that to happen then don't put that code in there. Is the .alert-success (which you should probably put an ID on rather than relying on just the class name) visible? As in it doesn't have a display:none or something? If it is, and probably should be, then you need to .show() it too.
  7. Is mail() returning true or false? Have you checked your spam/junk folders? Try using a library like PHPMailer to send emails instead. It is much more sophisticated than simply calling mail() and with it your emails have a higher likelihood of not being detected as spam anyways.
  8. If you need to process that file on your server then you'll need to get a copy of it to your server somehow. Even if that copy is just in memory, there's no way around retrieving the contents. As for disk space, if you download a copy to a file then there's no reason why you can't delete the file when you're done with it. Try using cURL to see if it behaves differently.
  9. You want to give them a URL to your site but have it download files from some other site? Would it be enough to support the URL on your site but do a redirect, which most people won't know or care about? You can if you put them in [code] tags. I've already done it for you.
  10. There are two root problems here that you can't really solve: 1. The Kp index is not completely accurate, in the sense that you cannot state "a rising value indicates a possible aurora" nor "a falling value indicates an aurora is ending" - the alternative meanings probably being due to random fluctuations and/or margins of error*. 2. Given two "high" Kp values, you don't know for sure whether they correspond to two different (chances of) auroras. For example, a change from 5->7 could indicate an increasing chance of the same aurora (such as 3->5->7) or the chance of a second aurora (as in 7->5->7). Consider that the rising or falling Kp value is not an event itself but rather the symptom of an event. That is, after all, what it actually represents. What you want to do is notify users of the aurora event (or more precisely, a particular likelihood of an aurora in the near future), and do to so you use the Kp index to decide when one might start and when one might have ended. As such the question is not whether you should send a notification at a certain Kp value but whether the new measurement does/does not belong to a particular aurora event that has/has not had a notification sent. Follow that? Honestly, I would pick a method, go for it, and see how it performs. Maybe you offer different options to the user so they can decide how they want their notifications? My first attempt would be with your last option: define the beginning of aurora event as being a series of consecutive Kp values above some threshold for some period of time and the ending as consecutive Kp values below some threshold for some period of time. Here are two examples of that approach: a) Auroras begin with Kp >= 5 for 10 minutes; auroras end with Kp b) Auroras begin with Kp >= 6 for 20 minutes; auroras end with Kp Also note that the second example has a buffer of uncertainty, where the Kp value can fall 6->5 for a while without being considered the end of an aurora. * Speaking of margins of error, you may want to round the figures you receive. Like to the nearest tenth? Fifth? Because the hundredth between 6.99 and 7.00 shouldn't be treated as a significant difference.
  11. LanceL, are you looking to hire/pay somebody to solve this for you? Or were you looking more for help with PHP so you can do it yourself?
  12. What are you doing to advance the time? If you did that part properly then the date would advance when it should automatically.
  13. Please don't make me lock this thread, guys. Yes, we could have easily answered the question. I (or anyone) could have posted the answer, you would have copied it, seen it working, and been on your way. But would you have learned anything? Not really. Well, maybe: it's possible you're one of those types who will take code given to them and try to understand what it does, but in my experience the majority (not everyone) of people who ask programming questions on the internet are not like that. So I gave you a couple bits of code that will (should) get you most of the way to the answer. rwhite35 talked about putting variables in strings. Jacques1 suggested you use a templating engine so you don't have to deal with embedding PHP code into HTML. But not even all of that combined would not have given you the complete solution. And that's the point. The normal process is that someone posts some code to help, OP comes back saying it doesn't work, we ask how it doesn't work and what their code is, they post, we tell them what they're missing, they figure it out, and we're done. Sometimes repeating those last couple steps a few times. Hopefully OP learned what was going on so that next time they come across a similar problem they will be able to say "oh, I recognize this situation from a problem I had earlier - I wonder if the same sort of solution will work for it too". We avoid giving out answers not because we want to annoy but because we want people to learn, and being fed answers doesn't really do it. Unfortunately not everyone understands that, and those people will spend months or years coming back asking simple questions because they aren't learning - or worse they quit after a couple threads because we didn't tell them the answer and they get frustrated and ragequit. You seem to get that we're trying to help you learn. Yes, sometimes threads get sidetracked and sometimes the discussion gets heated and sometimes people get offended. It happens because we're human. How about we take a step back, reconsider what this thread is supposed to be about, and go back to where we left off in that normal process? You have some code that isn't working. If you only put the code I posted into what you had then you're still missing something to make it work. So: what is the code you have now and how is it not working?
  14. Load the XML into SimpleXML $xml = new SimpleXMLElement("http://steamcommunity.com/profiles/76561198283429063/?xml=1", 0, true);then use SimpleXML's "simple" means of accessing information. Keep in mind that most of what you get from it will be objects and not strings so you'll probably want to (string)-typecast stuff. If you have a problem with something in particular then post your code and an explanation of what's going wrong.
  15. Remember that code I posted yesterday? Have you tried to do anything with it? If you're still wondering where to put it then you should think about what the code is doing and where it would make sense for it to go.
  16. Without any error checking, $h = fopen("file.txt", "rt"); while (!feof($h)) { $title = trim(fgets($h)); $url = trim(fgets($h)); // output } fclose($h);
  17. Try dumping the $_SESSION in the Admin page where it fails the login check. Apparently something is different between the two page loads and what's in (or not) the session may explain that. If your session data isn't too complex then you can error_log(json_encode($_SESSION));Or to the screen, but then the header redirect won't work (which would be fine for this).
  18. Is it possible that the login code is executing after those checks?
  19. requinix

    Json help

    Forget that for a moment and focus on the error message. And on fixing whatever caused it.
  20. requinix

    Json help

    Warning: Creating default object from empty value in /home3/aundie/public_html/dandewebwonders.com/BBProject 4/Controllers/Controller.php on line 41 {"data":[{"Id":"1","FirstName":"Chico","LastName":"Escuela","HomeTown":"San Juan, PR","Bats":"L","Throws":"R","Team":null},{"Id":"2","FirstName":"Christopher","LastName":"Henry","HomeTown":"Pittsburgh, PA","Bats":"","Throws":"","Team":null},{"Id":"3","FirstName":"Travis","LastName":"Hubbard","HomeTown":"Boise, ID","Bats":"","Throws":"","Team":null},{"Id":"4","FirstName":"Richard","LastName":"McCoy","HomeTown":"Austin, TX","Bats":"","Throws":"","Team":null},{"Id":"5","FirstName":"Al","LastName":"Torres","HomeTown":"Baltimore, MD","Bats":"","Throws":"","Team":null},{"Id":"6","FirstName":"Everett","LastName":"Greer","HomeTown":"Wilmington, DE","Bats":"","Throws":"","Team":null},{"Id":"7","FirstName":"Johnnie","LastName":"Joseph","HomeTown":"St. Paul, MN","Bats":"","Throws":"","Team":null},{"Id":"8","FirstName":"Milton","LastName":"Osborne","HomeTown":"Davidson, TN","Bats":"","Throws":"","Team":null},{"Id":"9","FirstName":"Dewey","LastName":"McDonald","HomeTown":"St. Louis, MO","Bats":"","Throws":"","Team":null},{"Id":"10","FirstName":"Ervin","LastName":"Lawrence","HomeTown":"Anaheim, CA","Bats":"","Throws":"","Team":null},{"Id":"11","FirstName":"Thomas","LastName":"Copeland","HomeTown":"St. Petersburg, FL","Bats":"","Throws":"","Team":null},{"Id":"12","FirstName":"Christian","LastName":"Shelton","HomeTown":"Akron, OH","Bats":"","Throws":"","Team":null},{"Id":"13","FirstName":"Jackie","LastName":"Harris","HomeTown":"Rochester, NY","Bats":"","Throws":"","Team":null},{"Id":"14","FirstName":"Bob","LastName":"Barnes","HomeTown":"Newark, NJ","Bats":"","Throws":"","Team":null},{"Id":"15","FirstName":"Woodrow","LastName":"Zimmerman","HomeTown":"Baltimore, MD","Bats":"","Throws":"","Team":null},{"Id":"16","FirstName":"Willard","LastName":"Harrington","HomeTown":"Glendale, AZ","Bats":"","Throws":"","Team":null},{"Id":"17","FirstName":"Orville","LastName":"Gregory","HomeTown":"Reno, NV","Bats":"","Throws":"","Team":null},{"Id":"18","FirstName":"Tony","LastName":"Jennings","HomeTown":"Denver, CO","Bats":"","Throws":"","Team":null},{"Id":"19","FirstName":"Benjamin","LastName":"Hawkins","HomeTown":"Philadelphia, PA","Bats":"","Throws":"","Team":null},{"Id":"20","FirstName":"Andre","LastName":"Wells","HomeTown":"Kansas City, MO","Bats":"","Throws":"","Team":null},{"Id":"21","FirstName":"Rafael","LastName":"McDaniel","HomeTown":"Norfolk, VA","Bats":"","Throws":"","Team":null}]}
  21. You don't really need to worry about dealing with arrays here. Both of the things you want to do only manipulate strings - it's just that the strings you want are inside of an array. 1. The first character of a $string is easy to get using $string[0]. Works just like an array. And yes, it also works with things besides a simple variable. $firstnameinitial = $lrow['firstname'][0];2. strlen() tells you the length of a string. Use an if to set a new variable with the displayable name of the team according to your rule. Then substr() to get a substring. if (strlen($lrow['rteamname']) > 25) { $teamname = substr($lrow['rteamname'], 0, 25) . "..."; } else { $teamname = $lrow['rteamname']; }Now use those two new variables in your echo.
  22. Huh. How did I miss that? I even scrolled down to see the rest of the if block... Okay. There's two things that need to change: supporting empty uploads, of course, but there's a larger problem of SQL injection where apostrophes in any of the fields (for example) will cause your INSERT to fail. At best; a malicious user could instead do damage to your database. Fixing that problem will also change how you deal with the empty uploads so you should do that first. The solution is with prepared statements. Instead of $sql = "INSERT INTO events VALUES(id, '{$title}', '{$date}', '{$time}', '{$desc}', '{$presenter}', '{$file_name}', '{$file_size}', '{$file_type}')"; mysqli_query($con, $sql) or die (mysqli_error($con)); echo "Success";you do $sql = "INSERT INTO events VALUES(id, ?, ?, ?, ?, ?, ?, ?, ?)"; $stmt = mysqli_prepare($con, $sql); mysqli_stmt_bind_param($stmt, "ssssssss", $title, $date, $time, $desc, $presenter, $file_name, $file_size, $file_type); // probably should be more like // $stmt->bind_param("ssssssis", $title, $date, $time, $desc, $presenter, $file_name, $file_size, $file_type); // because $file_size and whatever the column in the events table is are both numbers and not strings mysqli_stmt_execute($stmt);With that changed, all you have to do for an empty upload is set $file_name, $file_size, and $file_type to null. (And make sure the table supports NULL in those three columns.) So modify the upload logic to look something like switch (error status) { case successful: do the rest of the upload handling, including error checking; break; case no file uploaded: set those three variables to null; break; other cases:... }(which references the switch I posted earlier)
  23. Split from Parse Error. Are you saying you have the exact same problem as the other poster?
  24. 1. The first piece of code doesn't have any SQL stuff in it. It doesn't make sense to me that the second piece should go with it. Surely there's more code somewhere else that also does an INSERT? You should be modifying that so it can support an empty image, rather than making a whole new INSERT just for that one case. 2. The first piece of code doesn't support an empty image. I think it will complain about an invalid extension. You need to use the upload "error" status (a) period, because you can't just assume that the upload was successful, and (b) to tell if no file was uploaded. $file_error = $_FILES['image']['error']; switch($file_error) { case UPLOAD_ERR_OK: // okay break; case UPLOAD_ERR_INI_SIZE: case UPLOAD_ERR_FORM_SIZE: // file is too large break; case UPLOAD_ERR_PARTIAL: // file upload did not complete break; case UPLOAD_ERR_NO_FILE: // no file was uploaded break; case UPLOAD_ERR_NO_TMP_DIR: case UPLOAD_ERR_CANT_WRITE: case UPLOAD_ERR_EXTENSION: default: // system error preventing the file from being uploaded break; }
  25. If the web server still supports PHP then yes, you can probably make a simple email script that takes data like the send_mail.php did. How much PHP do you know?
×
×
  • 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.