-
Posts
3,372 -
Joined
-
Last visited
-
Days Won
18
Everything posted by Muddy_Funster
-
Hi vipsa, please use code tags when posting code, and give us the full error message, including line number (with a pointer in the code, if you can, to that line). Incidently, while inside the class, you should use self:: rather than Donation:: unless you've got a reason not to. (I think your book may be a bit dated, i.e. for PHP4) throw a "public" in front of the static as well (it's not needed, but php5 only allows for omitiion for legacy compatability)
-
wasn't this exact question posted yesterday?
-
your current PHP code?
-
I don't know this CMS your reffering to, so I'm not 100% on the process that your trying to replicate. It sounds to me like you're mixing up your display code with your function code though (given the refference of setting a div as a variable).
-
No one is being nasty, just pointing out the inconsistancy of your statements. It's not like people haven't taken the time to give you help here.
-
you would need to use "Comet" programing, an example of which would be APE - the AJAX Push Engine - see here
-
ok, here's a little class I knocked up quick to show what it would look like to do something like this that way. The class would expect either a multi dimensional array or multiple key value pairs passed in to set the values. the conditions (the bit used after the WHERE) needs to be a multi dimesional array with field and value and flag set as keys for the arrays within it. This is still a massive over simplification as it only works with select queries, only works against a single table, and only words with absolout value checking in the WHRE clause (use of = and nothing else) This is untested and uncommented - it's really just to give you an idea of where you should be going with this. if anyone wants to play with it and make it work, do please be my guest. class buildMySQLSelect(){ public $finalQuery; public $cols; public $table; public $condition; public function setQryVals($val, $stVal=null){ if(is_array($val)){ foreach($val as $key => $value){ $this->$key = $value; } } elseif(($stVal != null) &&($val =='cols' || $val =='table' || $val == 'condition')){ $this->$val = $stVal; } } public function create(){ $this->makeSafe(); if(!empty($this->cols) && !empty($this->table)){ if(is_array($cols)){ $this->cols = implode(', ', $this->cols); } $q_cols = "SELECT {$this->cols}"; $q_table = "FROM {$this->table}"; $q_cnd = ""; if(!empty($this->condition)){ $cndCount = count($this->condition); if($cndCount == 1){ $q_cnd .= "WHERE {$this->condition['0']['field']} = {$this->condition['0']['value']}"; } elseif($cndCount > 1)){ $q_cnd .= "WHERE"; for($i=1; $i<=$cndCount; $i++){ $pKey = $i - 1; if($i == $cndCount){ $q_cnd .= " {$this->condition[$pKey]['field']} = {$this->condition[$pKey]['value']}"; } else{ $q_cnd .= " {$this->condition[$pKey]['field']} = {$this->condition[$pKey]['value']} {$this->condition[$pKey]['flag']} "; } } } $this->finalQuery = "$q_cols $q_table $q_cnd"; } } } private function makeSafe(){ if(is_array($this->cols)){ foreach ($this->cols as $idx => $value){ $value = "`".$value."`"; } } else{ $this->cols = "`".$this->cols."`"; } $this->table = "`".$this->table."`"; foreach($this->condition as $pIDX=> $sArray){ $sArray['field'] = "`".$sArray['field']."`"; $sArray['value'] = trim($sArray['value']); if(!filter_var($sArray['value'], FILTER_VALIDATE_INT) && !filter_var($sArray['value'], FILTER_VALIDATE_FLOAT)){ if(filter_var(filter_var($sArray['value'], FILTER_SANITIZE_EMAIL), FILTER_VALIDATE_EMAIL){ $sArray['value'] = filter_var($sArray['value'], FILTER_SANITIZE_EMAIL); $sArray['value'] = mysql_real_escape_string($sArray['value']); } else{ $sArray['value'] = filter_var($sArray['value'], FILTER_SANIZE_STRING, FILTER_ENCODE_LOW); $sArray['value'] = musql_real_escape_string($sArray['vlaue']); } } if(!isset($sArray['flag']) || (trim($sArray['flag']) !="AND" && trim($sArray['flag']) != "and" && trim($sArray['flag']) !="OR" && trim($sArray['flag']) != "or")){ $sArray['flag'] = 'AND'; } } } }
-
what's stoping it connecting?
-
Maybe you should take that up with an admin.......oh, wait
-
There is absoloutly nothing wrong with the original query, and the suggested replacement will not work if there are more rows in the table than are being inserted. @ OP - you need to explain this statement, what actually happens?
-
As a general rule of thumb, if you don't understand it, don't mess with it. It's already only 6 lines of pretty simple code, why would you want to alter it?
-
Need To Have A Grid For Input Form With Php!
Muddy_Funster replied to saravanataee's topic in PHP Coding Help
that too I just do it the other way because eclipse gets upset about form tags apparently not being alowed to contain table tags (tbody, tr, th and td are all fine, just not table its self for some reason ) even though it renders fine in the browser -
as trq pointed out - you need to actually execute the query using mysql_query($sql) or die(mysql_error()); before you can access the results in the while loop. That you don't have any errors telling you this is a bit concerning. You should alwaus have error reporting turned on for development - if this is a development enviroment please find and edit your php.ini file to include E_ALL and E_STRICT for error reporting.
-
It doesn't really get any simpler than what trq posted.
-
How are you expecting this script to work? is it supposed to send a mail for every entry in the database or for a single, specific entry? What's happening just now is that the value in $row['email'] is that of the last record returned from the table, which in this case must have no email address.
-
then the data is getting lost somewhere along the line. post your full pcage of code please?
-
ok, between the $to=$row['email'] and the mail() line add die('$to is set to -'.$to.'-'); and lets see what comes back.
-
all that bit of code does is, each time an item is added to the cart, steps through everything that is already in the cart, and if that item has already been put into the cart updates the quantity rather than adding a whole new item line.
-
as a debugging step what happens if you set $to to the address you are testing manualy?
-
on the line above the mail() line add $to = $row['emailAddress'];
-
Need To Have A Grid For Input Form With Php!
Muddy_Funster replied to saravanataee's topic in PHP Coding Help
just put the form inside a table? -
each one is onely as secure as you make it. if you are providing write permissions to either the file system or the database you open up security. you yourself need to code in enough security in your script, regardless of which you use, to make sure that only what you want to happen is allowed to happen. That aside :- image = file --> folder = part of file system --> file system = specificaly designed to handle files
-
glad to have helped (evin if Psycho is far better at it than I am....*grumbles*) gl
-
The idea should be that it would be a minimum time, as bots eat through forms way quicker than people do, so thinking about a user name would actualy be better for the person filling out the form because a bot never stops to think, it just batters options in untill something givs Edt : yeah - what Jessica said :/ damn my slow fingers :'(