Welcome Guest, Not a member yet? Register   Sign In
  有中国人吗?
Posted by: El Forum - 09-02-2008, 01:23 AM - Replies (1)

[eluser]Unknown[/eluser]
RT


  Exiting Controller
Posted by: El Forum - 09-02-2008, 12:56 AM - Replies (3)

[eluser]spider pig[/eluser]
I have created a form and my controller script validates it and builds an error message in the variable $errorMessage. I then test if $errorMessage is not NULL, I display the form again with an error box. I then want to exit the script:

Code:
// header displayed earlier in code
if ($errorMessage != NULL) {
    $row->al_error_message = $this->error->error_box($errorMessage);
    $this->load->view('newsletter_form', $row);
    $this->load->view('footer', $settings);
    exit;
}

However, nothing displays. Is there a way to output what is already passed to output before I exit?

Thanks


  Difference between putting a library inside /libraries and /application/libraries
Posted by: El Forum - 09-01-2008, 11:57 PM - Replies (2)

[eluser]geshan[/eluser]
What is the difference between putting a library in /libraries and /application/libraries? Which is better? Why and how?


  __construct
Posted by: El Forum - 09-01-2008, 06:36 PM - Replies (2)

[eluser]jbads[/eluser]
Do I have this right?

If I put a function call to check authentication in the construct of my class, then I do not need to include that same check on the individual functions / controllers within that class? That authentication check will run before any controllers are accessed?

Sorry for the dipshit question. Just wanna make sure my bases are covered.


  problems with ajax
Posted by: El Forum - 09-01-2008, 04:59 PM - Replies (10)

[eluser]dumbo[/eluser]
Hi, I'm new to CI as well as javascripts & AJAX. I have a noobie question about how to pass in a variable from the view's javascript and how to access it in the controller.

View's [removed]

Code:
var httpObj;
function checkName(username)
{
  httpObj = GetHttpObject();
  if(httpObj == null)
      {
          alert ("Browser does not support HTTP Request");
          return;
      }
  var url = <?php echo base_url().'index.php/addaccount/username_check';?>;
  url=url+"?q=" + username;
  url=url+"&sid;="+Math.random();
  httpObj.onreadystatechange=callback_account;
  httpObj.open("GET",url,true);
  httpObj.send(null);
}

function callback_account()
{
if (httpObj.readyState==4 || httpObj.readyState=="complete")
{
   alert(httpObj.responseText);
}
}


