-
Posts
14,780 -
Joined
-
Last visited
-
Days Won
43
Everything posted by .josh
-
..and you are asking here, instead of asking paypal...why?
-
understandable. But nonetheless, simply using php to echo it out IMO does not make it a php question :/ as far as embed being deprecated...hmm didn't know that. thx for the info.
-
data sent from a form will either be in the $_GET array or $_POST array, depending on the method you used in your form. So for example if your form method is post and you have a textfield named subject, the posted info will be in $_POST['subject']
-
It is not working in mozilla because you are not using the proper tags for mozilla. Mozilla uses embed tags. This is not a php question either.
-
Or maybe it's because he's black and people are afraid you'll claim racism if they don't buy from you.
-
I think you missed the part where instead of having your script check to see if the user actually entered in a (for example) validly formatted number, it just escapes it and sends it on its way. So next thing you know, you have a database full of phone numbers like "abc" "abbclksdfja" etc... which guess what, they are escaped...but they aren't phone numbers! You should have been doing something more like this: $phone = preg_replace('~[^0-9]~','',$_POST['phone']); if (!preg_match('~^[0-9]{10}$~',$phone)) { // tell the user they must supply a valid 10 digit number } else { // $phone is valid. store it and it will be stored as 1234567890 so...no need to escape! }
-
And I hate mysql_real_escape_string. people just throw it on everything and send it off to the database, as the answer to validation. Someone entered in abcd instead of a phone number? who cares! we mysql_real_ecape_stringed it, it's all good!
-
[SOLVED] setting variable names and values from an array
.josh replied to drumhrd's topic in PHP Coding Help
That's the point of having it in an array in the first place - so that you can use a foreach loop or something. Which you used...to extract and make individual variables...only to turn around and want to automatically cycle through... -
so what's the problem? Are you stressing because you don't know how to write a good paper, or because you don't know the subject matter?
-
$18 for a photo/image good enough to be used commercially is pretty damn cheap.
-
okay so you run your query and the results are returned in $result. So next you would set a default value of 0 for each variable, then you loop through $result, and in the loop, you would overwrite the variables that are in the table. So for instance your example has mon | 2 and wed | 1, so... $sun = 0; $mon = 0; $tue = 0; $wed = 0; $thu = 0; $fri = 0; $sat = 0; while ($list = mysql_fetch_assoc($result)) { $$list['t_day'] = $list['t_daycount']; } echo $sun . "<br/>"; echo $mon . "<br/>"; echo $tue . "<br/>"; echo $wed . "<br/>"; echo $thu . "<br/>"; echo $fri . "<br/>"; echo $sat . "<br/>"; That would output 0 2 0 1 0 0 0
-
Afraid to release my site to the public. Is it secure enough?
.josh replied to justAnoob's topic in PHP Coding Help
personally I do not really subscribe to using mysql_real_escape_string unless you expect quotes to be in the value. If you don't, you should just strip them out with str_replace or preg_replace. IMO it is better to validate data by checking to see if they are formatted the way you expect them to be, rather than doing some "catch-all" method like mysql_real_escape_string. Also, you might find this to be an interesting read: when escaping is not enough -
variables passed through the query string can be retrieved with $_GET['variablename']
-
easiest thing to do would be to have a row for each day with a default value of 0 and have all of them returned. next easiest thing to do would be to hardcode them $mon = 0; $tue = 0; etc... before the query and overwrite the ones returned.
-
[SOLVED] Compare one value of array against all the values of another
.josh replied to Hatdrawn's topic in PHP Coding Help
$array1 = array ('a' => 1,'b' => 1,'c' => 1); $array2 = array ('a','b','d'); $newarray = array_intersect_key($array1,array_flip($array2)); echo "<pre>"; print_r($newarray); output: Array ( [a] => 1 [b] => 1 ) -
Afraid to release my site to the public. Is it secure enough?
.josh replied to justAnoob's topic in PHP Coding Help
BETTER WAY TO HANDLE: $allowed= array('home','about','contact'); // add pages allowed $page = (in_array($_GET['action'],$allowed))? $_GET['action'] . '.php' : $allowed[0] . '.php'; include($page); also, read this tutorial: http://www.phpfreaks.com/tutorial/php-security -
have you tried echoing out your cookie on the global level to see if it contains what you are expecting?
-
if the containing block is marked as position: relative, you can use absolute positioning for it and it will be relative to the containing element, not the overall page.
-
yeah was going to also mention that but you posted just before me and mentioned pretty much everything I said. Was gonna just say fuck it and not post at all since you beat me to it but I did post a little bit more details so I went ahead and posted it but left out mentioning it since you already did
-
while seeing credit given to people who help gives me warm and fuzzy feelings inside, please try to make subject lines descriptive of the problem at hand.
-
Assuming that in your code $calendar->rank is what you were showing $data to be... So you are trying to assign your cookie to $calendar->rank but in your class, you do not have a property called rank (nor does it look like you're actually doing anything in your class with a property called rank... In your class you need to add $rank to your list of properties. Assuming that you want to be able to assign something to it directly, you would have public $rank;
-
Touché I guess I should have actually read the last post.
-
(?!...) is a negative lookahead. It means look ahead of this thing and only match if it does not equal this. I honestly don't know why you guys keep going on with the regex. You both admit to being in the dark on it. Blind leading the blind. If all you are wanting to do is make sure it ends in .mkv and for some reason you insist on doing it with regex, this would be the most efficient pattern: if (preg_match('~.*mkv$~',$file)) { // file is good, do something } else { // file is bad, do something } But as I mentioned before, this does not even require regex. The substr solution is still faster and simpler.
-
If you are doing a simple string comparison, it would be more efficient to use a built-in string comparison function, like this: if (substr($file,-5) == ".part") { // file ends in .part, do something } else { // file does not end in .part, do something }