Part of the EllisLab Network
   
 
Silly Problem passing variables between controllers
Posted: 17 October 2006 11:34 AM   [ Ignore ]  
Summer Student
Total Posts:  3
Joined  10-17-2006

Hello,

I have a weird problem probably due to the fact that I am new to CI.
I have an application with a user menu that conists of a list of menu. When you click on the user name, it is supposed to call a controller passing the user ID ($u_id) as a variable as indicated below :

           

$array=$array . "<a href=user_details?u_id=".$row->user_id.">" . $row->user_fname . "</a><BR>";

which results in a link like :

http://localhost/11/index.php/user_details?u_id=1

The controller has the line to retrieve the variable :

$u_id=intval($_GET['u_id']);

or

$u_id=$_GET['u_id'];

However I always get the error :

A PHP Error was encountered
Severity: Notice

Message: Undefined index: u_id

Filename: controllers/user_details.php

Line Number: 9

followed by :

Fatal error: Call to a member function on a non-object in f:\easyphp1-8\www\11\system\application\controllers\user_details.php on line 13

Which is logical the variable being the criteria for my next query.

If I enter

$u_id=1;

the query works.

Can anyone help please ?

Profile
 
 
Posted: 17 October 2006 01:11 PM   [ Ignore ]   [ # 1 ]  
Grad Student
Avatar
Rank
Total Posts:  41
Joined  12-21-2005

GET data isn’t allowed by Code Igniter because it uses URL segments, unless you’ve enabled query strings in the config file.

http://www.codeigniter.com/user_guide/general/security.html

 Signature 

David Hemphill - freelancer // blog

Profile
 
 
Posted: 17 October 2006 02:30 PM   [ Ignore ]   [ # 2 ]  
Research Assistant
RankRankRank
Total Posts:  970
Joined  04-13-2006

Check the User Guide on the URI Class, specifically segmented urls ($this->uri->segment(n) ).

Profile
 
 
Posted: 18 October 2006 03:19 AM   [ Ignore ]   [ # 3 ]  
Summer Student
Total Posts:  3
Joined  10-17-2006

Thanks for the information David.

I appreciate the pointer Martin.
Cheers.

Profile
 
 
Posted: 18 October 2006 04:30 AM   [ Ignore ]   [ # 4 ]  
Summer Student
Total Posts:  3
Joined  10-17-2006

Thanks David and Martin.
I have indeed solved this problem.

Ignorance of the Law is no excuse

as the saying goes but it sure as heck changes your coding habits.

I just love it and it is far cleaner.

Profile
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 819, on March 11, 2010 11:15 AM
Total Registered Members: 120466 Total Logged-in Users: 33
Total Topics: 126545 Total Anonymous Users: 3
Total Replies: 665388 Total Guests: 301
Total Posts: 791933    
Members ( View Memberlist )
Newest Members:  DistrikerGerd Pansenneilgroomart.maniaakoloans5kmotion1jelevinlizandermagnosismx2428