function GetHttpObject()
{
    var xmlHttp=null;
    try
     {
     // Firefox, Opera 8.0+, Safari
     xmlHttp=new XMLHttpRequest();
     }
    catch (e)
     {
     // Internet Explorer
     try
      {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
     catch (e)
      {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
     }
return xmlHttp;
}
[removed]
Controller's function:
Code:
function username_check()
   {
      echo($this->input->get('q'));
   }

So my question is can I actually pass in
Code:
"?q=" + username;
if I didn't activate query string in my config? If I can't, is there a way around this without using query strings?

My second question is how do I access that variable in controller after it's pass in?
Right now my username_check function returns blank.

Please let me know if there is anything unclear. Thanks.


  Bypassing uri-specified controller method?
Posted by: El Forum - 09-01-2008, 04:15 PM - Replies (1)

[eluser]Unknown[/eluser]
New to CI, just a quick question...
I handle user authentication in the constructor of the controller. If authentication fails, it should display the login form and not run the requested method. Without using _remap(), how can i prevent the requested method from being called automatically (from within the constructor).

Hopefully I was clear enough. Thanks


  Post cache issues
Posted by: El Forum - 09-01-2008, 03:19 PM - No Replies

[eluser]gRoberts[/eluser]
Hi all,

When I post data to the same page, it displays the previous values until you refresh the browser (by manually going to the same url instead of refreshing.)

The data I am displaying is being pulled from a memcache store which after successfully updating the database, I reload the memcache store with the new data.

Directly after the update of the database/cache, I can print_r both the posted value and the memcache value which both return the same results. Yet when I echo the memcache value from the view it still shows the old result (even when i'm print_r'ing the exact same data in teh php code.)

I don't have any caching enabled as far as PHP/CI. I've checked the cache folder and the only file in there is the index.htm file.

Has anyone ever experienced this before? I'd go into more detail regarding my code but unless specifically asked, i'll not bother due to how complex the setup is.

Cheers

Gav


  Do something on every page
Posted by: El Forum - 09-01-2008, 03:17 PM - Replies (2)

[eluser]FinalFrag[/eluser]
Hi there guys,

I'm working on this website and I have a problem.
I have a header.php file, which contains some code that has to be included on every page. This header.php also draws a menu on the screen.

At the moment, I have this in my controller

Code:
...
$data['menu'] = '<a href="#">home</a> | <a href="#">about</a>';
$this->load->view('home', $data);
...

In home.php I then include the header file which uses the $menu variable to draw the menu items.

The problem is that I have to define this $data['menu'] variable in ALL my controller (cause I need the menu on every page). Is there an easier way do this?

Cause in real life it's not as easy as $data['menu'] = ...
In real life, the data needs to be fetched from a database.

Is there any way for me to have the $data['menu'] variable in EVERY controller without me having to declare it all the time? (some kind of hook maybe?)

Thnx in advance...


  Having a problem with $this->load->view();
Posted by: El Forum - 09-01-2008, 02:09 PM - Replies (4)

[eluser]ConnorD[/eluser]
Hi,

I am fairly experienced in PHP, but brand new to CI, so please bare with me. I have been having no trouble until I tried to load a view from my controller:

Code:
&lt;?php
class Home extends Controller{
    function index(){
        parent::Controller();
    }
    function Home(){
        $data['title'] = "Livefootballtalk - Home";
        $data['intro'] = "Livefootballtalk is a soccer/football fan community where fans from all different countries and clubs can meet and discuss about world football competitions and players. Also, the fans may interact through their profile pages and messager. We invite you to be a real fan and <a href='register.php?step=1'>join</a> the community!";    
        
        
        $this->load->view('home', $data);
    }
}
?&gt;

I am getting an error message on my codeigniter page from my browser saying: "A PHP Error was encountered

Severity: Notice

Message: Undefined property: Home::$load

Filename: controllers/home.php

Line Number: 11".

I don't understand it, because I have done everything with the tutorials. Any help would be appreciated, thank you.

BTW, here is my view if it is of interest:

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
&lt;html &gt;
&lt;head&gt;
&lt;title&gt;&lt;?php echo $title; ?&gt;&lt;/title&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /&gt;
&lt;link rel="stylesheet" href="css/1.css" type="text/css" media="screen,projection" /&gt;
&lt;/head&gt;
&lt;body&gt;

        <div id="top">
        
        </div>
        
        <div id="container">
        
                <div id="menu">
                
                        <ul id="nav">

                        &lt;?php
                        
                        ?&gt;
                        
                        </ul>
                        
                        <br class="clear" />
                
                </div>
                
                
                
                <div id="sidebar">
                
                        <h1 class="first">
                        
                            Home
                        
                        </h1>
                        
                        <p>
                        
                        
                        </p>
                        
                        <h1>My Account</h1>
                        
                        <ul class="linkroll">
                        
                            &lt;?php
                            
                            ?&gt;

                            
                        </ul>
                        
                    
                
                </div>
                
                <div id="content">
                &lt;?php
                
                ?&gt;
                <br />
                
                        <h1>Welcome to Livefootballtalk!</h1>
                        <br />
                        <img src="../images/soccer_fans.jpg" width="380" height="280" /><br />
                        
                        <p>
                        &lt;?php
                        echo $intro;
                        ?&gt;
                        </p>
                        <br /><br />
                        &lt;object width="425" height="344"&gt;&lt;param name="movie" value="http://www.youtube.com/v/dIlcc7Vks-8&hl=en&fs=1"></param><param name="allowFullScreen" value="true"></param>&lt;embed src="http://www.youtube.com/v/dIlcc7Vks-8&hl=en&fs=1" type="application/x-shockwave-flash" allowfullscreen="true" width="425" height="344"&gt;&lt;/embed>&lt;/object&gt;    
                        </p>
                        <br />
                        &lt;?php
                        echo "<br><font color='black'>Latest Discussions:</font><br>";
                        foreach($threads_query->result() as $row){
                            echo "<table border='0'><tr><td>Subject: <br><br><a >subject'>$row->subject</a></td></tr><td><td>By: <a >username'>$row->username</a></td></tr></table></table><hr>";
                        }
                        ?&gt;
                </div>

                <div id="footer">
                    
                    <p>Copyright 2008 Livefootballtalk.com | <a href="mailto:[email protected]">[email protected]</a></p>        
        
                </div>
        
        </div>


&lt;/body&gt;
&lt;/html&gt;


  Can I send my attributes to the model __construct
Posted by: El Forum - 09-01-2008, 02:01 PM - Replies (1)

[eluser]fuksito[/eluser]
Can I get several instanses of one model class, how it is possible to pass different data to it`s constructor.


Welcome, Guest
You have to register before you can post on our site.

Username
  

Password
  





Latest Threads
Bug with sessions CI 4.5....
by ALTITUDE_DEV
16 minutes ago
Validation | trim causes ...
by kenjis
2 hours ago
Integrating Bootstrap 5 i...
by Bosborne
3 hours ago
Error / Shield 1.0.3 + Ci...
by kenjis
4 hours ago
Asset Minification Packag...
by tarcisiodev1
Yesterday, 05:11 PM
Modify users data as an a...
by luckmoshy
Yesterday, 04:56 PM
Is it possible to go back...
by ejimenezo
Yesterday, 11:49 AM
SQL server connection not...
by davis.lasis
Yesterday, 07:11 AM
Problem with session hand...
by Julesb
Yesterday, 04:13 AM
External script access to...
by PomaryLinea
Yesterday, 03:58 AM

Forum Statistics
» Members: 85,546
» Latest member: kubet77games1
» Forum threads: 77,586
» Forum posts: 376,030

Full Statistics

Search Forums

(Advanced Search)


Theme © iAndrew 2016 - Forum software by © MyBB