-
Posts
2,965 -
Joined
-
Last visited
Everything posted by mikesta707
-
well think about what rules you will have for each input. as tom stated, for integer values, you should check if they are integers (is_int() will help with that) as for your specific example a street address starts with a number, and has a word. you can use regex functions like preg_match() to make sure its of the correct format. also, make sure you use mysql_real_escape_string() on all non encrypted data that you insert into the database to protect against sql injection. by the way, if there is a function that you end up applying to all the post data (IE if you use real escape string on everything) instead of doing every single entry individually, you can use array_map() to do it in 1 line. an example of its usage //apply mysql_real_escape_string() to every piece of data in the $_POST array $_POST = array_map('mysql_real_escape_string', $_POST); alternatively, if you are using $_GET you would obviously replace $_POST with $_GET
-
pass it as an argument into a method?
-
strpos doesn't return boolean false, but a value that evaluates to false (IE 0, or "") so in order to do what the second poster said, you would want If (strpos($_SERVER[’REQUEST_URI’], "/forum/") === false) { alternatively, you can do !== trueg. Take a look at the manual for more info on this
-
Right before any of your headers/session_starts() you have an echo. This is the problem. You can't send a header if you output something to the page. I realize those echo's are there for testing purposes, but if you want your headers to work, you need to get rid of them. also, session_register() is deprecated. above PHP version 4.2 (i think) you can simply do this $_SESSION['whatever'] = "value"; and it is the exact same. read up on headers for more info
-
forgot semi colon $hell = $_POST["fname"]; when you get parse errors, its a good idea to look a line (or a few lines) above the error line
-
It looks like IE6 doesn't like the javascript. are there any javascript errors on the page?
-
wow, totally thought that PHP required forward slashes as delimiters. Yeah you were right its that last forward slash that was screwing things up. thanks for the tip, those forward slashes really messed everything up. all is well now
-
I know this is easy, but for some reason, regex just kicks my ass. The pattern I currently have goes like so $pattern = "/[a-zA-Z]{2,3}\/web\/[0-9]{9,11}\/\.html/"; i'm trying to match URLs that look like this: mnh/web/(somes numbers).html thc/web/(numbs).html dcf/web/(numbs).html Note that the first 3 digits are basically for certain areas (IE manhattan is mnh, queens is que or something, etc.) I used a character class that includes any characters of 2-3 letters in length to make it easier on myself. I'm sure its a simple fix, but I just can't seem to figure it out
-
I hate lukeywes1234... hate him so much
-
The following should give you a clue of how to do it $rand1 = "d"; $rand2 = "c"; $rand3 = "x"; for($i = 1; $i < 4; $i++){ $varName = "rand".$i; echo $$varName . "<br />"; } output: d c x
-
Simple & Valid PHP Not Working on My Site... all the sudden
mikesta707 replied to neagloe's topic in PHP Coding Help
the exact error messages would help -
just incase your curious, I wrote a for loop to do this 100 times and take the average of the id, and it ranged from about 1.7-2.3 the code to take the average $items = array( 1 => 'item 1', 2 => 'item 2', 3 => 'item 3', 4 => 'item 4', 5 => 'item 5' ); $count = 0; for ($i = 0; $i < 100; $i++){ $X = array(); $ID = count($items); //The more of these the higher the chance of a lower number $X[] = rand(1,$ID); $X[] = rand(1,$ID); foreach($X as $Y) if($Y<$ID){ $ID= $Y;} //echo $items[$ID]; $count += $ID; } echo ($count / $i);
-
what does your table setup look like? I would need that to give an exact answer, but you wanna do a query like $result = mysql_query("SELECT * FROM TABLE WHERE username = 'whatever variables holds username' AND rank='admin'"); if (mysql_num_rows($result) > 0){ //show page }
-
something like $query = "select count(userid) as numRows FROM tablename"; $result = mysql_query($query); $row = mysql_fetch_assoc($result); $num = $row['numRows']; should be about what you want. Look into the count mysql function
-
Reorder an array's keys but reassociate their index as well??
mikesta707 replied to thepip3r's topic in PHP Coding Help
The following worked for me $arr = array("d", "d", "d", "d", "d", "", "", "", "d", "d"); echo count($arr) . "<br />"; $new = array(); foreach($arr as $arr){ if (!empty($arr)){ $new[] = $arr; } } echo count($new) . "<br />"; print_r($new); ?> then $new would be the array without the blank values output: Array ( [0] => d [1] => d [2] => d [3] => d [4] => d [5] => [6] => [7] => [8] => d [9] => d ) 10 7 Array ( [0] => d [1] => d [2] => d [3] => d [4] => d [5] => d [6] => d ) the important part is the foreach loop -
if its an html email you will have to use line breaks, and not newlines
-
$fmt_ymd = "m.d.Y"; echo $_SERVER['SCRIPT_FILENAME'] , "created "; echo date($fmt_ymd, filemtime($_SERVER['SCRIPT_FILENAME'])); worked fine for me i'm assuming your having trouble because the following /* date page was last modified */ $file_last_modified = date(filemtime($_SERVER['SCRIPT_FILENAME'])); /* display foooter */ $last_modified = date($fmt_ymd,$file_last_modified); echo(" Page Last Updated: " . $last_modified); applies the date function twice, and the first time the usage was incorrect
-
session_start(); $_POST['whatever'] = $_SESSION['whatever']; thats the basic idea
-
that loops looks like it would be endless. perhaps it should be just greater than rather than greater than or equal
-
if you wish to pay someone to do this you would have better luck posting in the freelance forums
-
Split a string in half or insert into middle...
mikesta707 replied to mikka23's topic in PHP Coding Help
do you know exactly what the title is? or will it change? -
echo $_SERVER['REMOTE_ADDR']; thats all you really need to do
-
can you simply use str_replace() second delimiter and turn it into the first? or are they going to be different/random each time?
-
I need help...my script isn't working now...
mikesta707 replied to chromenun's topic in PHP Coding Help
if you want to get help, then you at least have to post the troublesome code. it helps if you show some evidence that you actually are trying to fix the problem yourself. This is a help forum, not a forum to find people to do something for you. Thats what the freelance section is for -
I need help...my script isn't working now...
mikesta707 replied to chromenun's topic in PHP Coding Help
if you are looking to pay someone, then go to the freelance forum, this is the PHP help forum.