
Alex
Staff Alumni-
Posts
2,467 -
Joined
-
Last visited
Everything posted by Alex
-
<p><img src="someimage.jpg" alt="" align="left" /> Your text here . Your text here . Your text here . Your text here . Your text here . Your text here . Your text here . Your text here . </p>
-
[SOLVED] server status check script always saying online
Alex replied to Jnerocorp's topic in PHP Coding Help
You're over complicating things and making a mistake somewhere, it would be easier to do something like this: <?php $list = Array(Array('fewfm43f.com', 80), Array('google.com', 80)); foreach($list as $check) echo (@fsockopen($check[0], $check[1], $errno, $errstr, 5)) ? "{$check[0]} is Online!<br />\n" : "{$check[0]} is Offline!<br />\n" ; ?> -
Yup.
-
Not being very clear.. $var = "<a href='http://phpfreaks.com'>PHP Freaks!</a>"; echo $var;
-
try: $sql = "INSERT INTO `dbase`.`dtable` (`name`, `last`, `mi`, `add`, `add2`, `city`, `state`, `zip`, `hp`, `cp`, `work`, `email`, `make`, `model`, `color`, `plate`) VALUES ( {$_POST['name']}, {$_POST['last']}, {$_POST['mi']}, {$_POST['phone']}, {$_POST['cp']}, {$_POST['wp']}, {$_POST['add']}, {$_POST['add2']}, {$_POST['city']}, {$_POST['state']}, {$_POST['zip']}, " . md5(md5($_POST['password'])) . ", {$_POST['make']}, {$_POST['model']}, {$_POST['color']}, {$_POST['plate']})";
-
Alternatively you can name the constructor as the same name as the class. All of this is stuff that you should probably look into: http://us.php.net/zend-engine-2.php
-
Ah, I've been out of writing PHP for a long while and am used to Actionscript classes. I just figured the syntax would be $this -> $xml, but I see how that wouldn't work. Thanks again for all the help guys. Yea, I actually don't like that AS OOP allows that. But even in AS OOP you're allowed to do: this.something; just not required to.
-
I actually noticed and fixed that before you posted that. @OP: The main thing you'll need to know is how to use $this, $this is used inside of a class to access methods or properties within itself. So if a class has a property of $xml, to access that property from within the class you'd do $this->xml
-
class retrieveStats { //set XML file public $xml_stats = "./visits.xml"; private $xml; //load XML file public function load_xml() { $this->xml = simplexml_load_file($this->xml_stats); } public function show_ids() { if (count($this->xml -> hit) > 0) { foreach ($this->xml -> hit as $a) { echo $a -> id; }//end foreach }//end if } //end show_ids }//end class Edit: MadTechie inb4 me. But I put loading the xml file within a load_xml method instead of the construct because in your example you tried to use a load_xml method.
-
Well the reason for that is because strings must be surrounded by quotes, while ints don't need to be.
-
[SOLVED] help turning list of words into an array
Alex replied to Jnerocorp's topic in PHP Coding Help
Well, a quick google search returned this: http://www.mieliestronk.com/wordlist.html It has 58,000 words. -
Yea, he can just do that: echo substr($list['Article'], 0, 300); But it's usually a better idea to just let the query perform as much work as possible. And I really don't see why it isn't working.
-
$sql = "SELECT Author, Title, LEFT(Article, 300) as Article, DATE_FORMAT(Date,'%e/%m/%y') as Date FROM news ORDER BY id DESC LIMIT $offset, $rowsperpage"; Edit: Whoops, to make it easier just use: LEFT(Article, 300) as Article. That way you don't have to edit the following code.
-
[SOLVED] help turning list of words into an array
Alex replied to Jnerocorp's topic in PHP Coding Help
file() does exactly this, takes the contents of a file and stores each line in an element of an array. $array = file('sometextfile.txt'); -
SELECT ... LEFT(Article, 300) ...
-
You most likely messed up something on accident while trying to edit it. It would be a good idea to either post the original (unedited source) or to just try to reedit being more careful, because I doubt anyone is going to watch to search through all that code and try to find the differences.
-
Try this: <?php $arr = Array("images/smilies/rofl.gif", "don't remove", Array("images/smilies/something.gif", "don't remove", "don't remove")); function removeRec(&$arr) { foreach($arr as $key => &$part) { if(is_array($part)) removeRec($part); else if(!stristr($part, "images/smilies") === false) unset($arr[$key]); } } echo "<pre>"; print_r($arr); removeRec($arr); print_r($arr); echo "</pre>"; ?> Output: Array ( [0] => images/smilies/rofl.gif [1] => don't remove [2] => Array ( [0] => images/smilies/something.gif [1] => don't remove [2] => don't remove ) ) Array ( [1] => don't remove [2] => Array ( [1] => don't remove [2] => don't remove ) )
-
Your query was all messed up, try this: $sql = "INSERT INTO `dbase`.`table` (`name`, `last`, `mi`, `add`, `add2`, `city`, `state`, `zip`, `hp`, `cp`, `work`, `email`, `make`, `model`, `color`, `plate`) values ( " . $_POST['name'] . ", " . $_POST['last'] . ", " . $_POST['mi'] . ", " . $_POST['phone'] . ", " . $_POST['cp'] . ", " . $_POST['wp'] . ", " . $_POST['add'] . ", " . $_POST['add2'] . ", " . $_POST['city'] . ", " . $_POST['state'] . ", " . $_POST['zip'] . ", " . md5(md5($_POST['password'])) . ", " . $_POST['make'] . ", " . $_POST['model'] . ", " . $_POST['color'] . " " . $_POST['plate'] . " )"; You should also be securing all values being used in a mysql query with mysql_real_escape_string()