-
Posts
14,780 -
Joined
-
Last visited
-
Days Won
43
Everything posted by .josh
-
/* function based on the following rules: 1) username can have 0 or 1 of !@#$%^&*() but it must be preceded by a ` 2) username can have 0 or 1 number in it, but it must be preceded by a ` 3) username can have 0 or more letters, case insensitive returns true if valid, false if not */ function validateUsername($username) { // check to see if $username only contains valid chars if(!preg_match('~^[a-z0-9!@#$%^&*()`]+$~i',$username)) return false; // check if more than one number or symbol preg_match_all('~([0-9])|([!@#$%^&*()])~',$username,$matches); if ((count(array_filter($matches[1]))>1)||(count(array_filter($matches[2]))>1)) return false; // check if ` precedes symbol or number if ($matches[1]||$matches[2]) if(!preg_match('~`[0-9!@#$%^&*()]~',$username)) return false; // valide username return true; } // end validateUsername
-
fyi you don't need that {1}
-
soo...revised rules: 1) username can have 0 or 1 of !@#$%^&*() but it must be preceded by a ` 2) username can have 0 or 1 number in it, but it must be preceded by a ` 3) username can have 0 or more letters, case insensitive
-
Example: $specials = array( "Sunday" =>"52in Flat Screen TV:425.00", "Monday" =>"Amplifier:145.00", "Tuesday" =>"HP Computer:355.00", "Wednesday" =>"500GB External Harddrive:99.00", "Thursday" =>"Internal Speakers:55.00", "Friday" =>"Ergonomic Keyboard:85.00", "Saturday" =>"Wacom Tablet:175.00", ); foreach ($specials as $day => $special) { list($product, $price) = explode(':',$special); // variables // $day : Sunday, etc... // $product : 52in Flat Screen TV, etc.. // $price : 425.00, etc... // example echo $day . "<br/>"; echo $product . "<br/>"; echo $price . "<br/>"; echo "---<br/>"; } // end foreach $specials output: Sunday 52in Flat Screen TV 425.00 --- Monday Amplifier 145.00 --- Tuesday HP Computer 355.00 --- Wednesday 500GB External Harddrive 99.00 --- Thursday Internal Speakers 55.00 --- Friday Ergonomic Keyboard 85.00 --- Saturday Wacom Tablet 175.00 ---
-
okay so let me get this straight: 1) The string should always start with ` 2) After the ` the string can contain 1 or more (is there a limit?) of any letter, number or the following symbols: !@#$%^&*() 3) No spaces anywhere (which this is technically defined by its absence in #2)
-
2nd thing I see wrong is elseif ($player!=$sel_result) Problem is that $sel_result is a result source. You need to actually check if a row was returned or not, pull the queried data out of the result source. Something like $sel_result=mysql_query($sel,$conn); $r = mysql_result($sel_result, 0); and then use $r in your condition
-
first thing I see wrong is that you are using $PLAYER in you $sel query but I see only $player (lowercased)
-
1) Store the data in a flatfile or database 2) retrieve the data from a flatfile or database Whether you choose database or flatfile, you can make a "config" type script that will load up variables and you can include that script in other scripts with include or require
-
That reminds me of the time my car was acting weird so I called up the mechanic and asked him what was wrong with my car and he said "Well what is it doing?" and I said "Well it's acting weird.." and he said... "Are you a fucking idiot? How am I supposed to know what is wrong with your car when instead of bringing it in for me to look at it, you call me up on the phone, and when I ask you what's wrong with it, you seem to think that "It's acting weird" will totally help me identify the problem! Seriously, if you want me to fix your car, bring it in so I can take a look at it. Or at least describe what you think is wrong, what you expect and what it is not doing (or doing) instead." True story And the moral of the story is, you may not know how to fix your code, but you should know what it is supposed to be doing and what it is (or is not) doing instead, and I can't help you unless you tell me these things.
-
...and you are NOT using a framework like jQuery or Prototype, think long and hard to come up with a very good reason why you are not! In all my years of coding, the only valid reason I have ever seen for not using one of these tools, is because someone is trying to learn it the old fashioned way (but not necessarily actually build websites with it). Or...someone is trying to build their own framework. That's it! IMO there has been no other reason worthy enough to warrant not using jQuery or the like! "It will bloat my website, increase page load time, blahblah" is not a good enough reason! These frameworks are compacted and browsers will cache them! So if you post an AJAX question here and your code and/or question does not involve the use of an existing framework like jQuery, then be prepared for you first response to be something along the lines of "Why aren't you using a framework?" Seriously. It is super easy. Way easier than that code you're trying to post. Save yourself the headache. Get jQuery or similar. DO IT.
-
and to compact it even more (and solve your problem), you can dynamically build that .js file with server-side scripting. You'd have your .js files in a dir and have your script tag point to a single blah.js and mod_rewrite that to point to blah.php and and in blah.php you would file_get_contents the necessary ones and compact it and output the single custom file.
-
seriously, do yourself a favor and get jQuery or prototype framework or something.
-
so what's your question?
-
$routing = array('~news/search/[^=]+=(.*)~' => 'news/search/$1'); That's just an educated guess, based on what you provided. If it doesn't work, then you need to provide more info. Explain where/how you are getting the URL, the context it coming from, example context, etc... But it looks like (and based on your mention of making a CMS) what you want to do is if user goes to .../news/search/?search=blah you want to redirect to ../news/search/blah well if that is the case, then mod_rewrite is what you should be doing.
-
a case will not get executed unless the condition is true, so if case "Two" is true, case "One" will never execute and therefore that assignment to $price will never exist. Maybe you are unsure about how switch() works? It is basically the same as doing this: if ($someValue == 'One') { $price = 1; } else if ($someValue == 'Two') { $total = $price + 2; } Why not just do $price = 1; instead of $price = 0.00; up there before the switch?
-
$content = 'content to match'; preg_match('~class="future"[^(]+\((\d+)~',$content,$value); $value = $value[1];
-
You need to a) save the image instead of output and then point to it like any other image (in an <img .../> tag) b) seeing as how option "a" isn't all that great, an alternative is to make the image generation script a completely separate script all by itself. You would then output your image tag in your script as you normally output an image tag, except point to the image script like so: <img src='image.php?url=urlhere&shrink=260' ... /> Then in script.php is where you have that function and the only thing it will do is the arguments from $_GET['url'] and $_GET['shrink'] and then output the image.
-
Well they are but...you can't just call a function like that....if you really want to do it like that then you would have to eval it, but that's not really a good idea. Instead, you should setup a condition to output based on type of image. $ext = strtolower(pathinfo($Url, PATHINFO_EXTENSION)); switch($ext) { case 'jpg' : case 'jpeg' : imagejpeg($tn); break; case 'png' : imagepng($tn); break; case 'gif' : imagegif($tn); break; case 'bmp' : imagewbmp($tn); break; }
-
mb_ereg basically that code says: if the value of $field contains "phone" or "fax" then... ...if the value of $value does NOT have between 7 and 20 of only these characters: 0-9)(xX - .... then add that error message to the $errors array
-
also, you can't just echo $image. It's an image source object. If you want to output it to browser, you have to do it like this: header('Content-type: ' .image_type_to_mime_type($type)); imagejpeg($tn); // for jpg files, there's other image type equivalents to this
-
Yes, that is raw image data. And you are getting that error because you are outputting something before it. See the sticky about headers.
-
makethumb($Url,260); This send image header and output the image directly. You don't really want to do this unless the only thing being output from your script is the image. $image = makethumb($Url,260,false); This will make the change to the image and return the altered image resource. You will want to do it like this if you are wanting to do something more with the image and then output it later, or save it to disk instead or whatever.
-
how are you actually using it on your site? Sounds like you are calling the function and then echoing out what it returns (leaving that last argument true). If that's what you are doing, you need to send the proper headers first so that the browser knows its an image to be rendered. Otherwise, the browser is just printing out the raw data of the image. Look at the function, at the code when $rt is set to false.
-
javascript is processed client-side so not an *easy* way to do it. But it IS possible see example . However with google maps specifically, depending on what exactly your needs are, you can use server-side scripting to build a url with query string to output as an img and google will process it and return a map based on parameters you sent in img src. It is of course a static image, so that may or may not work for you, but if it does, there you have it. http://code.google.com/apis/maps/documentation/staticmaps/