-
Posts
1,025 -
Joined
-
Last visited
Never
Posts posted by Caesar
-
-
Edit: Beat me to it.
-
If `desc` is a column/field in your database table, you need to surround it with tics. It is a MYSQL reserved word.
-
Well...we're assuming now they're on PHP 5. Not a bad suggestion...but, would suggest accommodating a PHP 4 configuration as well.
-
What happens if someone enters 'http:mydomain.com'? '...How about 'http:// whoops i have spaces and invalid characters here .com'?
One can't assume that a simple check based on string or character position will account for users who blindly type without thinking. Most people ont he internet don't :-P
-
By the way...in case that confused you, implementation would look something like this...
<?php function CheckURL($url) { if(preg_match('/http\:\/\/[aA-zZ0-9\.]+\.[aA-zZ0-9]+?[\?\=\_\-\/[aA-zZ0-9]+/', $url)) $link = $url; else $link = 'http://'.$url; return $link; } //// Assuming the POST variables have already been defined... $linkone = CheckURL($_POST['linkone']); // If the link is 'google.com', 'http://google.com' will be returned. $linktwo = CheckURL($_POST['linktwo']); // If the link is 'http://yahoo.com', the same value will be returned without changes. ?>
...But as stated...you want to make sure you check ALL user input to make sure no SQL injection or XSS is possible.
-
simply use string function i think strrpos or strstr is enough and faster
Assuming all his links are formatted the same. This is user input we're talking about. So many things can go wrong and so many things can be entered.
-
<?php function CheckURL($url) { if(preg_match('/http\:\/\/[aA-zZ0-9\.]+\.[aA-zZ0-9]+?[\?\=\_\-\/[aA-zZ0-9]+/', $url)) $link = $url; else $link = 'http://'.$url; return $link; } ?>
Though I caution that you should scrub/clean any user input and not assume that the url or link is valid to begin with. You'll want to check that as well.
-
Not for this specifically....I doubt it. But to do something like that would require only a basic to intermediate understanding of PHP and HTML. You'll want to look into fopen() and fwrite() and understand how paths work, relative to where you are on the server. Knowing that, you should be able to write your code with no problem.
-
If this is your server, then it's possible. Otherwise, the default settings may not allow a PHP script to access a file that isn't in a public folder. If the use of site/user based php.ini files is enabled, then it should be easy.
-
Any particular reason why you'd be using .ini files for this?
Also, yes, you can use PHP to write to files using something like a series dropdowns. In my opinion that's kind of clumsy and definitely want something like that limited by implementation of a user/account system.
-
<?php function RemoveExtension($img) { $pos = strrpos($img, '.'); if($pos) $str = substr($img, 0, $pos); else $str = $img; return $str; } ?>
-
<?php $string = 'This is my test <img src="link_to_image1" border="0">, some other text.<img src="link_to_another_image" border="0">'; $str = preg_replace('/\<img src=\"[aA-zZ0-9\/\_\.]+\" border=\"[0-9]+\"\>/','',$string, 1); ?>
-
Assuming your quotes are in an array called $quotes
<?php function random_quotes($quotes) { $q = array(); for($count = 0; $count <= 2; $count += 1) { $num = rand(0, count($quotes)-1); while(in_array($num, $q)) $num = rand(0, count($quotes)-1); array_push($q, $num); } return $q; } ?>
Without testing much, that should return an array with three random keys. You can then display your quotes by using a foreach loop.
<?php $q = random_quotes($quotes); $i = 1; foreach ($q as $key) { echo'<ul>'.$i.'. '.$quotes[$key].'</ul>'; $i++; } ?>
-
How would I add this to the existing code? - Or what new codeset would I use with is_integer?
<?php if(!is_int($uid)) { //// Do the dew, dude. } ?>
-
Also...
http://us2.php.net/manual/en/function.is-numeric.php
Also...
<?php if(!preg_match('/[0-9]+/',$uid)) { //// Do the dew, dude. } ?>
-
-
-
One approach...
<?php if(!$f->login($sess)) $alert->errors('login'); ?>
...You can then have a nice error handling method you can pass a simple value to and it will return the correct error accordingly.
-
Are you talking about mysql_fetch_assoc perhaps?
-
Just edit your post, use <?php tags to open/close even if it isn't the entire script... and surround it with [ code ] [ /code ]...it will highlight your code accordingly and make it easier for people to look through.
-
If the folder the curl script is being executed from is not writable, change the cookie path to something like temp/cooki.txt, and make /temp CHMOD 777.
-
Did you take that code from somewhere? If so, it was probably inside a class.
-
You can recall/use a value within a method using $this like so...
<?php function myMethod($var) { return $this->value.$var; } ?>
You can't use $this outside of your method/class.
-
<?php $para = $_POST['send']; ?>
I have a logic issue and I just can't figure it out ... pls help!
in PHP Coding Help
Posted
If I understood.....