Jump to content

Fyorl

Members
  • Posts

    273
  • Joined

  • Last visited

    Never

Everything posted by Fyorl

  1. OK, I have no idea what's going on now. Try putting: echo "I can has cheezeburger"; at the top as well (make sure var_dump() and echo aren't inside the if() statement!)
  2. I just had a quick look through the documentation. CURLOPT_SETTIMEOUT isn't even on the curl_setopt page so I have no idea where I got it from now. From the description CURLOPT_CONNECTTIMEOUT looks like the one I want but it obviously doesn't work for some reason as I was already using it. I might just use your suggestion and go with CURLOPT_TIMEOUT to make sure the load times are snappy though. Thanks though!
  3. Fyorl

    Tutorials

    Hmm there was a good one in Linux Format a while ago I think. I don't know if you'll find an online version though. Setting up a server, PHP and MySQL can be a bit crazy if you're not sure what you're doing though. I would recommend installing something like XAMPP (google it) if you want to do testing on your own computer. Otherwise you'll need a web-host that has PHP and MySQL installed. Once you've got that you should be able to find some decent tutorials on this site.
  4. I would do the grouping in PHP rather than SQL. I don't know which method is more efficient though.
  5. Yeah people can turn it off but most either don't know how or just don't. Either way, the javascript validation is good for useability as people can be told of slight errors without having to load another page, be told that there were errors and they go back and change them. You shouldn't rely on javascript to do your validation for you though. Validate with javascript and PHP if you can.
  6. OK, at the top of script.php (under the <?php bit though) can you put: var_dump($_POST); and tell me what you get?
  7. getimagesize() should work with absolute paths...
  8. Where is the .txt file stored? It needs to be in the same directory as script.php and be writeable by everyone (777 permissions most likely).
  9. One option would be to create a 'fake' popup window. E.g. Use a combination of HTML and Javascript to make a floating div containing the chef's info etc. The advantage of this is you can use normal CSS to size the 'window' to fit the text perfectly. Also, styling scrollbars is a bad idea as that CSS only works in IE and so everyone who uses a different browser won't see them.
  10. Your last SQL query should generate an error because you've got too many quotes: "UPDATE userpic SET public = '0' WHERE userid = '$dir' AND Picture = '$pc''" should be: "UPDATE userpic SET public = '0' WHERE userid = '$dir' AND Picture = '$pc'" You might want to try putting 'or die(mysql_error())' (without the quotes) after your queries. Also, you should echo the values of $dir and $pc to make sure they're what you're expecting.
  11. What's the significance of 16? I'll try it but I don't think it will make any difference as the script seems to be ignoring the timeout and waiting 20 minutes for the absent server to respond. Have you had any success with using 16? What I mean is, has there been a time when the script has actually had to stop trying to connect due to a timeout?
  12. Sorry to go off-topic here but actually, no, you don't get a warning about the undefined constant. That would only happen if you used {$row[Picture]}. In that case, {$row['Picture']} would be needed however if no curly braces are used then using $row[Picture] will have the desired effect without generating any level of errors. I have tested this insofar as I always use it when expanding arrays inside strings. I only ever use the curly brace notation when doing object calls as they don't work without curly braces.
  13. Ah but you're forgetting that some of us are really bored and have nothing better to do =P Firstly, I'm not sure how valid this HTML is but the following should work: <label> <div align="center">Make an ITEM To put in the Bank!.<br> <br> <form action="script.php" method="post"> <input name="textfield" type="text" id="textfield" value=""> <br> <br> <input type="submit" name="button" id="button" value="Submit"> </form> </div> </label> Then in script.php: <?php if(isset($_POST['button'])) { $fname = 'items.txt'; $data = str_replace(' ', "\n", $_POST['textfield']); if(version_compare(phpversion(), '5.0.0', '>=')) { file_put_contents($fname, $data); } else { $h = fopen($fname, 'a'); fwrite($h, $data); fclose($h); } } ?>
  14. I've got a function that gets some XML data from a server. Unfortunately the server isn't very reliable so I've used curl_setopt() with a CURLOPT_SETTIMEOUT value of 5. Here's some reference code to better understand: $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $this -> url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_USERAGENT, $userAgent); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5); $xml = curl_exec($ch); curl_close($ch); I'm unsure as what it supposed to happen. If it times-out, will $xml be false? At the moment I'm assuming that behaviour and loading the data from cache if $xml is false. The only problem is that whenever the server is unavailable, the script just takes forever to execute and doesn't seem to be timing-out at all. In actual fact there's some really weird things happening which I have no idea about but I just wanted to check first that this part of the code isn't the problem because it seems like the most obvious place where things are going wrong.
  15. The onsubmit handle was calling a javascript function when the form is about to be submitted. It looks like the function was meant to check the form was filled in properly and then either stop the form submitting (if the form was filled out incorrectly) or allow the form to submit normally. You presumably didn't have that function defined and so it was always returning false and therefore not submitting.
  16. Well if you want a specific solution you'll need to post the HTML that you're using for your form and tell us how you want the data to be formatted in the file.
  17. It means your form data isn't reaching your script properly.
  18. Fyorl

    simple

    <?php $fname = 'file.php'; if(!file_exists($fname)) { header("Location: file2.php"); exit; } ?> Edit: Sorry, joecooper's should work just as well but I didn't see his updated code before I posted.
  19. Your input's name is 'agree' but you're using 'accept' in your code.
  20. Really? I've never encountered one before and my error_reporting level does include E_NOTICE.
  21. I'm not 100% sure here as I'm not really familiar with what you're doing in that query but will the following not achieve the comment count: $sql = " SELECT COUNT(*) FROM `news_comments` WHERE `news_id`='$id' "; $data = mysql_query($sql); $numcomments = mysql_result($data, 0);
  22. @thorpe: The curly braces around the variable aren't necessary for simple arrays like that. @madspof: You obviously haven't tried my code because it will work. You're escaping the $ character which means PHP treats it as a normal character rather than the start of a variable.
  23. You need: echo "<a href='makep.php?p=$row[Picture]'>protect from public </a><br><br></div>";
  24. Well that's one of the most popular themes for WordPress. I hardly think it'd get popular if it was unreadable. Admittedly the code is difficult to read but the normal text outside the code blocks is fine unless you're using a stupidly low contrast or it's really bright where you're sitting...
  25. Well I've tried setting a lighter background colour for code blocks but it just makes the site look awful. *sigh* I'm useless with colour schemes...
×
×
  • 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.