Jump to content

Yucky

Members
  • Posts

    81
  • Joined

  • Last visited

    Never

Everything posted by Yucky

  1. Fix: echo "<img src='http://datenight.netne.net/images/".$info['img']."' title='".$info['username']."' width='50' height='50'>";
  2. I used quick tags for brevity in the example. Apart from that, there's not really anything wrong with it. It seems to be the cleanest and quickest way of doing what he wanted.
  3. A bit rough, but here goes: <table width="300" border="1" cellspacing="0" cellpadding="0"> <?php foreach($yourArray as $key => $value): switch($value['yourCategory']) { case 1:$colour = "00000";break; case 2:$colour = "FFFFFF";break; } ?> <tr> <td bgcolor="#<?=$colour;?>"><?=$value['yourCategoryName']; ?></td> <td bgcolor="#<?=$colour;?>"><?=$value['yourCategoryData']; ?></td> </tr> <?php endforeach; ?> </table> Wouldn't be too hard to move the logic into the function that returns your data array.
  4. Your question doesn't really make any sense. What are you trying to achieve?
  5. I've told him this several times already. By default, HTML files will not be parsed by PHP.
  6. I said earlier that the file should be .php, not .html.
  7. You have to run the script on a proper server that supports PHP. You can't just preview PHP scripts in your browser.
  8. Given that you may want to return data to be displayed on the page as well as error messages, it seems logical to use multidimensional arrays. I find that it's easier to stick with one structure even when I don't need to send data/error messages back to the user rather than possibly changing it later down the line.
  9. Did you remember to use session_start();? Edit: Beaten to the punch.
  10. Using an array to hold errors is pretty standard. Have you considered using a multidimensional array instead? When I need to display errors to the user, I tend to use a multidimension array that might have a structure along the lines of: $array['data'][] - data needed be displayed goes in this subarray. $array['errors'][] - informative error messages are stored in this subarray and later looped through. $array['success'] - true/false. Helps to determine styling such as a tick or a cross.
  11. There's not anything you can do to prevent automated form filling. You can however try and prevent automated form submission through the use of captchas.
  12. Yucky

    Help

    Change: $qry = "SELECT * FROM users WHERE username='$_POST['username']'"; To: $qry = "SELECT * FROM users WHERE username='".$_POST['username']."'"; Take care with double/single quotes. With your original code, PHP would have seen $_POST[ and then been cut off by the single quote.
  13. As it doesn't sound like a big site, you should look at using a single include file that would contain your functions. I don't think including business logic (essentially the code that makes your site work) in your presentation (HTML/CSS) is ever the right thing to do.
  14. I think you have it wrong also. using OO in php doesn't mean writing a class for everything you do, it would be more of a time consuming process then just plain old simply functions. I don't believe mixing programming paradigms in such a fashion is good style. If you're going to use OOP, stick to it throughout. I didn't advocate writing a class for every function that didn't fall nicely into an existing class. Having a utilities/misc class with static functions seems like an acceptable solution. I'm more than open to arguments in favour of switching between procedural and OO though.
  15. I guess he's trying to say that all of the PHP code is displaying in his browser. I did consider that it wasn't being parsed at all but I concluded that he meant that only the code in the text field was being displayed. Make sure the document extension is .php and not .html or some variant. If that fails to work, make sure you actually have a working PHP installation on your server.
  16. Those are unicode characters. Try parsing it with the correct character set. See http://www.utf8-chartable.de/
  17. If you set a session in the URL, a user's session can be maintained even if they have cookies disabled.
  18. Just to be clear, if they selected Tuesday, would you want last week's Tuesday or the last Tuesday gone?
  19. Perhaps short tags aren't enabled. Try <?php echo $random_number; ?> instead of <?=$random_number;?>.
  20. Are you talking about includes here or totally different scripts? If the former, it'd be slightly quicker to have everything in one file. However, you'll be using more memory if you're including code that isn't relevant to the action being performed. If the latter, I doubt it makes any difference whatsoever.
  21. Ask them to find out why it triggered the spam filter. He might be able to find out by checking the headers.
×
×
  • 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.