Jump to content

sanfly

Members
  • Posts

    344
  • Joined

  • Last visited

Profile Information

  • Gender
    Female
  • Location
    New Zealand

sanfly's Achievements

Member

Member (2/5)

0

Reputation

  1. In my Payment model I have the following var $payMethodAll = array( '0' => 'Cash On Arrival', '1' => 'Direct Debit', '2' => 'Post (Cheque Only)', '3' => 'Credit Card', '4' => 'Account Credit', '5' => 'Account Credit + Direct Debit' ); In my Bookings controller, I call this data: $pMethods = $this->Payment->payMethodAll; And I get the following error: Notice (: Undefined property: AppModel::$payMethodAll [APP\controllers\bookings_controller.php, line 180] This was working perfectly before but now all of a sudden is not. I have tried clearing my tmp/cache/models Im confused as to what the problem is, because in the bookings_controller I can use the model to get data from the database without issue: ie: $p = $this->Payment->find('all'); works perfectly so not an issue with not having 'Payment' listed in $uses in my controller, or the model name being incorrect... Any ideas?
  2. Hi I have two fields in my users table: first_name & last_name I want to be able search by name (first or last or first & last) to return a result eg: lets say I have Joe Bloggs and Joe Jenkins If I search 'Joe' i get both back (thats fine) If I search 'Bloggs' I just get Joe Bloggs back (also fine) But if I search 'Joe Bloggs' I dont get the correct results back, I guess because its looking firstly in first_name and then in last_name This is my request for this search $u = $this->User->find('all', array('conditions' => array( "OR" => array( 'User.first_name LIKE ' => "%" . trim($input) . "%", 'User.last_name LIKE ' => "%" . trim($input) . "%", ) ) )); I have an awful feeling this could get really complicated with exploding the input into arrays and nested requests? Anyone have any ideas - especially ones that will keep it uncomplicated
  3. Hi Im very new to Ajax and using prototype am looking at the ajax.Request function to send form data to another page, evaluate and return a response. If I am using post for my method, in the Parameters can I just use the ID of the form itself to pass data through, or do I have to layout each form element and its value individually?
  4. sanfly

    if else

    Its been so long since Ive coded proper PHP (I've been using CakePHP for a few years now) I can hardly remember how the database calls go. Perhaps something like (hope my syntax is correct) <?php $r1 = mysql_query("SELECT * FROM tablename WHERE fieldname == '$comparison_value'"); if(mysql_num_rows($r1) > 0){ echo "its a duplicate"; } else{ echo "its unique"; } ?>
  5. I agree that its a bit much green at the top of the page In your first box under the menu where it says "local tree surgeon" etc...., im not sure there is any benefit in repeating the logo/company name in there I wonder if you should have your "mission statement" above the "Benefits" The benefits seem to have a lot of acronyms. Are all your customers going to know what these mean? I also find it a little ironic that you talk about how you can look after trees to maintain their health/beauty/benefits and then have a picture of a truck with what appears to be a lot of big logs from felled trees - perhaps a pic of one of your aborists at work "caring" for a tree would be paint a better image?
  6. In the PHP manual it does say that if you're sending a lot of emails, its not that great to use mail(), and gives some pear packages you could use. I've done a bit of googling and can't verify this, but I have a vague memory of seeing this problem previously, and it having something to do with a server timeout or something? Maybe if you add a 5 second + rest in every 5-10 emails that might help? Also, just keep in mind some mailservers/webservers have a limit on how many emails you can send in 1 hour to deter spammers - it may pay to check what this limit is for your host. Is you're error reporting on in php_ini? Seeing any errors?
  7. sanfly

    if else

    Im also a big fan of curly brackets, and wasn't sure the code would work without them, so I did a little test <?php $br = "breeze"; if($br == "breeze") echo "its a breeze"; else echo "not so easy"; ?> and the result was "its a breeze" so while I agree curly brackets are probably best practice, they don't appear to be necessary
  8. sanfly

    if else

    My first hint would be to check out the Comparison Operators in the PHP manual in your if statement comparison you should have == not =
  9. You really need to give more info about your table structure when you ask for help. All I can do is make my best guess based on the info provided I cant guarantee this will work as I dont have the table structures and form data, and also Im not able to test, but you should be able to get the right idea Step 1: Get the lowest score in the leaderboard <?php $lb = $this->Leaderboard->find('first', array('order' => array('Leaderboard.score DESC'))); $lowestscore = $lb['Leaderboard']['score']; ?> Step 2: Check if the users score is greater than the lowest score <?php if($lowestscore < $this->data['User']['score']){ // Delete current low score $this->Leaderboard->delete($lb['Leaderboard']['id']); // Insert the new score $this->data['Leaderboard']['user'] = $this->data['User']['id']; $this->data['Leaderboard']['score'] = $this->data['User']['score']; // Also add any other fields you need $this->Leaderboard->save($this->data['Leaderboard']); } ?>
  10. Hi I have three fields in a form: Mobile Phone, Home Phone and Work Phone. I require just one of these three fields to be filled in - is there a way to define this with the model data validation? I can make all three required, but like I said I require only one Cheers
  11. Thanks Wildteen88, that worked great Crayon Violet - I did have more complicated series of string searches etc that looked for <img then src (more or less what your regex does from what I can tell) - the only problem was if I added any styles to the image in TinyMCE, it would put the style tag attribute ahead of the src attribute and screw up my script. Thats when I decided I needed to just search for the src attribute. Cheers for your suggestion though.
  12. Hi Im using preg_match_all to find all instances of an image in a string <?php $textareainfo = '<p><img style="float: left;" _mce_style="float: left;" src="http://localhost/dsc-upgrade/img/uploads/content/hist-HappyValley1975.jpg" _mce_src="http://localhost/dsc-upgrade/img/uploads/content/hist-HappyValley1975.jpg" height="177" width="300">Progress with the High noon is going really well and to schedule.</p> <p>All the new high noon towers have been flown in and the old tower sections have been flown out. All the cross heads are on the towers and we have only two more wheel assemblies to fly in. We are currently tightening bolts on the towers, there is close to 150 bolts per tower and these all need to be torqued down to specification and the towers are being wired into the safety and control circuits.</p> <p>Our next milestone is to get the haul rope cable onto the towers and running so we can speed up access. Staff currently have to walk up each day, this will also allow us to better manage the lift through early ice storms. The top of the high flyer has been dismantled. Work is progressing well and we are scheduled to have the lift commissioned and certified by the end of May.</p>'; preg_match_all('/src=([\'"])?(.*?)\\1/', $textareainfo, $output); print_r($output); ?> My problem is that this code is taken from a TinyMCE textarea, and in the image tag it also has _mce_src="http://localhost/dsc-upgrade/img/uploads/content/hist-HappyValley1975.jpg" as well as the standard src So, what I want to do is modify the regex so that it doesnt return _src, only src. Unfortunately Im pretty useless with regex - Ive had a play around but have been unable to figure it out yet. Any help?
  13. Hello PHPfreaks! Im doing a server upload of a new cakePHP site for the first time in a long time, and am having some issues with my mod_rewrite (I believe this is the issue at least). My webhost has been next to useless on this issue, so Im hoping your freakiness will help me instead. With no files uploaded into the site, my folder structure looks like this in my FTP / myusername/ www.mydomain.com/ I uploaded everything from app/webroot into my webroot, which is the www.mydomain.com folder I also uploaded the app/ (without webroot) and cake/ folders into the same folder so I have something like: / myusername/ www.mydomain.com/ app/ cake/ css/ img/ etc..... index.php .htaccess etc.... Now, the frontpage of my site works fine, but when I navigate to any other page I get a 404 error In my .htaccess file <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ /index.php?url=$1 [QSA,L] </IfModule> After a bit of googling, I think that I need to add a RewriteBase line, but I cant figure out what to put. I think ive tried every combination I can think of but to no avail. One thing that may be of note is that we do not have this site/host/server connected to my domain name yet, as I wanted to get it all configured before I risked losing the old site, so Im actually accessing it by something like: http://www.mywebhost.com/www.mydomainname.com Any ideas? Cheers
  14. Good idea, but unfortunately didnt work - it only went down one branch eg: If my "dir" structure is: 2008 Winter Games Season Parties 2009 Ski Sale Winter Games All that was returned was: 2008 Winter Games Season Parties
  15. Hi Guys I have this function (below) which works great in its current setting, but Im now using cakePHP so I need to change it a little. I have an image gallery, there are categories in the gallery, each category can have sub categories, each sub-category can have sub-sub-categories etc, so I had this recursive function to put all the category names (in the correct order) in a select box so when I was uploading or moving an image I could select the correct destination category The function below just basically spits out (echos) each line as it comes to it - this was fine for my old site because I would just call the function in the spot where I wanted the select box to appear. NOW I want to collect up all the outputs into a string, then echo them in a place of my choosing. Any ideas how I do this? The Current Function <?function display_children($parent, $level, $selectedParent) { // retrieve all children of $parent include "includes/db.php"; $r = mysql_query("SELECT * FROM gal_cat WHERE gc_parent = '$parent' ORDER BY gc_order") or die(mysql_error()); // display each child while ($row = mysql_fetch_array($r)) { $gc_id = $row['gc_id']; $gc_name = $row['gc_name']; $gc_level = $row['gc_level']; $indent = str_repeat(' ',$level) // indent and display the title of this child ?> <option value="<?=$gc_id?>" <? if($gc_id == $selectedParent){ echo "selected"; } ?> class="optionHeight"><?=$indent?><?=$gc_name?><br> <? // call this function again to display this // child's children display_children($gc_id, $level+1, $selectedParent); } } ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.