-
Posts
14,780 -
Joined
-
Last visited
-
Days Won
43
Everything posted by .josh
-
Adding isset() causes database value to be ignored
.josh replied to ICYUH8's topic in PHP Coding Help
As I said before, the isset needs to come first. There is no difference between that 2nd one and putting it in separate if statements, so you shouldn't need to do that. Did you apply this to ALL of your conditions? Look back at your warning messages: you are getting multiple warnings, each for different indexes. IOW you need to apply this to more than one place in your code. -
why would you want to get "expected results" out of something that is supposed to return a randomly selected entry? If you want to be able to pass an argument and receive a specific result, it's no longer random thing. Perhaps you aren't explaining it right, or perhaps I am not understanding it right? In any case, since you are trying to control or otherwise influence the random selection, instead of using the built in functions that shuffle or return a random entry, you'd use the functions that return a specifically specified entry, and then just write your own "randomize" logic, around whatever you pass to the function. So IOW you'd be using things like count or array_keys to get info about the array.
-
Adding isset() causes database value to be ignored
.josh replied to ICYUH8's topic in PHP Coding Help
To clarify, isset returns a boolean value of true or false, so basically your condition is saying: if the array index is set: if (true=="Y") or if the array index is not set: if (false=="Y") Yes, try changing your condition to what Muddy_Funster showed - however, you need to reverse it. This will still give you the error, since you are evaluating the value first. if($settings['set_payment']=='Y' && isset($settings['set_payment'])) { This will first check if the index is set, and will prevent the error, since the 2nd half of the condition won't be evaluated if the first half is false. if(isset($settings['set_payment']) && $settings['set_payment']=='Y') { -
preg_match \ preg_replace functions for embedding youtube\soundcloud\etc.
.josh replied to doofy's topic in Regex Help
preg_match only matches for and returns the first thing found. preg_match_all will look for all things that match the pattern. Basically the issue is that you are finding and capturing the first id.. and then using preg_replace to replace all of the ids with that first id. The best way to fix this is to skip trying tp preg_match or preg_match_all and incorporate what you have there into preg_replace. -
yeah..not gonna bother sorting through a shitton of code, but it sounds like you have a really old script and your host got around to upgrading to a more recent version of php. As for the specific error mentioned in your thread title: http://forums.phpfreaks.com/topic/268091-ereg-and-deprecated-error/ Overall my suggestion to you would be to take the time to rewrite your script with updated code, or find someone to do it for you (which will most certainly involve money).
- 1 reply
-
- ereg_replace()
- pereg_replace()
-
(and 3 more)
Tagged with:
-
gratz and other fancy stuff. .josh
-
$pattern = '#(?:\?|&)linkauth=([^&\'"]+)#'; make sure it's linkauth and not someothervarendswithlinkauth. Also cover for if it's the last url param.
-
but...that's exactly what you said you wanted, yes? If you want it to match starting at beginning of string, instead of anywhere within string, then remove the first %
-
SELECT * FROM certificado WHERE nome LIKE '%{$name}%'
-
you are missing a comma after this one: "/magician-winchester.html" => "magician-winchester"
-
okay, are you sure $username has the expected value? If you run the query directly in mysql (via phpmyadmin or commandline) do you get expected results?
-
dumb question.. are you sure you are properly connected to the db and all that? do this: $maxscore = mysql_query("select (max(scoreioa) + max(scoreioa2)) from result where username='username'") or die(mysql_error()); $row = mysql_fetch_row($maxscore); echo "<pre>";print_r($row); echo "</pre>"; $scoremax = $row[0]; echo $scoremax; do you get any errors displayed? what does the print_r show? what is echo'd out? is 'username' really the username?
-
Fetching last characters after "=" sign
.josh replied to WebDesignerDeveloper's topic in PHP Coding Help
$url = "http://www.abc.com/index.php?site=new"; $parts = parse_url($url); parse_str($parts['query'],$query); echo $query['site']; // this will have your value -
I seriously cannot figure out what's wrong with this! (EDITED files)
.josh replied to Craptacular's topic in PHP Coding Help
hi. please do not make multiple threads asking the same thing. -
I seriously cannot figure out what's wrong with this!
.josh replied to Craptacular's topic in PHP Coding Help
yeah.. sorry that you've been pullin' your hair out for 2 days now, but not gonna sort through tons of code. But in general, here are some tips to help: 1) You said it works for some of your items, but not all. This usually means that you've typoed a variable or form field name somewhere. Make sure the form field names line up with your $_POST variable and whatever other variable(s) you push it to. Also make sure they are not typoed in your query string, columns in your table are right, etc.. 2) make sure your form is actually pointing to your single.php. I know this is probably dumb but you never know. Maybe you have several scripts and forms floating around and you're pointing to the wrong one 3) Add the following to your single.php echo "<pre>";print_r($_POST);echo "</pre>"; exit(); This will dump what was received from your form. Make sure the expected variables/values are there 4) echo out your db query string (whatever variable you put your query into): echo $query; exit(); Make sure it looks right. Copy and paste it directly into your database via phpmyadmin or commandline or however else you directly interact with your database. Does it throw an error? 5) add the following to your query execution (not sure what you are using, but hopefully you can figure out the equivalent for you) : $result = mysqli_query($conn, $query) or die (mysqi_error()); Does this produce an error? -
One way to do it is to have a database table with 2 columns: an ID column and a timestamp column. Each time the form is submitted, insert a row into the table with the current timestamp and ID of the user. If you require the user to be logged in, you can use their ID associated with their login that you should already have. Also, requiring login will make it easier to enforce your limit. If you do not require login, you can use their IP address instead. This can easily be spoofed (e.g. user goes through a proxy service) but there's no much you can do about that, except to make them login. Then you will have logic that selects by the ID for the last hour and if there's more than 10 entries, give an appropriate message instead of performing the lookup. Should prolly make an additional script to purge old data and put that on a cron job, unless you want to keep records for something else (e.g. showing user a history of use, etc.)
-
trim will trim from beginning and end. ltrim will trim only from the beginning.
-
I don't think it's too much to expect regular members to use code tags. And I'm sure you did just forget. Which is why it was a 1 point warning that expired almost immediately. I mean really, it was the equivalent to a PM. Also, this happened like 7 months ago. You're just now getting around to seeing it and saying something about it? Which means you haven't been active for like 7 months. I think someone woke up on the wrong side of the bed today.
-
sorry, i wasn't trying to be grumpy or nitpick.. i only wanted to point it out because they are two different things, and if you happen to go searching for answers elsewhere, using "java" as a keyword instead of "javascript" will give you vastly different results.
-
first off, this is javascript, not java. Two completely different things. 2nd, your code only does that because that's all the code actually does. Where is the code that actually retrieves the shoutbox content?
-
Yep, this is a forums, and you are here to ask questions. And you did get an answer. However, I'm free to point out when something isn't a "best practice" or generally not a good idea, or just plain stupid. It's like if my kid were to ask me what's the best way to make a homemade parachute to jump out of a tree. I could tell him which sheet to use and how to tie the rope around the corners..or I could tell him that jumping out of a tree with a homemade parachute is damn stupid. We aren't here to just blindly answer questions. We're here to try and help people become better programmers. Sometimes becoming a better programmer is recognizing that there are better ways to do what you are doing, or accepting that what you are doing doesn't make sense or is just stupid. Instead of acting like a 2 year old stomping your feet, swallow your pride and listen to advice given, and you just might learn something.
-
What's the point in even having a line that says "Current Password: **********" anyways? What function does that possibly serve anyone? The only "useful" thing that's related is when password change forms require you to ENTER your current password, in addition to the new one, as final verification. Simply displaying a line of text with stars is pointless and IMO kinda dumb.
-
1) this isn't a regex question. Thread moved. 2) There are a ton of "basic form" tutorials on the internet. 3) Are you sure you want to have 3 separate .php files that just show a message in a slightly different way? At face value, it sounds like it would be better for you to have a single php script that keeps your messages in an array and then just select a random element of the array.