Jump to content

lemmin

Members
  • Posts

    1,904
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by lemmin

  1. I'm sorry, you apparently can't do that in MySQL. My mistake. I supposed you DO need to query for the LIMIT value first. Was there an error returned by the code in your first post? It's hard to tell since you didn't post a real query in your first post, but I think the problem is with the parameters. If you use your original code and change these lines, it might fix the problem: $sql2 = "SELECT id, subject FROM newsdat WHERE category = ? ORDER BY id DESC LIMIT ?"; $stmt2->bind_param('ii', $catNumber, $howmany);
  2. I don't see anything wrong with the code. When anything dealing with cookies happens "sometimes," you are probably looking at caching issues. I'm guessing either the cookie is not in the state you think it is, or Wordpress is caching a page or variable.
  3. I've had this exact same problem! If only I could remember how I fixed it. I'm currently letting my computer search for "json_decode" in my archives. In the mean-time, something like this should get rid of any leading characters: substr($string, strpos($string, '{')); I seem to remember feeling stupid when I figured out what was causing it for me. That solution should work, but I will let you know if I find anything else.
  4. What is the error? Have you tried using mysqli_stmt_prepare()? if (mysqli_stmt_prepare($stmt, "SELECT * FROM toptips")) { From the documentation of mysqli::init_stmt(): http://www.php.net/manual/en/mysqli.stmt-init.php http://php.net/manual/en/mysqli-stmt.prepare.php
  5. Just paste the line I posted in place of your "if" line and it should work.
  6. Something like this? http://www.9lessons.info/2009/09/php-login-page-example.html
  7. Too many dollar signs. You should only have one dollar sign on $sqlinsert.
  8. The problem is that mysql_query() expects parameter 1 to be string and you gave it a resource . mysqli_query() accepts the connection resource as the first parameter, not mysql_query(). You can fix it by taking the first variable out of the function call: if (!mysql_query($sqlinsert)) {
  9. Just concatenate the variable: $airport = $_GET['airport']; $URL = "http://www.weather.com/activities/travel/businesstraveler/search?where=".$airport."&start_with=1&search_loc_type=9&x=5&y=13"; Or however you get your airport variable.
  10. Why are you setting POST options if you are using get? GET variables are passed through the URL, so you can just append them like you would see it in the browser: $URL = "http://www.weather.com/activities/travel/businesstraveler/search?where=phx&start_with=1&search_loc_type=9&x=5&y=13"; If there are no special headers or anything, you might as well use file_get_contents() or fopen().
  11. What you should be doing is scraping for ONLY the data that you need, then format it however you want to. Especially since the HTML on that web site is horrible. BUT, if you want to do it that way: <form id="theform" method="GET" action="/description.php"> <input type="hidden" name="manga" value="value"/> </form> <?php $file_contents = file_get_contents('http://eyemanga.com'); preg_match_all('/<table width="100%".+?<\/table>\s*<\/td>\s*<\/tr>\s*<\/table>/ims', $file_contents, $matches); $tables = $matches[0]; $html = ''; foreach ($tables as $table) $html .= preg_replace('/(<a[^>]+href="([^"]+)")/', '$1 onclick="document.forms.theform.manga.value=\'$2\';document.forms.theform.submit();return false"', $table); echo $html; ?>
  12. str_replace replaces ALL occurrences, so your loop is just overwriting $codetest with different values every time. You want to do something like this: <form id="theform" method="POST" action="/description.php"> <input type="hidden" name="manga" value="value"/> </form> <?php $file_contents = file_get_contents('http://eyemanga.com'); preg_match_all('/<a href="([^"]+)"/', $file_contents, $matches); foreach ($matches[1] as $link) echo '<a href="" onclick="document.forms.theform.manga.value=\''.$link.'\';document.forms.theform.submit();return false">'.$link.'</a><br/>'; ?>
  13. Try something like this instead: $file_contents = file_get_contents('http://eyemanga.com'); preg_match_all('/<a class="cvr" href="([^"]+)"/', $file_contents, $matches); foreach ($matches[1] as $link) echo '<a href="'.$link.'">'.$link.'</a>';
  14. You can actually do this: "SELECT STUFF FROM table LIMIT (SELECT howmany FROM news WHERE id = ? LIMIT 1)"
  15. You should definitely be using header() for something like that. You should have your script go through all of the logic before outputting any information. This allows you to completely change the location without going out of the way to send information to the browser to tell it to change pages.
  16. I have to guess that the server is explicitly rejecting your server. Can you telnet that server from your web server? What happens if you try to put a different URL from that server into your file_get_contents() function?
  17. You might have to give more information about your setup. Is the websocket open on the same server as your PHP script? Is the websocket open using PHP?
  18. Interesting. Are you behind a proxy? What happens if you change the URL to just http://www.google.com? Those two config settings shouldn't cause any problems. Does the owner of this website know you are doing this? It is possible they banned your IP simply because you were using too much bandwidth.
  19. It IS possible, but more likely to be a memory constraint by your server. I know you say no errors are thrown, but when file_get_contents() fails, it should at least be throwing a warning. I think your server configuration is preventing them from being displayed altogether. Try adding this above your code: ini_set('display_errors', 1);
  20. I'm guessing your web server doesn't like PHP trying to allocate that much memory. Try a lower number like 128M. That should be more than enough.
  21. The datetime type uses the format YYYY-MM-DD HH-MM-SS. I don't know of a way to convert a twelve-hour time to twenty-four with MySQL so you might have to extract the data, convert it in PHP using strtotime(), then update your table. You can just make a new field, update the data, then drop your other five fields after the new data is in.
  22. If you are just asking how to make an anchor link send POST data, you can't without using Javascript. You can either use AJAX or some workaround like this: <form method="POST" action="/description.php"> <input type="hidden" name="manga" value="value"/> <a href="anything" onclick="this.parentNode.submit();return false">link</a> </form> If you have a bunch of them it would probably be better to do something like this: <form id="theform" method="POST" action="/description.php"> <input type="hidden" name="manga" value="value"/> </form> <a href="anything" onclick="document.forms.theform.manga.value='something';document.forms.theform.submit();return false">link</a> <a href="anything" onclick="document.forms.theform.manga.value='somethingelse';document.forms.theform.submit();return false">link</a> You really should just use GET
  23. I'm guessing it's your query you're having trouble with. The whole thing would be much easier if you just had one datetime field in your database. The datetime data type can store all of the data that your five different fields store separately. Then, your query could just be: SELECT * FROM table WHERE datetime_field >= NOW()
×
×
  • 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.