Jump to content

mikesta707

Staff Alumni
  • Posts

    2,965
  • Joined

  • Last visited

Everything posted by mikesta707

  1. seems like your php tags arent being parsed
  2. oh ok, i wasn't sure, you just said it was on a clients email. sorry bout that
  3. oops your right... missed the last bracket
  4. ok if i have this right you want to check if a certain string is in a string your user submitted. we can use the stristr() function for that (which checks if a string is in a string, and returns whats after the string if it is, and false if it is not) so take the following global $bad_spams; foreach ($bad_spams as $bad){ if (stristr($string, $bad) !== false){ //do whatever it is you want to do if the spam is found! } that should do what you want it to. hope that helped!
  5. Im assuming you want to do this if like, the user tries to log in or register, leaves a field blank, and you take them back to the page and say, hey color the field the left blank. While you can do this with php, it would be a lot easier, and a lot smoother to do this with javascript in my opinion. If you dont know how, read a tutorial on how javascript interacts with the HTML DOM. Its actually very easy to do with javascript, and honestly would only use a couple of functions consisting of 10-15 lines of code each
  6. why not just password protect the page... So that you know exactly who can access it
  7. you have an extra curly bracket. change this: function upload($image) { $image=$_FILES['image']['name']; if ($image) { $filename = stripslashes($_FILES['image']['name']); $extension = getExtension($filename); $extension = strtolower($extension); if (($extension == "jpg") || ($extension == "jpeg") || ($extension == "png") || ($extension == "gif")) { $size=filesize($_FILES['image']['tmp_name']); $image_name=time().'.'.$extension; $newname="images/".$image_name; $copied = copy($_FILES['image']['tmp_name'], $newname); } } return $newname; } to this function upload($image) { $image=$_FILES['image']['name']; if ($image) { $filename = stripslashes($_FILES['image']['name']); $extension = getExtension($filename); $extension = strtolower($extension); if (($extension == "jpg") || ($extension == "jpeg") || ($extension == "png") || ($extension == "gif")) { $size=filesize($_FILES['image']['tmp_name']); $image_name=time().'.'.$extension; $newname="images/".$image_name; $copied = copy($_FILES['image']['tmp_name'], $newname); } return $newname; }
  8. is that query set to output a mysql error? as in is there something like mysql_query("whatever") or die("error".mysql_error()); if there is a mysql problem, and you dont have your code outputting the error, you wont see any errors popping up. the error you mentioned above seems to me like you are missing an argument, or your array doesnt have enough information
  9. why would you do that? I dont understand.. You are trying to set one column to have the value 0, 8, or 24 right. Just use the HTML and a radio button to set one Post variable to either 0, 8, or 24 and put that value into the table. No if statements are needed at all
  10. unless your clientlist array is multidimensional, the client variable wont be an array, (when you loop through an array with foreach, the variable after the "as" is a a variable equal to the current entry of the array you are accessing)
  11. I dont understand exactly what you mean by that but this page was working fine... with this query.. $query = $db->execute("Update `players` set `level`= `level`+?, `maxexp` =?, `exp` =?, `money` = `money` + ?, `hp`=?, `maxhp`=?,`maxenergy`=`maxenergy`+?, `energy`=?, `crimes_sucess`=?, `crimes_money`=?, `maxnerve`=?, `awake`=? where `id`=?",array(1, ($player->level+1) * 70 - 20, 0, $player->money + $moneygain, $player->maxhp + 10, $player->maxhp + 10, $player->maxenergy + 1, $player->energy = $player->maxenergy, $player->crimes_sucess + 1, $player->crimes_money + $moneygain, $player->maxnerve + 1, $player->awake - $awakeloss, $player->id)); its when i replaced ($player->level+1) * 70 - 20 with $maxexpgain that it now doesnt work. that isnt a normal mysql query... it uses an object called db with a method called execute to do the query. But whatever you clearly dont realize this, or i'm misunderstanding the code. Is it returning an error?
  12. Password protect the page?
  13. Where is looking for some criteria to execute whatever mysql command you want to execute. the right side of the = sign is a column name, and the left side is a value. Where tells the Mysql where you want to make whatever changes you are making.Say you wanted to update your database where the column named id is equal to 5 you would write $id = 5; mysql_query("update tbl_athensPhoto set photo = '".$_file_name."' WHERE id = '$id "); If you wanted to set every entry in that table to have the column, photo set to $_file_name, you would do: mysql_query("update tbl_athensPhoto set photo = '".$_file_name."'");
  14. you have an error with your query right? Well it isnt a normal query is it, it is using some method of some object. can you show us the definition of this object? or at least its db_query method?
  15. Ultimately the header issue in it's self is a good reason. The other options is that you do not have control of the data in a sense. Also it makes it a pain if you want to implement "templating". If you store your output in variables you can easily template your system, where as if they are all in echos, you now have to re-do your logic/go back through and put all echo's into variables to be echo'd out. Doing it this way makes it easier for templating, modifying down the road and solves the issues of header errors, session_start errors and other items. There is no real reason to just echo items out while it is processing. Also think that 1 echo vs 100 echo's will be much faster and less processing time. So aside from the errors it improves efficiency of the script. Process the script where it needs to process, display data where it needs to be displayed. Simple as that. If you want more examples, I would suggest creating a thread in the Misc section to get examples and other's explanation. Sorry to the OP for thread hijacking =\ Ahh that makes a lot of sense. Thank you very much for taking your time to explain that to me. I think you just changed the way I code slightly haha. Oh and OP im sorry too for hijacking.
  16. You may not have the correct permissions set for scripts in those folders. Try changing your folders permissions (to 777 I believe) and try again
  17. If you code right, not just echoing output as you go instead storing them in a variable(s) and then outputting those variables at the end you will be fine. It is not good practice to just echo stuff out through out the script. Execute the script first then output the items generated by the script. Ahh I was entirely unaware of that.. thank you very much! But can you explain to me why it is bad practice to just echo stuff, instead of storing what you are echoing into variables, and output the stuff later? Is it just bad practice, or do certain problems arise from doing that?
  18. Nope. I am a fan of coding it right and using the header. Due to the simple fact JS can be disabled/turned off. is it actually better practice to use headers? I understand that Javacsript can be turned off, but you can't do any output before hand, so If I wanted to redirect if someone logged in, but output something if they failed I wouldn't be able to do that with headers would I? Or can I?
  19. Anybody else here a fan of a javascript redirect? instead of using headers just insert this where you want to redirect <script language="javascript"> window.location="index.php"; </script>
  20. Ok I dont quite Understand you but let me see if I got this straight. You want to take a string, and replace every occurence of the sub string [$plugin] with the variable output? tha seems easy enough $output = $plugin."Output";//this is what you want to do right? $plugin = "[".$plugin."]";//this is what plugin should be right? what you want to replace? $string = str_replace($plugin, $output, $string); try that. I hope that helps. It is kind of difficult to understand what you are trying to do
  21. HOLY CRAP!!! You are amazing!! thank you sooo much. I really appreciate that It looks really really good =). Hope you dont mind if I use that hahah
  22. are there any error messages?
  23. oh jeez im sorry. My mistake I see what happend change $sql = mysql_query("SELECT catid, catname FROM category WHERE catname='Cars'") or die('ERROR'.mysql_error()); to $sql = mysql_query("SELECT catid, catname FROM category) or die('ERROR'.mysql_error()); The WHERE is what was messing us up. Instead of choosing everything from the database, it chose everything with the catname Cars, so it would never get the entry with the catname as Bikes. alternatively, instead of $sql = mysql_query("SELECT catid, catname FROM category) or die('ERROR'.mysql_error()); you can write $sql = mysql_query("SELECT * FROM category) or die('ERROR'.mysql_error());
  24. ahhh I see you want to convert your RSS feed from your blog and turn it into a type of news for your site. To be honest, there are much easier ways of making news on your site that don't involve RSS feeds. For example, you could make a simple php script that added news articles to your database (just make a news table, and make a form that inserts entries into it) Then you could make functions to access the news information a lot easier. Actually, once you get a simple news system working with Mysql, it would be easy to convert it into an RSS feed, rather than turning an RSS feed into a news section. Hope that helps!
  25. google php and flash. first result is http://www.kirupa.com/developer/actionscript/flash_php_mysql.htm i have used this tutorial and it is good.
×
×
  • 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.