
spires
Members-
Posts
492 -
Joined
-
Last visited
Everything posted by spires
-
Sorry, Me being a total idiot. I was running: if(Admin_emails::send_notification($sendTo, $toName){ echo 'Saved'; } Instead of: $new_email_obj = new Admin_emails(); if($new_email_obj->send_notification($sendTo, $toName)){ echo 'Saved'; }
-
Even more stripped away: Still getting the error: Fatal error: Using $this when not in object context in /home/p/o/powtest/web/public_html/includes/admin_emails.php on line 10 class Admin_emails { public $subject; public function send_notification(){ $sub = $this->subject; } }
-
OK. I have taken it right back to bear bones. And still get the error. FULL CLASS class Admin_emails { protected static $table_name="admin_emails"; protected static $db_fields = array('id', 'name', 'subject', 'body_content', 'from_name', 'from_email'); public $id; public $name; public $subject; public $body_content; public $from_name; public $from_email; public function send_notification($sendTo, $name){ $subject = $this->subject; } } What am I missing?
-
ok, Thanks for your help I'll have a look around a few sites, see if I can find anything
-
Actually, Scrap that. It's not working with my work around. Yes the error has gone, but the values are now empty? $new_email = new Admin_emails(); $subject = $new_email->subject; echo $subject; $subject is empty I should be able to use $this->subject, but can't? Any ideas?
-
Hi Yes I do. I've got a solution: $new_email = new Admin_emails(); $subject = $new_email->subject; But i'm not sure why the first way is not working. It should work fine. Unless i'm missing something. Full Class: <?PHP require_once(LIB_PATH.DS.'database.php'); class Admin_emails { protected static $table_name="admin_emails"; protected static $db_fields = array('id', 'name', 'subject', 'body_content', 'from_name', 'from_email'); public $id; public $name; public $subject; public $body_content; public $from_name; public $from_email; public static function make($NAME, $SUB, $BODY, $FROM, $Femail){ if(!empty($SUB) && !empty($BODY) && !empty($FROM)){ $kw = new Admin_emails(); $kw->name = $NAME; $kw->subject = $SUB; $kw->body_content = $BODY; $kw->from_name = $FROM; $kw->from_email = $Femail; return $kw; }else{ return false; } } public function send_notification($sendTo, $name){ $new_email = new Admin_emails(); $to_name = $name; $to = $sendTo; $subject = $new_email->subject; $message =<<<EMAILBODY {$new_email->body_content} EMAILBODY; $message = wordwrap($message, 70); $from_name = $new_email->from_name; $from = $new_email->from_email; $mail = new PHPMailer(); $mail->IsSMTP(); $mail->Host = "localhost"; $mail->Port = 25; $mail->SMTPAuth = false; $mail->FromName = $from_name; $mail->From = $from; $mail->AddAddress($to, $to_name); $mail->Subject = $subject; $mail->Body = $message; $result = $mail->Send(); return $result; } }
-
Hi Can anyone see why $this->subject is not working? I have a class that is going to send an email. All the variables are set and contain values. How ever, I'm getting an error if I try to use the subject variable inside a method? Error: Fatal error: Using $this when not in object context in /home/p/o/powtest/web/public_html/includes/admin_emails.php on line 36 Line 36 is: $subject = $this->subject; protected static $table_name="admin_emails"; protected static $db_fields = array('id', 'name', 'subject', 'body_content', 'from_name', 'from_email'); public $id; public $name; public $subject; public $body_content; public $from_name; public $from_email; public function send_notification($sendTo, $name){ $to_name = $name; $to = $sendTo; $subject = $this->subject; $message =<<<EMAILBODY {$this->body} EMAILBODY; $message = wordwrap($message, 70); $from_name = $this->from; $from = $this->from_email; $mail = new PHPMailer(); $mail->IsSMTP(); $mail->Host = "localhost"; $mail->Port = 25; $mail->SMTPAuth = false; $mail->FromName = $from_name; $mail->From = $from; $mail->AddAddress($to, $to_name); $mail->Subject = $subject; $mail->Body = $message; $result = $mail->Send(); return $result; } Any help or pointer would be great. Thanks
-
Hi I am trying my first OOP update. I have it working exactly as I want except for one thing. For some reason if I try to update the database with the same information (every column exactly the same) it returns 0 affected rows. is there anyway of getting the database to update, even if all columns are exactly the same? Code: $membershipID = Profile_membership::find_membership_ID($UID); $MID = $membershipID->id; $new_member = Profile_membership::make($MID, $UID, $acc_type, $membership, $upgradeL, $date, $dateUpgraded); if($new_member && $new_member->save()){ $flag = 1; }else{ $message .= "Error: Sorry, there was an error creating your membership. <br> Please try again<br>"; $flag = 0; } $new_member->save() will create the database entry if no ID exists, and will update if an ID does exist. So, I want the save() to return success. If it does, move on else give an error. However, I'm getting the error, if a user accidentally clicks submit, when no fields have been changed. I what it to still update, so $flag will be 1 Thanks
-
Hi Everyone. I'm working on a form, that allows the user to select the country / county / area where they are from. I am doing this using: - mysql database store the locations in - PHP OOP, to pull this information from the database - AJAX/Javascript to only show the next dropdown, once the first dropdown has been selected. Example: select country then the county dropdown will appear, select county then the area/town will appear. However, the first drop down for country is placed directly on to the page. So the javascript works fine. but the second dropdown is placed in to a PHP function, and the javascript seems to no longer want to work. CODE: //////////////// CODE FOR COUNTRY /////////// if(isset($_REQUEST['country'])) { echo ' <div class="labelleft">County / State:</div> <div class="fieldleft"> <div > <select name="county" id="county" onchange="javascript:AJAXQuery("lib/search.php?town="+this.value, "tw", "")"> <option value="0">Select County</option> <option value="0">-------</option>'; $countyList = Area_county::find_country_id($_REQUEST['country']); foreach($countyList as $countyLists){ $county_id = $countyLists->id; $county_list = $countyLists->county; echo '<option value="'.$county_id.'">'.ucwords($county_list).'</option>'; } echo ' </select> </div> </div> <div class="clear"></div>'; } Any ideas? Thanks
-
Hi. I'm trying to create a directory folder on my server. I am using the following code, but keep getting an error? The images folder is set to 0777 on the server, and the file is located just outside the images folder. $uID = $new_user->id; mkdir('/images/'.$uID.'/main/thumb', 0777, true); mkdir('/images/'.$uID.'/main/large', 0777, true); Error: Warning: mkdir() [function.mkdir]: Permission denied in /home/p/o/powtest/web/public_html/test_users.php on line 19 Warning: mkdir() [function.mkdir]: Permission denied in /home/p/o/powtest/web/public_html/test_users.php on line 20 Thanks for your help
-
Hi I am trying to set this simple bit of code up in a class: $lastID_sql = "SELECT max(id) FROM admin_interest"; $lastID_query = mysql_query($lastID_sql) or die ('Line 6: '.mysql_error()); $lastID_Row = mysql_fetch_array($lastID_query); $lastID = $lastID_Row['max(id)']; As you can see, you need to return the max(id) to be able to display that value that you want. My Class: class Admin_interest { protected static $table_name="admin_interest"; protected static $db_fields = array('id', 'interest_category', 'type'); public $id; public $interest_category; public $type; public static function find_by_maxID(){ global $database; $sql = "SELECT max(id) FROM ".self::$table_name." LIMIT 1"; $result_array = self::find_by_sql($sql); return !empty($result_array) ? array_shift($result_array) : false; } Displaying the class $found_lastID = Admin_interest::find_by_maxID(); echo $found_lastID->id . '<br>'; The value, as expected is blank. I've tried $found_lastID->max(id) But this comes back with an error Any ideas? Thanks
-
Works perfect thanks
-
Hi I have 3 strings. $discount2 = '12,000'; $discount3 = '1.00'; $discount4 = '10,000.01'; I need to add these together. $less234discount = $discount2 + $discount3 + $discount4; $less234discount = number_format($less234discount, 2); BUT, it will not calculate past the comma. It only sees: 12, 1, 10 NOT 12,000 1.00 10,000.01 How can I add these up correctly? Thanks for your help
-
Hi I want to check if a string has numbers in it. I've tried using is_numeric, but this on returns true if the string is all numeric. Not if it's a combination of characters and numbers. How can I check to see if my sting contains numbers. Example: Spires01 -- Should return True Spires -- Should return false Thanks
-
It's a varchar Does it need to be int? Thanks
-
HI I'm trying to get the highest number out of a database, I'm doing by: SELECT * FROM csv_tempStored ORDER by temp DESC LIMIT 1 This should take every number in the temp column, and place the numbers in descending order. However, I have all the following numbers in the temp column, but it keeps returning 9 instead of 21. 1, 2, 5, 6, 8, 9, 10, 11, 13, 14, 15, 16, 17, 18, 19, 20, 21 (they are in a random order in database) Any ideas why it's returning 9 and not 21? Thanks for your help
-
Of Course Seems so obvious now. Thanks for your help
-
Hi. I'm trying to select user from the database depending on the users access level. However, I can only select one level at a time. This is what I want to do: SELECT * FROM csv_login WHERE login_level='2' && login_level='4' But this will bring back nothing. It will only let me do: SELECT * FROM csv_login WHERE login_level='2' OR SELECT * FROM csv_login WHERE login_level='4' But not both. How do I get around this? Thanks for your help.
-
They got in to the database. I'm now trying to stop this from happening again. I'm not to sure if they got any info out or not.
-
Hi codex-m I use addslashes() is this just as good as mysql_real_escape_string()?
-
ok, thanks. Is there any way of seeing if it was hacked?
-
Hi I've had some one try to hack my account. declare @q varchar(8000) select @q = 0x57414954464F522044454C4159202730303A30303A313527 exec(@q) Does anyone know what this hack does? Or, how to stop it? Thanks
-
I'm on a dedicated server. Ok, well thanks for all your help with this, at least i'm moving in the right direction now Cheers
-
Hi, Thanks for your help, Glad I asked now, I never would nave seen that There is however, a new bug that has been thrown up: Warning: require_once(/htdocs/PHP_Training/beyond_the_basics/photogallery/includes/initialize.php) [function.require-once]: failed to open stream: No such file or directory in /home/p/o/powtest/web/public_html/PHP_Training/beyond_the_basics/photogallery/public/admin/index2.php on line 2 Fatal error: require_once() [function.require]: Failed opening required '/htdocs/PHP_Training/beyond_the_basics/photogallery/includes/initialize.php' (include_path='.:/usr/share/php:/usr/share/pear') in /home/p/o/powtest/web/public_html/PHP_Training/beyond_the_basics/photogallery/public/admin/index2.php on line 2 It looks like it's to do with: require_once($_SERVER['DOCUMENT_ROOT'] . "/PHP_Training/beyond_the_basics/photogallery/includes/initialize.php"); any other pointers would be very helpfull Thanks
-
Hi. I have a website that i'm using to learn PHP OOP. To make my website more dynamic, I want to be able to place all include files into one php file 'initialize.php' But, I keep getting an error. initialize.php <?PHP defined('DS') ? null : define('DS', DIRECTORY_SEPARATOR); defined('SITE_ROOT') ? null : define('SITE_ROOT', 'http://powtest.co.uk'.DS.'PHP_Training'.DS.'beyond_the_basics'.DS.'photogallery'); defined('LIB_PATH') ? null : define('LIB_PATH', SITE_ROOT.DS.'includes'); require_once(LIB_PATH.DS."config.php"); require_once(LIB_PATH.DS."functions.php"); require_once(LIB_PATH.DS."session.php"); require_once(LIB_PATH.DS."database.php"); require_once(LIB_PATH.DS."user.php"); ?> index.php <?PHP require_once("../../includes/initialize.php"); if (!$session->is_logged_in()) { redirect_to('login2.php'); } $user = User::find_by_id($session->user_id); ?> PATH FOR INDEX.PHP: http://powtest.co.uk PHP_Training beyond_the_basics photogallery public admin index.php PATH FOR INITIALIZE.PHP: http://powtest.co.uk PHP_Training beyond_the_basics photogallery includes ERROR Warning: require_once() [function.require-once]: URL file-access is disabled in the server configuration in /home/p/o/powtest/web/public_html/PHP_Training/beyond_the_basics/photogallery/includes/initialize.php on line 7 Warning: require_once(http://powtest.co.uk/PHP_Training/beyond_the_basics/photogallery/includes/config.php) [function.require-once]: failed to open stream: no suitable wrapper could be found in /home/p/o/powtest/web/public_html/PHP_Training/beyond_the_basics/photogallery/includes/initialize.php on line 7 Fatal error: require_once() [function.require]: Failed opening required 'http://powtest.co.uk/PHP_Training/beyond_the_basics/photogallery/includes/config.php' (include_path='.:/usr/share/php:/usr/share/pear') in /home/p/o/powtest/web/public_html/PHP_Training/beyond_the_basics/photogallery/includes/initialize.php on line 7 This is probably something very easy, but I just can't seems to see it. Thanks