Jessica
Staff Alumni-
Posts
8,968 -
Joined
-
Last visited
-
Days Won
41
Everything posted by Jessica
-
Conditional display of images depending on subscriber status
Jessica replied to driftwood11's topic in PHP Coding Help
you pretty much wrote it right there. What are you asking for? The sql? what type is the field? DATE, DATETIME, or INTEGER (storing timestamp)? if the first two, use php's date() function to format the date into this string: "Y-m-d" or "Y-m-d H:i:s" If it's integer, use time() then add three months to the date. -
Cookies can be easily edited. Plus, if someone steals the cookies of an allowed user (which is EASY to do), they now have access. If you want to use cookies, always check against the database and also store in a session and check that. Cookies aren't really that great because they are easily stolen and easily edited. "Further, since I am only checking if the cookie is set, but not any kind of value, can someone simply try vaious combinations of names and set them to any values on their hard drive and this will pass the test? " YES. Check the VALUES against the database at least.
-
"require() and include() are identical in every way except how they handle failure. include() produces a Warning while require() results in a Fatal Error. In other words, don't hesitate to use require() if you want a missing file to halt processing of the page. include() does not behave this way, the script will continue regardless. Be sure to have an appropriate include_path setting as well." I use require because I never include things which are optional :)
-
Why do you want to do this? You want to force them to slow down? :/
-
It's called a CAPTCHA. Google that and you will find more info. I installed one today for someone, and I can do the same for you if you need.
-
Probably has to do with my reusing the city variable. Try this: [code] function city($city,$location){ include('cities.php'); global $loc_pro, $loc_thug; $info['pro'] = $loc_pro; $info['thug'] = $loc_thug; return $info; } [/code]
-
And you've saved that file as action.php? I've had problems in the past with error reporting and using die. Try this and see if anything shows up. Otherwise, comment everything out and add lines back in until it stops working. That will show you the problematic line. [code] if(!is_numeric($age)){ print "The age is not numeric"; die(); } if(!ctype_alnum($name)){ print "Your name contained illegal characters"; die(); }[/code]
-
Try this: [code] function city($city,$location){ include('cities.php'); global $loc_pro, $loc_thug; $city['pro'] = $loc_pro; $city['thug'] = $loc_thug; return $city; } [/code] AFAIK: You can only return once per function, so what you had won't work. You might want to move this info into a database.
-
Try this: [code] <html> <head> <title> Name test </title> </head> <body> Hi <?=htmlspecialchars($_POST['name'])?> <p> you are <?=intval($_POST['age'])?> years old!</p> <p><?php if($_POST['name'] == 'Harley'){ echo 'Hey champ! Welcome'; }else{ echo 'hi Stranger/Other, how are you'; } ?> </p> </body> </html> [/code] It works for me. What you had already also works on my server. *shrug*.
-
[SOLVED] parse error, unexpected $end...Help!
Jessica replied to Brunner41's topic in PHP Coding Help
No problem. Don't use books...books suck. Use the manual ;) -
You probably have a parse error. Post the new code.
-
Contact your host.
-
[SOLVED] parse error, unexpected $end...Help!
Jessica replied to Brunner41's topic in PHP Coding Help
Edit: bool settype ( mixed &var, string type ) The type must be a string. "string" not string "int" not int http://us3.php.net/settype Look at the example. -
I think the Movable Type is doing stuff...it's rearranging them. Where is the actual query. It should look similar to: "SELECT * FROM tablename" MT should have an option to do this somewhere, you shouldn't need to mess with the code.
-
onClick expects a javascript function. It looks like that is not what is there.
-
Missing a ; [code]return $string;[/code]. If your page doesn't load, it can't compile.
-
[SOLVED] parse error, unexpected $end...Help!
Jessica replied to Brunner41's topic in PHP Coding Help
What's with this apostrophe? "; // 3.14 ' settype( $undecided, string ); -
You made it more complicated than need be. [code] <?php if ($_POST['name'] == 'Harley'){ echo 'Hey champ! Welcome'; }else{ echo 'hi Stranger/Other, how are you'; } ?> [/code]
-
thorpe, mind if I steal your signature? ;) I love that article.
-
Change it to 1 instead of 0.
-
Sounds right to me Carter.
-
[code]if (empty($_POST['password'])) { $sql = "UPDATE users SET email = $email, area = $area, phone = $phone, age = $age, message = $message"; //EVERYTHING BUT PASSWORD } else { $sql = "UPDATE users SET password = $password, email = $email, area = $area, phone = $phone, age = $age, message = $message"; //EVERYTHING INCLUDING PASSWORD } mysql_query($query); [/code]You don't see a problem here? Your variable which contains the SQL is called $sql. Yet you're calling mysql_query with $query. You also need to add a WHERE or you'll update EVERYTHING, not nothing as was suggested above. You ALSO need to add some mysql error checking, and quote your strings which I forgot. Go read some more tutorials on mysql ;) [code] if (empty($_POST['password'])) { $sql = "UPDATE users SET email = '$email', area = '$area', phone = '$phone', age = '$age', message = '$message'"; //EVERYTHING BUT PASSWORD } else { $sql = "UPDATE users SET password = '$password', area = '$area', phone = '$phone', age = '$age', message = '$message'"; $message"; //EVERYTHING INCLUDING PASSWORD } mysql_query($sql);[/code] Also what Shogun said was right. you have: [code]unset($_POST); $id = $_SESSION['userid']; if (empty($_POST['password'])) { }[/code] See a problem there?
-
Oh sorry. $num = rand(0,1); if($num){ $value = $value-($value*.02); }else{ $value = $value+($value*.02); } Is that what you mean?
-
right before the loop... Bah, I guess that's not technically a "loop". Before the ifelse. $radio = mysql_real_escape_string($_POST['RadioGroup1']); print $radio; if (trim($radio) === 'number') { $query = "SELECT * FROM $table WHERE $field_to_search LIKE '$trimmed'"; } else { $query = "SELECT * FROM $table WHERE $field_to_search1 LIKE '$trimmed'"; }
-
Why can't you? What error do you get?