Jump to content

mikesta707

Staff Alumni
  • Posts

    2,965
  • Joined

  • Last visited

Everything posted by mikesta707

  1. BTW if (is_array ($errors)) { $display_errors = true; } will always be true because of this line $errors = array(); the array() function will always return an array, even if you don't give any data. an empty array is still an array. you probably want to check the count or something like if (count($errors) > 0){//there were errors
  2. If your images change all the time, than I would suggest using a database like raytri says. You don't need the Union operator though, thats used when you want to join the results from two result sets, and there is no need for that here since you would only need one. If they stay static for the most part, than you could just use an array instead of having to make a database. Similar to what ray said, you could use the shuffle() function which will take an array and make it random. for example $images = array("img1.jpg", "img2.jpg", "img3.jpg"); shuffle($images); foreach($images as $image){ echo $image . "<br />"; }
  3. depending on what files you want to rename (if its all, only gifs, etc.) you can use the rename() function in combination with glob(). something like this would work for all file types (assuming you are in the same directory $files = glob("*.*");//get all files in directory (note, if you need to set //the directory, you should so something like glob("/path/to/*.*"); foreach($files as $file){ //$file is each individual file //replace spaces with underscores $new_file = str_replace(" ", "_", $file); rename($file, $new_file);//rename file } a little side note, you can add an if statement using the logic that PFMaBiSmAd suggested to only rename files with spaces if you want
  4. you can get the value of a select box the same way you get the value of any submitted input tag. just use its name attribute as the index in the POST/GET array //get the value of the available options value $options = $_POST['availableOptions'];
  5. Haha, thats pretty awesome, I should totally spy on my user's history now, and bring it up at the most awkward possible situation as I can
  6. This is not PHP looks like Java
  7. It would help if you pointed out which line line 24 is. But my guess would be $glowT=$hay[1][2]->{$tankId}->{'game_info'}->{1}->{"open_time"}; you are using the number 1 as some classes attribute name. As the error pointed out, property names must be strings. I don't know how that class is structured tho, so I can't be much more help than that
  8. you could just use sessions, and check if one is set if (isset($_SESSION['whatever'])){ //they are already viewing } But that may lead to unwanted results. For example, if you have that check doing something like if (isset($_SESSION['var'])){ //don't let the user play } else { //let them play } then if the user refreshes the page, they won't be able to play again until they close the connection to the server (IE closing the page/browser)
  9. well first off all, your show_error() function <html> <body> <b>Fields with red astericks are required. <br />Please correct the following error:</b><br /> <?php echo $myError; ?><br /> <a href="javascript:history.go(-1)">Go back</a> </body> </html> You should leave out the html/body tags. First off, if you have multiple errors (which you might) you will have multiple html/body tags, which not only is invalid html, but will prevent you from seeing other stuff (because the main body tags, which are the first that appear, have been closed).
  10. It looks pretty good. Your CSS/Javascript/HTML is all over the place, and you should think about organizing it a little better so the page isn't as cluttered. You need to check verify stuff with PHP too. You're register javascript validation works (to make sure they put in all the correct stuff) but if I turn javascript off, I can register with empty data. I can also log in with empty data too, and the login works after I created an account with empty data. You do use mysql_real_escape_string() on your data, which is good. That flash calender is kind of annoying. You also probably want to apply html entities to your comments. I can inject html in there, and can do harmful things to your site
  11. $query=mysql_query("SELECT * FROM logins, users WHERE logins.loginID=users.userID AND Email_Address='".$_POST['username']."' AND password='".$_POST['password']."'"); $result=mysql_query($query); if you read the error message, it tells you exactly whats wrong. mysql_query takes a string that is parsed as a query. the function returns a result resource. You are doing mysql_query twice for no real reason. get rid of $result=mysql_query($query);
  12. Apparently, human trials for a substance that promotes "phenomenal" muscle growth is getting close http://singularityhub.com/2009/12/08/super-strength-substance-myostatin-one-step-closer-to-human-trials/ It is going to be interesting to see the dynamic of the geek/nerd, bully relationship once this "substance" becomes available to the public.
  13. $query is a mysql resource, which is why it says "Resource ID#3" However, since its not NULL, it seems that the query is executing fine. Are you sure that your query would return results? check your database, and make sure that the row you are trying to extract is indeed the same. If you are using md5 or another hash, you need to hash the password.
  14. firstly put your code in code/php tags. secondly this line $ME= $SCRIPT_NAME; I don't see where $SCRIPT_NAME is defined, unless its defined in one of your two requires. When you saw that code, it probably relied in a setting in php.ini called register_globals set to one (basically it would take the global variables, like $_SERVER['SCRIPT_NAME']; and make variables with the same name as their index values) I suggest you keep register_globals set to off, as it can be a security risk. You should just use the $_SERVER['SCRIPT_NAME'] variable
  15. Well, if you want to store the content of some page into the "content" attribute of your class, than file_get_contents() would work without much changes to your code. Using includes is very simple tho. If I wanted to include, say, form.php in my page on some condition, i could do if (something) include "form.php"; and if something was true, it would include the form
  16. yes But depending on how you generate the array, and how many entries there are, it may be faster to store the IP's on a database and do a query
  17. Usually the way you go to a script is to browse to its location on the server...
  18. using count on the array you built will work fine too, yes. You could also use the COUNT() mysql function as mrMarcus pointed out
  19. You could use the heredoc syntax instead of single/double quotes. Or you could write the html to a page ( or have a template html page that you use with str_replace/regex to change the contents of) and use file_get_contents()
  20. $query = "whatever"; $result= mysql_query($query); $num_rows = mysql_num_rows($result);
  21. that doesn't make any sense. mysql_num_rows will return an int, not a result set... there is no need to put it in a while loop, since it will return the same int regardless of how many times you loop. Hell, that might even cause an endless loop. Not to mention that he may need the information from the result set....
  22. Can you post the code/link that causes this error
  23. you could also use mysql_num_rows()
  24. $pageInfo = file_get_contents("whatever page you want"); As far as Curl, you will have to wait for another user to answer that, as it is not my forte, you can also look up Curl examples on the manual
  25. instead of echoing the table, you would store it into a variable, and just put that into the message body. You have to make sure you set the appropriate headers so your email is read as an HTML email
×
×
  • 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.