Jump to content

xnowandtheworldx

Members
  • Posts

    89
  • Joined

  • Last visited

    Never

Everything posted by xnowandtheworldx

  1. I'm making a script, and I need to replace every symbol, like, `, ~, , , !, @, ETC. ETC. but instead of just replacing everyone if there are two in a row i still need it to only replace the symbols with only 1 "_"...and also remove any "_" that would be at the end after being replaced...heres an example... The.losers! => the_losers The..losers!! => the_losers php!!rules:D => php_rules_D so any help would be nice..i didn't really know how to explain lol.
  2. And for the use of it..say...when you have someone submit a comment and you use mysql_real_escape_string...so that there is no sql injection..when you want to display the comment say the comment was.."Hello, i'm matt" when you submit the comment, when it is inserted into the database it will be "Hello, i\'m matt" so when you display the comments you want you can use stripslashes() so that it appears as "Hello, i'm matt". Hope this helps you some.
  3. It would probably be a lot better if you tested to see if the search terms, and whatever is selected using // testing to see the user entered a search type and a search term if (!isset($searchtype) || !isset($searchterm)) { echo 'Please enter search details. Please go back and try again'; exit; } it just absolutely makes sure that it IS empty. So I believe overall it is better to use that than just checking it like that, because from what I read a while back, even if it has a 0 value it can still pass as true sometimes. I'm not sure if it's fixed or anything, but i've used the isset() function ever since. Hope I made since haha.
  4. What would go in the 'whatever' ? the 'whatever' area is for instance if you wanted a user to post stories the story variable would go in place of 'whatever'
  5. Ah, sorry I didn't see that part, but you could still use the mysql_real_escape_string I suppose, it still adds the slashes it's just that your not actually putting it in a database somewhere...so still try it and if that doesn't work I really don't know what to tell you. :\ EDIT: I was looking at it again..and i'm not really sure what you can do about it why exactly is the reason for you adding the slashes? Is it to protect against SQL injection when your submitting it or what?
  6. Do i need to make a new file or add it to an existing one? That's just how you fetch the information include it in your current file and use variables to store the information and display it only whenever you need it. If that makes since?
  7. Originalboy if you would like to fetch only the date, use the way i showed you to fetch a date, if not and you would also like to fetch the time it was posted use the NOW() mysql function that marklarah had posted. Just an FYI.
  8. Basically when ever the person has submitted whatever they need to submit, I suspect that you already have something that tells PHP, "Okay, the whatever is submitted now we need to execute this", if not, then post what it is you are trying to do and we would help you with that. As for the date in mysql, the mysql date format is as follows "year-month-day" i'll give you a little snippet below and all it does is show you how you would insert the date into mysql, and if you would like to show the date to users as "month-day-year" I will also include a function for that. Here we go, <?php $date = date('Y-m-d'); //I assume you know where to put the name of your table, and the row for the date $query = "INSERT INTO your_table (row_name) VALUES ('$date')"; mysql_query($query); ?> As for fetching, and displaying the date here's what I do. <?php //function to convert the date inputted //to the following format //month-day-year function convert_date($date) { $ex = explode("-", $date); $dates = "{$ex[1]}-{$ex[2]}-{$ex[0]}"; return $dates; } //echo the date $s_date = convert_date($your_date); echo $s_date; ?> Hope I explained fairly well, I am after all only 16 and not very good with explaining haha, if you need any help just let me know.
  9. Ah, sorry I didn't reply faster zang, I see someone else go to it though, i'm also sorry I didn't explain it too thoroughly but I had just gotten off and I was pretty tired haha. But i'm glad you finally got it!
  10. try using mysql_real_escape_string to add slashes before the single quotes.
  11. <?php $ff = "destination/"; move_uploaded_file($tempFile, $ff); ?> just change destination to the destination folder you want it to be moved to and it should move it. hope this helped. And about checking the dimensions i'm not sure, as I have never really worked with images. Another note use the "code" bb codes to display your code.
  12. You could also do something along the lines of.. <?php $url=$_COOKIE["username"]; echo ("<a href=\"http://localhost/members/{$url}/{$url}.php\">My profile</a>"); ?> where you encapsulate your php variables with {} I learned this a while ago, and have been using it ever since. I like it alot better than joining all the stuff together, and in my mind makes it less confusing either way.
  13. Yeah, if you have any html, or anything echoed before the actual header() function it won't work. So just make sure nothing is being outputted before hand.
  14. Thanks for both of those solutions guys! I never even thought of forcing the zeros with the gdate function either, but once again thanks to both of your solutions!
  15. On my website for users to upload their gaming videos, when i'm formatting the seconds into minutes when there is a 0 in the duration for some reason it gets truncated and i've scoured the internet and found nothing.... i've tried (int) and intval() so any help would be greatly appreciated! $mins = floor($duration_first / 60); $secs = $duration_first % 60; $duration = $mins.":".$secs; and then i store it in a table as varchar
×
×
  • 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.