-
Posts
327 -
Joined
-
Last visited
-
Days Won
3
Everything posted by objnoob
-
Wouldn't it be easier to pay me since you've found it too hard to Google anything thus far?
-
nope, you just accept the request and after validating the user permissions initiate the cgi script.
-
I do. file_get_contents to open the url and retrieve data preg_match_all and a regular expression could do the trick for extracting the data simplexml for writing output
-
DOM and SimpleXML are two PHP extensions one could use to read/write HTML, xHTML, XML and xHTML, XML respectively.
-
Yup, protect it with Apache. Only allow 127.0.0.1 (localhost) to access it.
-
probably because you have two columns with the same name cat.category_name, parent.category_name You should give one an alias using the AS keyword: SELECT cat.category_id, cat.category_name, cat.category_parent, parent.category_name AS parent_category_name FROM .... You'll then have both $data['category_name'] and $data['parent_category_name'] to work with.
-
Multiple LEFT JOINS not returning expected results
objnoob replied to jalinidy's topic in PHP Coding Help
i understand now. thanks -
And, this didn't peak your interest at all?-- because it's pretty badass and really what you should have wanted to learn! It makes useful use of your users' computer power and saves your server from doing extra stuff it really doesn't need. It also reduces the overall size of the transfer! Stop polluting the internet, thanks! ;] <style> .storm { background-color: black; color: #FFF; border: 1px #666 solid; text-align: center; font-size: .9em; } .storm.weak { color: rgb(255, 255, 0); } .storm.strong { color: rgb(255, 0, 0); } </style> <?php echo '<td class="storm ' . $tintensity . '">' . $tintensity . '<td>';
-
Multiple LEFT JOINS not returning expected results
objnoob replied to jalinidy's topic in PHP Coding Help
You shouldn't store calculated data. Unless the data changes infrequently and used VERY OFTEN and the calculations are derived from a VERY LARGE data set and take 5 minutes to produce. When you store calculations, you need mechanisms to ensure the stored value is in fact the correct value. When the data changes you need to update all of these balances columns and that is room for disaster. You should be calculating balances on the fly. Take max subtract used and you have a balance. There is no way your data set is going to be large enough to warrant storing derived data. Make sure to get your indices set up and make sure you're using them properly when joining / querying data. Learn how to read the output of MySQLs explain query feature. Don't store a request off that spans multiple days in one row. At most the request off should be a single date and time from / to. date | time_from | time_to ------------------------------------ 2013-01-01 | 00:00:00 | 23:59:59 = 24 HOURS the entire day. You can check if it's a holiday by looking the date up in the holidays table. if you don't need to be exact on from & to, you can just store how many hours as a single column. You don't have to have an extra table to map the request off record with the holiday record- The of the request off date should be enough to map it to any holiday. You don't need an ID column in the holidays table. The date column is the primary key / ID -
How to determine 5 seconds instead of 24 hours using timestamp
objnoob replied to therocker's topic in PHP Coding Help
it's very [programmer] human-readable for me too! when working with large schemas and large data sets, i've found it's more productive to work outside of php. This format is the most useful to me and easily sortable by eye. after all, it wasn't an accident the Y-m-d H:i:s became the format. -
Trying to CONCAT two columns in a Select query...
objnoob replied to Jim R's topic in PHP Coding Help
$query = 'SELECT * FROM a_playerRank WHERE CONCAT(nameFirst," ",nameLast) = \'' . $slug . '\''; or better yet.... $query = "SELECT * FROM a_playerRank WHERE CONCAT_WS(' ', nameFirst, nameLast) = '{$slug}'"; Line 14 is.... while($line = mysql_fetch_assoc($results)) { -
Multiple LEFT JOINS not returning expected results
objnoob replied to jalinidy's topic in PHP Coding Help
I mean the word outer is optional, but the effect is the same. -
Heh, I failed to notice this. Good catch.
-
Better yet.... You can define classes, then you wont have to switch() shit. <style> .storm.weak { color: rgb(255, 255, 0); } .storm.strong { color: rgb(255, 0, 0); } </style> <?php echo '<td class="storm ' . $tintensity . '">' . $tintensity . '<td>';
-
You need to put that CSS inside the style attribute. echo '<td style="color: ' . $stormIntensity[$k] . '">' . $tintensity . '<td>'
-
Unless it's your own email server's incoming mail, you have no control over how a piece of email get's classified as spam or junk.
- 1 reply
-
- email authentication
- dkim
-
(and 2 more)
Tagged with:
-
How to determine 5 seconds instead of 24 hours using timestamp
objnoob replied to therocker's topic in PHP Coding Help
Datetime is great! Trying storing an 80 year old's birth date as a timestamp... I bet you can't. Do you know why you can't? Datetimes typically require more overhead than timestamps. But that's to be expected. -
I give this guy a standing ovation for asking people to complete his class assignments. Bravo!
-
Copy one table row and add to another table...
objnoob replied to Red2034's topic in PHP Coding Help
Most RDBMS have syntax to accomplish this is one query! For example, in MySQL: INSERT INTO tblName1 (column1, column2) SELECT thisColumn1, thisColumn2 FROM tblName2; Visit http://dev.mysql.com/doc/refman/5.0/en/insert-select.html for more information on INSERT SELECT. In other RBDMS, such as SQLServer, this is known as a SELECT INTO. http://technet.microsoft.com/en-us/library/ms188029.aspx -
It's quite obvious the OP is learning...... ideas will be conjured and dispelled. mistakes will be made and corrected. the learning process is full of trials and tribulations. A better understanding of OOP and the PDO class. Such a colossal waste, right? Lighten up, man. I can list 10 reasons why wrapping PDO is a great idea. I'd love to hear 10 to the contrary.
-
php code run 100% in localhost, but in cpanel no
objnoob replied to linuxfreakphp's topic in PHP Coding Help
Windows allows both \ or / as path separators.... so if you use / you shouldn't have a problem. What do you mean by... in the cpanel? I suspect something else is the issue. -
Sorry, but not exit() nor die() be proper ways to handle errors when content-type: text/html
-
class dbConnection { private $_conn = null; // the connection public $error = null; // the last exception caught public function connect(){ try{ $this->_conn = new PDO ("mysql:host=localhost;dbname=database", 'root', ''); $this->_conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); return $this->_conn; // connection made! return connection }catch(PDOException $ex) { /* caught PDOException on new PDO()! to avoid possibly displaying your mysql password you will construct your own PDOException with a safe message....... to store in $this->error */ $this->error = new PDOException('Couldn\'t connect to database!', $ex->getCode() ); return null; // connection failed! return null } } public function getConnection(){ return $this->_conn; } } $db = new dbConnection(); if( ! $conn = $db->connect() ){ echo $db->error->getMessage(); exit; }
-
Remove an element from a multi-dimensional array
objnoob replied to BerbBrown's topic in PHP Coding Help
if the values are string void <?php foreach($yourArray as $k0=>$innerArray){ foreach($innerArray as $k1=>$value){ if(strtolower($value) === 'void') unset($yourArray[$k0][$k1]); } # will reindex array: $yourArray[$k0] = array_values($yourArray[$k0]); } if the values are actually null <?php foreach($yourArray as $k0=>$innerArray){ foreach($innerArray as $k1=>$value){ if($value == null) unset($yourArray[$k0][$k1]); } # will reindex array: $yourArray[$k0] = array_values($yourArray[$k0]); } You could also look into the array_filter() function http://us2.php.net/array_filter -
Shayna23, there are a number of ways to accomplish any and everything. Some are better practices than others, as well as being more secure and robust as others. Some are simply better for purposes of readability and understanding. I personally would choose ${$var}. Easy to see the separation!