Jump to content

premiso

Members
  • Posts

    6,951
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by premiso

  1. 1: #1b It is just easier and allows for comments on each variable if needed. 2: #2b I do not see how making them with _ helps any (other than to the person looking over the code), just an extra character. 3: #3a Might as well conform to the standards and use the keywords that they created for you, which will also potentially add security to your script. 4: #4a camelCase, just from my Java days it was a habit and it just makes it easier if you ask me to do and helps make less mistakes. <?php class myClass { public $myVar1; private $myVar2; protected $myVar3; public function myFunction() { } } ?>
  2. Yea, I attempted to use one of those when I started programming. I got through maybe the first chapter when I decided it was BS and decided to just try and create scripts I wanted, such as a file system stat counter, and learn that way. It worked fairly well But I actually started with Javascript and cookies as I wanted a hit counter for the user. But I learned most of that from Webmonkey.com. Either way, yea those books are kind of a joke in my opinion.
  3. nl2br on the data when it is displayed will do it. Given that they entered the data in the text field and you did not strip the newline characters (\n).
  4. One part of your issue is: $postage_query = 'SELECT postage FROM postage WHERE country="$country"'; Is not a valid SQL statement as it uses single quotes around it's values and not double. $postage_query = "SELECT postage FROM postage WHERE country='$country'"; Should actually work. As for the SUM portion, if you want it with the country together here is the proper way to do it: $postage_query = "SELECT postage FROM postage WHERE country='$country' AND $sum BETWEEN start AND end"; EDIT:Reworking the above query / testing it as I am not sure that would work. Just tested it, and should work as long as it is really what you want. Hope that helps.
  5. You should be able to use strtotime to convert them to a unix timestamp to compare. If that does not work properly, you can use the explode with mktime function to create a timestamp for comparison. $time1 = strtotime("18:30"); $time2 = strtotime("07:30"); if ($time1 > $time2) echo "Correct";
  6. Well for one, you are not connecting to the Database first. You are connecting after. If you were to have: <?php mysql_query("SET NAMES 'utf8'") or trigger_error("Query Failed (UTF8): " . mysql_error()); ?> It would probably tell you as such. Put that after you make the connection and select the database and it should work. If that is not what you are after, please elaborate on how it is not working.
  7. Using session_set_cookie_params should allow you to make the session last longer. You should also be able to change this in the php.ini if you are able to so you do not have to have that code in there before the session_start each time.
  8. Post the code you are using as it is hard to see what is going wrong without the actual code.
  9. Chances are you are not putting the new file in the WWW directory where it needs to be put to display. This can be different depending on how you setup your system, did you by chance use WAMP? Or did you install them manually? You can find out what is the document root of the apache server by looking at the httpd.conf file and seeing what it has been set to.
  10. Please highlight line 64 of functions .php. To fix it you can use the isset on the offending line to first make sure that variable has been set, or make sure you are passing the variable in properly to the function.
  11. One item: if ($action = 'players') { is incorrect as that is the assignment operator. You want the comparison: if ($action == 'players') { As for the error, you get the syntax error after you turned on the error display or not? If not put it above the session_start call. Also make sure that your <?php is at the very top of the page and no spaces before it, as it will cause an issue with session_start. If you do receive the error, please post it and highlight the line it is occurring on.
  12. It is kinda funny how the small things are often the ones that are missed: }elseif(isset($GET['page'])){ Should probably be: }elseif(isset($_GET['page'])){
  13. I am glad you can spell "loosers" correctly when you are trying to flame. Good luck in your future endeavors!
  14. Use correct syntax. $sum = "$pri + $met =";
  15. Give and a try. Because if it is equal to anything but 4 or 5 you want to display the information: if ($res['cat'] != "Nothing" && $res['cat'] != "Something") { That is how you would display not equal to "4 or 5" just because there is an or in that statement does not mean that is what you want to use. Give it a try. The and statement, both those conditions have to be true to execute. So the cat cannot equal nothing OR something. If it does it will not execute. Your OR statement was always executing because if $res['cat'] was not "something" or not "nothing" then it would execute it. Hope that makes sense, kind of a hard thing to explain, but basically that OR statement you had originally would execute no matter what, because $res['cat'] cannot be both of those.
  16. If you have a date field, order by that. SELECT * FROM new ORDER BY `date_field`
  17. Because you are just concatenating a string. As far as I know the only way to do what you want is something like this: $pri = 1; $met = '+'; $sec = 1; switch ($met) { case '+': $answer = $pri + $sec; break; case '-': $answer = $pri - $sec; break; } You may be able to use eval but I would suggest against it. Here is how that would be done: eval('$answer = $pri ' . $met . ' $sec'); echo $answer; If you go that route make sure to filter your data, as eval can be dangerous if the data going into it is not checked / validated / filtered.
  18. You need to provide some more information, like what is $res['cat']? As if it is not Something or Nothing it will execute. Perhaps you wanted an AND instead of an OR?
  19. <input name="submit" type="button" value="submit"/> Should be: <input name="submit" type="submit" value="submit"/>
  20. There are a few things wrong here. First is your query: mysql_query("SELECT FROM SLIDESHOW foldername, image_name WHERE slide_id='$id'"); Should be: $res = mysql_query("SELECT foldername, image_name FROM SLIDESHOW WHERE slide_id='$id'"); Now the assignment of the folder and image name $folder=mysql_result($res, 0,0); $image=mysql_result($res, 1,0); Now you are trying to use variables inside of single quotes. When using $variable inside of single quotes they are taken literally and will display like that. So since you are using this on its own I would remove the single quotes (you could also replace them with double quotes). $folderPath = implode(DIRECTORY_SEPARATOR, array('..','client', $folder)); $imagePath = implode(DIRECTORY_SEPARATOR, array('..','client_images',$image)); echo $folder; echo $image_name; // Delete folder and contents. if (!is_dir($folderPath)) { I have not fully looked at the rest of your code, but hopefully that gets you going on what you need to work on / change.
  21. Chances are one of the script in your site includes a file from GET data. And you do not check if that file exists on your server and you do not limit it to a white list of pages. This is dangerous in many ways as if allow_fopen_wrappers is on then yea, it can execute a remote script and open your site up to security breaches like so.
  22. $content = "<?php "; $content .= "\$mysql_server = '$mysql_server';"; $content .= "\$mysql_username = '$mysql_username';"; $content .= "\$mysql_password = '$mysql_password';"; $content .= "\$mysql_database = '$mysql_database';"; $content .= "\$address ='$url';"; $content .= "\$desc ='$descrption';"; $content .= "\$name = '$sitename';"; $content .= "\$owner ='$ownername';"; $content .= "?>"; Is what you are looking for. You have to escape the $ inside of double quotes like shown.
  23. Its dangerous code whatever it is. Will allow someone who put it there to pretty much execute any code they want on your server with that eval.
  24. If I am not mistaken, you can do something like: INSERT INTO table (date_field, other_field) VALUES (DATE_ADD(NOW(), INTERVAL 1 DAY), 'other field stuff'); References: MySQL Date and Time Functions
  25. No, the champagne was only 12% alcohol, I had a bit much of Scotch
×
×
  • 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.