-
Posts
14,780 -
Joined
-
Last visited
-
Days Won
43
Everything posted by .josh
-
Relative path "../" not behaving as expected.
.josh replied to benzittlau's topic in PHP Coding Help
Yes, this is expected behavior. For php, including one file in the other is the equivalent of c/p'ing code to your main file, as if it were hardcoded in the script. Therefore it is relative to the main script being executed. -
by sorting it, obviously.
-
Yeah, that's what I'm saying. It wouldn't result in any ambiguity because the parsing rules already dictate what would happen if \s was a valid escape sequence for double quoted strings. Okay in something like this: $string = "blah blah blah\s"; There wouldn't be ambiguity because there's no regex happening. But if you are doing this: preg_match("~blah blah blah\s~",$string); so...what is that supposed to mean? A space/tab/newline, or a plural 'blah'? Using \n like that is okay because it happens to mean the same thing in both contexts, but it would not mean the same thing with \s.
-
show some code
-
ctype_digit or if you really wanna preg_match it, '~^[0-9]+$~'
-
only thing i see wrong with it is you have a closing h1 tag with no opening h1 tag. But that shouldn't stop it from showing it...you sure you're going to the right file?
-
i wanna make it multi ( if else if else if ..)
.josh replied to egturnkey's topic in PHP Coding Help
if all of the files follow that same format, just do something like this: $lang = 'ar'; $languages = array('en','ar','ru','es'); // add languages here $file = (in_array($lang,$languages))? 'co_'.$lang.'.php' : 'co_'.$languages[0].'.php'; // change array elem to whatever you want as default include_once $file; -
opening it via your browser like that won't do anything, because your browser is not what parses the script. When you go to localhost via your browser, you are making a request to a server (a local server, like when you run apache) just like when you go to a regular website. Apache and php is what actually executes and parses the script.
-
syntactically it is correct. Is it echoing out the actual code?
-
okay so let's assume your preg_matches are right. where is $loginid assigned?
-
i'd say your culprit is your preg_matches. You are using a greedy dot matches, so more than likely you are matching a whole lot more than you are wanting to match, probably including random quotes, which would cause your query to mess up. They can be written much better, but at the very least, change all your (.*) to (.*?)
-
well that's because \n happens to mean the same thing for both regex and as an escaped char in strings. \s stands for a space, tab or newline char in regex, which is not even remotely the same thing as what the OP suggests it be used for. and the $ does mean something in regex. That's why you have to do all kinds of escaping with it, depending on what you're intention is.
-
yes I was referring to its use in regex. IMO making it be what OP is proposing would cause confusion. Or not. Seems as though regex is some arcane gray area to most people... well I know you're decent at it Dan, must have slipped your mind.
-
never ceases to amaze me how many "is this code okay" questions we get. Why not press the GO button and find out?
-
[SOLVED] Almost there, just need some advice with this code!
.josh replied to merylvingien's topic in PHP Coding Help
move it above your foreach loop... -
[SOLVED] If decimal exists then stop looping
.josh replied to KingOfHeart's topic in PHP Coding Help
or if (($fileData[$n] % 32) != 0) { // is decimal } -
you can redirect with the header command, just remove the echo right above it. If you really really want to have a message like that before actually redirecting, you can output a meta tag that redirects, instead (or with javascript).
-
[SOLVED] Almost there, just need some advice with this code!
.josh replied to merylvingien's topic in PHP Coding Help
-
why are you even using session_register? It's deprecated and slotted for removal in php6. Anyways, as to your new errors, that is because you are calling the header function after output. You can't do that either. I don't really know why you are trying to do that anyways, as instantly sends you to the location, so it's not like the user will see the echoe'd message anyways.
-
[SOLVED] Almost there, just need some advice with this code!
.josh replied to merylvingien's topic in PHP Coding Help
It's a notice simply stating that in the first iteration, $total does not exist as a variable. PHP is fine with this, but it's letting you know. To make it go away, simply define it before the loop: $total = 0; -
try removing the single quotes around $_GET['sort'] in your query: '{$_GET['sort']}' to {$_GET['sort']} also, to address cag's note about security, inside your condition, above your $query = ... you should at the very least do something like this: $allowed = array('email','name','dob','fav_artist','fav_game'); $_GET['sort'] = (in_array($_GET['sort'],$allowed)) ? $_GET['sort'] : $allowed[0]; // change [0] to whatever element you want as default
-
Also \s is already taken, so you'd have to either pick something else or go through the added effort to re-purpose what it is currently being used for.
-
actually it's match and capture everything but a newline (no modifier for the dot) between all (preg_match_all) "first" and "next" (lazy quantifier) single quote characters.
-
[SOLVED] finding words and non wanted charecters
.josh replied to redarrow's topic in PHP Coding Help
keep message as a string, loop through the unwanted array, use stripos -
Combining 3 form fields into one record and dumping to database
.josh replied to pioneerx01's topic in PHP Coding Help
Basically you take the same code you already have setup, but concatenate the posted info... $fullname = $_POST['firstname'] . ' ' . $_POST['middlename'] . ' ' . $_POST['lastname']; ... and put it into a single column...same was as how it's done individually ...