| CARVIEW |
Anyway encounter this? All have to mention that I tried the solutions and callbacks are still not working…
Update:
Sorted my problem out..
I am using the following to remove my index.php -
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
I am replacing an old site with my new one written with codeigniter, because of this I need to rewrite some old urls to new ones. This is working fine for single pages, however I am running into a problem with the following rewrite -
RedirectMatch 301 ^/comments/(.*)/$ /location/$1
This should in theory redirect you from:
https://www.mysite.com/comments/123 to https://www.mysite.com/location/123
Because I’m removing index.php through a rewrite I am ending up being directed to - https://www.mysite.com/location/123?/comments/123/
Does anyone know how to fix this?
Thanks.
]]>Sessions are saved in database.
In controller I set_userdata(data[‘test’]) and print out the session data to screen.Everything is ok, but! After i redirect to view, and print session data again, inserted data does not show up anymore. Why? ]]>
I am implementing an application where I have to test if a field is empty or not. That field is defined within PhpMySQL as follows :
Field name : DIVERS
Type : varchar(80)
Interclassement : latin1_swedish_ci
Null : No (non)
Defaut : None (aucun)
There are cases where nothing has been put into the field. Nevertheless whenever I test that field in the controller using an instruction such as
if (empty($DIVERS))
{
echo "DIVERS empty<br />";
}else{
echo "DIVERS not empty<br />";
}
the Else part of the if condition is always executed.
The same occurs if I use is_null
Could someone give me a clue ? Thanks in advance.
CapErquy
I was wondering if anybody could point me in the right direction to update Multiple rows in Codigniter. Just a link or explanation of what to do?
View >>>
<? echo form_open("".current_url().""); ?>
<table>
<thead>
<th>ID</th>
<th>First Name</th>
<th>Surname</th>
</thead>
<?php foreach ($query->result() as $row){ ?>
<tr>
<td><? echo $row->ID; ?><? echo form_hidden('ID[]',$row->ID); ?></td>
<td><? echo form_input('FirstName[]',$row->FirstName); ?></td>
<td><? echo form_input('Surname[]',$row->Surname); ?></td>
</tr>
<? } ?>
</table>
<? echo form_submit('Update', 'Edit'); ?>
<? echo form_close() ?>
Bit stuck on what to do next. Got the post array but it doesn’t make any sense (keys etc). Any help would be kindly appreciated.
Controller >>
function Update() {
print_r($_POST);
}
Thanks a million!
]]>If you dump the returned array, each element is still a SimpleXMLElement object, meaning that you can’t access the object after passing it into CI sessions, for example. So I simply casted each object accessor as a string:
...
'country_code'=>(string)$result->CountryCode,
'country_name'=>(string)$result->CountryName,
'region_name'=>(string)$result->RegionName,
'city'=>(string)$result->City,
...
This makes it match, in terms of returning an associative array and having that array behave like one would expect an associative array to behave.
Is there a better way to do this?
]]>I have a working pagination, but I want to modify the segment handling like:
controller/category/34/page=5
So I want not only uri segment(4) as a number, but I want to put some text before.
Thank you.
]]>I’m writing a bilingual site in CI version 2. Following the instructions in the user guide I’ve created language files at application/language/english/english_lang.php and application/language/welsh/welsh_lang.php. In autoload.php I’ve added ‘english’ and ‘welsh’ to the $autoload[‘language’] array:
$autoload['language'] = array('english', 'welsh');
What I want to do in my application is to test for the language the user wants and then load the correct strings for things like titles, so in english_lang.php I have, for example:
$lang['en_title_home'] = "Wales Legislation Online: Home";
And in welsh_lang.php I have:
$lang['cy_title_home'] = "Deddfwriaeth Cymru Arlein: Hafan";
The language the user wants is passed into every controller function as a parameter, for example:
function index($language = 'en') { ... }
So I’m hoping that in each function I can do something like:
if($language == 'en')
$data['title'] = $this->lang->line('en_title_home');
else
$data['title'] = $this->lang->line('cy_title_home');
However, when I try to run the application it fails with the following error:
Unable to load the requested language file: language/english/welsh_lang.php
From what I can tell, it’s the autoloading that’s failing, although I could be mistaken. Obviously I’m misunderstanding the user guide so if anyone could take the time to put me straight, I’d be very grateful.
Thanks in advance,
Peredur
I want to use the Rest Library from Phil Sturgeon. I put the code in my application folder, but if I run it I get this error:
Fatal error: Class ‘REST_Controller’ not found in /Applications/XAMPP/xamppfiles/htdocs/tricell/application/controllers/example.php on line 20
The system directory is one level up and the index.php is changed. What to do?
Best regards ...
]]>i have an add user form in which a user will add an account. the account will be added in two database tables user and section (the db table below).
table name: course pk(sec_code)
table name: section pfk(user_id)
fk(sec_code)
table name: user pk(user_id)the sec_code column of table course must have values which will be shown in the dropdown list that’ll be selected and inserted to the user_sec column of section table and as well as the user_id of table user upon creating an account.
my problem is, nothing is inserted in my database.
this is my model:
function get_sections_dropdown()
{
$this->db->from('course');
$this->db->order_by('sec_code');
$result = $this->db->get();
$return = array();
if($result->num_rows() > 0){
$return[''] = 'Please select';
foreach($result->result_array() as $row){
$return[$row['sec_code']] = $row['sec_code'];
}
}
return $return;
}
function AddUser($userId, $userName, $userPassword, $userType)
{
$md5_userPassword = md5($userPassword);
$data = array(
'user_id' => $userId,
'uname' => $userName,
'pwd' => md5($userPassword),
'user_type' => $userType
);
$this->db->insert('user', $data);
}
function AddUserSection($userId, $userCode)
{
$query = "INSERT INTO user_section (user_id, sec_code) VALUES (?, ?)";
$this->db->query($query, array($userId, $userCode));
}