Search Results

Search found 45 results on 2 pages for 'kwokwai'.

Page 1/2 | 1 2  | Next Page >

  • [PHP] function().function() VS function()function()

    - by kwokwai
    Hi all, I was writing a foreach Loop in PHP5. Here is the script: foreach(range('A','Z') as $char) // line 1 { // line 2 echo strtoupper($char)strtolower($char); // line 3 } // line 4 And I got this error message Parse error: parse error, unexpected T_STRING in testing.php on line 3 I spent almost an hour to figure out I should add a dot between two functions like this: echo strtoupper($char).strtolower($char); So I can't tell the difference between these two lines of codes: echo strtoupper($char).strtolower($char); echo strtoupper($char)strtolower($char);

    Read the article

  • [PHP] Sorting data in an array

    - by kwokwai
    Hi all, I got an array which has 7 types of fruit: $fruits = array( "lemon", "orange", "banana", "apple", "cherry", "apricot", "Blueberry" ); I don't know how to print out the data in a way that the outcome will like this: <A> Apple, Apricot (Note that Apricot is followed by Apple in alphabetic order) <B> Banana <C> Cherry <L> Lemon <O> Orange I am sorry that the question may be a bit difficult. But please kindly help if you could.

    Read the article

  • Model relationship types in cakePhP

    - by kwokwai
    I have checked out the cookbook web site of cakephp that there are four types Model relationship: http://book.cakephp.org/view/79/Relationship-Types Since the one I am more familiar with is belongsTo, I am not sure when I need to use hasManay and HABTM. What will be the result to my web site if I used a wrong Model relationship type? Please advise.

    Read the article

  • Naming convention for the primary key in a Table

    - by kwokwai
    Hi all, I am learning the Model relationship types in cakephp. I have built twotables and in one of the Table A, I got these fields in it: Table A {postID, topic, content} Table B {replyID, content, postID} And when I ran the web page, a bunch of error related to SQL popped up saying that cakephp couldn't find post_id. It is weird that I have already declared the $primaryKey to be using postID in the tableA.php under Models folder, but cakephp seemed want me to change the ID field to post_id instead of postID, because the error disappeared after I have changed the primaryKey to post_id. ANy ideas?

    Read the article

  • [Zend YouTubeAPP] failed to upgrade a token

    - by kwokwai
    Hi all, I was testing Zend Gdata 1.10.1 in my localhost. I downloaded Zend Gdate from this link: http://framework.zend.com/download/webservices Inside the Zend Gdata zip file, there was a folder called demos. I extracted it and used the YouTudeVideoApp to upload a sample video to Youtube. But every time after I logged into Youtube, before it redirected me to my localhost, I received a warning message like this warning message: localhost: This website is registered with Google to make authorization requests, but has not been configured to send requests securely. We recommend that you continue the process only if you trust the following destination: localhost:8080/youtube/operations.php So I googled on how to resolve the problem of getting this warning message when I saw some people suggesed changing the value of $secure to True in operation.php. Here is the script mentioned: function generateAuthSubRequestLink($nextUrl = null) { $scope = 'http://gdata.youtube.com'; $secure = true; $session = true; if (!$nextUrl) { generateUrlInformation(); $nextUrl = $_SESSION['operationsUrl']; } $url = Zend_Gdata_AuthSub::getAuthSubTokenUri($nextUrl, $scope, $secure, $session); echo '<a href="' . $url . '"><strong>Click here to authenticate with YouTube</strong></a>'; } After I altered the value of $secure to True, I found that the warning message changed to this: localhost: Registered, secure. This website is registered with Google to make authorization requests The new warning message is somehow shorter and looks better than the previous warning message. But once I pressed the Allow Access button, it turned out to be this: ERROR - Token upgrade for CI3M6_Q3EOGkxoL-___wEYjffToQQ failed : Token upgrade failed. Reason: Invalid AuthSub header. Error 401 ERROR - Unknown search type - '' I don't know why this happened. Could you help me solve the problem please?

    Read the article

  • SQL select statement

    - by kwokwai
    Hi all, I got a Table which has two fields: Point, and Level, with some sample data as follows: ----------------------- Point | Level ----------------------- 10 | Level 1 20 | Level 2 30 | Level 3 40 | Level 4 Suppose that there is a user who has 25 points, to find the Level in which this user is in, the Select statement I used was: Select Level from Table where Point < 30 AND Point > 20; But the Select SQL ststament is a hard-copy one where you can see the ponts 30 and 20 are fixed. I want to alter the Select statement so that the new SQL Select statement can be applied to all users with different points, but I don't know how to do it.

    Read the article

  • [PHP Array] - Sorting data and print out in alphabetic order

    - by kwokwai
    Hi all, I got an array which contains some data like this: $arrs = Array("ABC_efg", "@@zzAG", "@$abc", "ABC_abc") I was trying to print the data out in this way (Printing in alphabetic order): [String begins with character A] ABC_abc ABC_efg [String begins with character other than A to Z] @$abc @@zzAG I don't know how to do it.

    Read the article

  • What is dot and hash symbols mean in JQuery

    - by kwokwai
    Hi all, I feel confused of the dot and hash symbols in the following example: <DIV ID="row"> <DIV ID="c1"> <Input type="radio" name="testing" id="testing" VALUE="1">testing1 </DIV> </DIV> Code 1: $('#row DIV').mouseover(function(){ $('#row DIV).addClass('testing'); }); Code 2 $('.row div').mouseover(function(){ $(this).addClass('testing'); });? Codes 1 and 2 look very similar, and so it makes me so confused that when I should use ".row div" to refer to a specific DIV instead of using "#row div" ?

    Read the article

  • confused of $this in cakePHP

    - by kwokwai
    Hi all, I got a few lines of codes in a Model in cakePHP 1.26: function beforeSave() { $this->data['User']['pswd'] = md5($raw['User']['pswd']); return true; } // this beforeSave() works The code above has been tested and it is working in my database. Yet, I am not sure if I can understand it well, so, I re-wrote the code in other way, and it just failed to work then. function beforeSave() { $raw=$this->data; $raw['User']['pswd'] = md5($raw['User']['pswd']); return true; } // this beforeSave() failed to work Why the second method can not work?

    Read the article

  • How to use JQuery to focus on a specific DIV tag?

    - by kwokwai
    Hi all, Say I got a few DIV tags in a HTML page like: <DIV ID="div1"> <Input type="radio" name="data['site1']['user']" VALUE="1">user1<br/> </DIV> <DIV ID="div2"> <Input type="radio" name="data['site1']['user']" VALUE="2">user2<br/> </DIV> <DIV ID="div3"> <Input type="radio" name="data['site1']['user']" VALUE="3">user3<br/> </DIV> <DIV ID="div4"> <Input type="radio" name="data['site1']['user']" VALUE="4">user4<br/> </DIV> Is it possible to do the same effect in JQuery like this: Document.getElementByID('div2').focus();

    Read the article

  • How JQuery data validation plugin works on the submit action

    - by kwokwai
    Hi all, I am learning how to use JQuery validation plugin, and came across some questions about the JQuery magic that works on the sumbit action. I got a simple HTML form which has got an input text field like this: <form class="cmxform" id="commentForm" method="get" action=""> <input id="cname" name="name" size="25" class="required" minlength="2" /> <input class="submit" type="submit" value="Submit"/> </form> The magic happened when I tried not to input any data into the field and pressed the submit button. I saw an error message in red pop up, and no matter how hard and how many times I pressed the submit button, nothing was submitted. It seemed that there was some scripts that disabled the submit action, but I just couldn't find which lines of codes in the JQuery Validatyion Plugin that did it.

    Read the article

  • [CakePHP] what is the aim to declare $name in each controller

    - by kwokwai
    Hi all, I am leaning cakePHP. I noticed that a variable $name is declared in each Controller. What is its purpose? Is it referring to the name of table Sites? <?php class SitesController extends AppController { var $name = 'Sites'; ... } ?> If yes, Can users refer to more than one table like this? var $name = 'Sites', 'Sites2', 'Sites3';

    Read the article

  • Event handler triggered twice instead of once

    - by kwokwai
    Hi all, I am sorry that I have asked two questions in a few minutes. In a html file, I got three child DIV tags in a parent DIV tag: <div id="container"> <div id="frag-123">123</div> <div id="frag-124">124</div> <div id="frag-125">125</div> </div> Now when I click either the three child DIV tags, I will see two alert boxes pop up instead of one: The first alert box will show something like this: frag-123, and the second alert box will show something like this: container I dont know why. I just want to get the ID value of a child DIV, not the one from the parent DIV. <script> $(function() { $("div").click(function() { var imgID = this.id; alert(imgID); }); }); </script> Please help.

    Read the article

  • To pass the ID of DIV tag in JQuery

    - by kwokwai
    Hi all, I am learning JQuery. In a HTML file, I got this: <DIV ID="testing"> And I am trying to pass the ID of this DIV tag to a JQuery self-defined function: <script> $(function() { $("div").mouseover(function() { var ID = $(this).children().attr('id'); alert(ID); }); }); But it wont work.

    Read the article

  • Write a few things to a session in cakephp

    - by kwokwai
    Hi all, I am learning Session function in CakePhp, and see some examples like this on cakePHP cookBook web site: For example: write($mysession1, 'testing') I am not sure if a session can only hold up a particular thing in it. Is it possible to write an array to a session like: mysession[0] = 'Testing0'; mysession[1] = 'Testing1'; mysession[2] = 'Testing2';

    Read the article

  • [CakePHP] I am so confused. What should I write in the default.ctp

    - by kwokwai
    Hi all, I am learning cakePHP, everything seems alright except that I am very confused of how to make use of the default.ctp and what should be put inside the Elements folder. Here is the default.ctp file that I have been using since my very first lesson on learning cakePHP: (I copied from this URL http://book.cakephp.org/view/96/Layouts) <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title><?php echo $title_for_layout?></title> <link rel="shortcut icon" href="favicon.ico" type="image/x-icon"> <!-- Include external files and scripts here (See HTML helper for more info.) --> <?php echo $scripts_for_layout ?> </head> <body> <!-- If you'd like some sort of menu to show up on all of your views, include it here --> <div id="header"> <div id="menu">...</div> </div> <!-- Here's where I want my views to be displayed --> <?php echo $content_for_layout ?> <!-- Add a footer to each displayed page --> <div id="footer">...</div> </body> </html> But the problem is that the layout will take effect to all web pages that I have created. Let's see the case that I have recently encountered. In one of the .ctp files, I need to use JQuery function and I need to ass some and tags in the .ctp file. Here are the and tags I used: <Script language="javascript"> $(document).ready(function() { // some functions here }); </Script> <style type="text/css"> { #toppage{ width:800px; } But when I followed the default.ctp file, I noticed that these tags (i.e. and ) happened to appear below the tag. As far as I know, the and self-defined Javascript functions should be put inside the tag of the HTML instead. I have considered to add the and in the default.ctp file, but then these codes would appear in every web pages instead of just a particular web page. Please help.

    Read the article

  • JQuery AJAX returned too much data that I had not requested

    - by kwokwai
    Hi all, I am using CakePHP 1.26 and CDN JQuery in this URL: http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js In a HTML web page, I have these lines of code: $.ajax({ type: "POST", url: "http://mywebsite.com/controllers/avail/"+curl, success: function(data) { alert(data);} }); and in the PHP page, I got another few lines of code: function avail($uname){ $result1=$this->Site1->User->findByusername($uname); if($result1){ return 1; } else{ return 0; } } As you see, the Avail function will return either zero or one. But there was some redundant data returned from the server, what I saw in the Alert box was somthing like this (rather than 0 or 1): <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Missing Method in Controller</title> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> <style type="text/css"> /* CSS Document */ /*PAGE LAYOUT*/ 0

    Read the article

  • JQuery Post caused permission denied warning in IE 6 and IE 7

    - by kwokwai
    Hi all, I am using firefox 3 and IE 6, 7 to test if a simple php web page using JQuery Post to pass some data to and from another server web page. $(document).ready(function(){ $("#data\\[User\\]\\[name\\]").click(function(){ var usr=$("#data\\[User\\]\\[name\\]").val(); if(usr.length >= 4){ $("#username").append('<span id="loaderimg" name="loaderimg"><img align="absmiddle" src="loader.gif"/> Checking data availability,&nbsp;please wait.</span>'); var url = "http://mysite.com/site1/toavail/"+usr; $.post( url, function(data) {alert(data);}); }); }); //--> </script> <table border=0 width="100%"> <tr> <td>Username</td> <td> <div id="username"> <input type="text" name="data[User][name]" id="data[User][name]"> </div> </td> </tr> </table> In Firefox 3, the alert box showed empty message. In IE 6 and IE 7, I got an error message saying "Permssion denied"

    Read the article

  • what exactly is this.id ?

    - by kwokwai
    Hi all, I was doing some dynamic effect on DIV using JQuery when I found that the returned value of this.id varied from function to function. I got two sets of simple parent-child DIV tags like this: <DIV ID="row"> <DIV ID="c1"> <Input type="radio" name="testing" id="testing" VALUE="1">testing1 </DIV> </DIV> <DIV ID="row"> <DIV ID="c2"> <Input type="radio" name="testing" id="testing" VALUE="2">testing2 </DIV> </DIV> Code 1. $('#row DIV').mouseover(function(){ radio_btns.each(function() { $('#row DIV).addClass('testing'); // worked }); }); Code 2. $('#row DIV').mouseover(function(){ var childDivID = this.id; radio_btns.each(function() { $('#'+childDivID).parent('DIV').addClass('testing'); // didn't work }); }); I don't understand why only the first code couldn work and highlighted all the "row" DIV, but the first code failed to do so?

    Read the article

  • String pattern matching in Javascript

    - by kwokwai
    Hi all, I am doing some self learning about Patern Matching in Javascript. I got a simple input text field in a HTML web page, and I have done some Javascript to capture the string and check if there are any strange characters other than numbers and characters in the string. But I am not sure if it is correct. Only numbers, characters or a mixture of numbers and characters are allowed. var pattern = /^[a-z]+|[A-Z]+|[0-9]+$/; And I have another question about Pattern Matching in Javascript, what does the percentage symbol mean in Pattern matching. For example: var pattern = '/[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}/';

    Read the article

  • [JQuery] Highlight a Radio field and then pop up an input text box field

    - by kwokwai
    Hi all, I am trying to make some dynamic effect to a HTML page using JQuery. 1. When the user clicks a Radio feild, the field will be highlighted. 2. When the user clicks the Radio 'Man', a Input text box will be provided immeditely just below it. Here is my simple HTML page, but I don't know how to do with the JQuery part: <Table> <TR> <TD>Gender</TD> <TD> Man: <INPUT type=radio name="gender" value="M"><Br/> Woman: <INPUT type=radio name="gender" value="F"> </TD> </TR> <?Table>

    Read the article

  • HTML input text box vs CakePHP Automagic Form Elements

    - by kwokwai
    Hi all, I was manually creating a simple form with one input text box field like this: <form action="/user/add" method="post"> <input type="text" name="data[user_id]" value="1"> But when I call $this->model->save($this->data) in the Controller, nothing was saved to the Table. Only when I used this and the data in the field was written to the database successfully: $form->create(null, array('url' => '/user/add')); echo $form->input('user_id', array('label' => 'User ID', 'value' => '1'));

    Read the article

  • Tables relationship in Cakephp

    - by kwokwai
    Hi all, I am new to Models structure in Cakephp. A few weeks ago I came across a tutorial in which the author got three tables in Database: Table A: {ID, Description, IsActive} Table B: {ID, TableA_ID, Description, CreationDate, ModifiedDate} Table A_B: {ID, TableA_ID, TableB_ID} The author of the tutorial said that the third table (Table A_B) is needed to run in CakePHP. I don't understand. Is there any specific documentation in CakePHP that I can refer to? I know there is a CookBook in Cakephp web site, but I couldn't find the relevant infromation.

    Read the article

1 2  | Next Page >