Welcome Guest, Not a member yet? Register   Sign In
  TOTAL NEWBIE PLEASE HELP
Posted by: El Forum - 10-06-2008, 12:24 PM - Replies (4)

[eluser]sHoyRu777[/eluser]
hello.. i am really a noob in CI and i am practicing CI by making a shopping cart system or what do you call that.. (dont mind my english)... i want to make my cart session, i have already done that with native php coding(heres my code) :

<?
if(isset($_GET['product_id'])){
$_SESSION['product'][$_GET['product_id']]++;
}
?>
<?
if(isset($_POST['btn'])){
switch($_POST['btn']){
case "Update" :
foreach($_POST['hidden_lodge'] as $Key => $Index){
$_SESSION['product'][$Index] = $_POST['txt_qty'][$Key];
}
break;
case "Remove" :
foreach($_POST['chk_remove'] as $index){
unset($_SESSION['product'][$index]);
}
break;
case "Continue Shopping" :
echo "[removed][removed]='products.php'[removed]";
break;
}
}
?>

and i am really2x confused on how will i convert that into CI code.. im really confuse on CI's Sessions ... Please help... ^_^


  Avoid including header in each template file (Smarty)
Posted by: El Forum - 10-06-2008, 12:23 PM - No Replies

[eluser]blaff[/eluser]
Hello,

I have included Smarty in my CodeIgniter framework. Now when I display a template i have to include headers all the time.

Example on main.tpl:

Code:
<html>
   <head>
   </head>

   <body>
      {$content}
   </body>
</html>

Instead I want to include one base.html with all html, head and body tags. Then the other templates will be included in the variable $content.

Anyone who have a good solution for this?

Best regards,
Mikael


  Flashdata is messing up numbers
Posted by: El Forum - 10-06-2008, 11:45 AM - Replies (2)

[eluser][email protected][/eluser]
Hello,

I am storing a decimal number in the flash_data (ie. $42.99) and the serialize function inside the set_flash_data() is appending too many decimals. Later, when I retrieve the value there are issues with comparing the values. Has anyone come across this problem?

Code:
<?php
$val = 42.99;
var_dump($val);  // initial value: float(0.333333333333)
echo '<br/><br/>';
$val = serialize($val);
var_dump($val);  // standart float format: string(55) "d:0.333333333333333303727386009995825588703155517578125;"
echo '<br/><br/>';
$val = preg_replace('/d:([0-9]+(\.[0-9]+)?([Ee][+-]?[0-9]+)?);/e', "'d:'.((float)$1).';'", $val);
var_dump($val);  // compact float format: string(10) "d:0.333333333333;"
echo '<br/><br/>';
$val = unserialize($val);
var_dump($val);  // unserialization successed: float(0.333333333333)
echo '<br/><br/>';
$val = serialize($val);
var_dump($val);  // but value is rounded off!: string(55) "d:0.3333333333330000147753935380023904144763946533203125;"
echo '<br/><br/>';
?&gt;


  encoding problam with ajax
Posted by: El Forum - 10-06-2008, 10:42 AM - Replies (2)

[eluser]A.M.F[/eluser]
hello everyone

i a working on a comment form and i am sending the form with ajax (jQuery) and i am using the plugin ajaxForm.

so i have this ajax code:

Code:
[removed]
   $(document).ready(function() {

      &lt;!-- sending the comment form --&gt;
      $('#commentSend').ajaxForm(function(data) {
         alert(data); //here i am just validating that it sends
      });

   });
[removed]

i am using a simple HTML form, and in my controller i am just checking the fields and save them.
everything works fine expets when i am not writing the comment in english.
when i write it in other characters it encodes it to different thing, and in the DB it looks like that:
Quote:סכע

i added this:
Code:
header('Content-Type: text/html; charset=windows-1255');
to my controller but it still doesn't help.

can anyone help me?


  Please help on JOIN problem
Posted by: El Forum - 10-06-2008, 09:56 AM - Replies (3)

[eluser]Gewa[/eluser]
Here i have a code that helps to take companies, and attach the city table

Code:
$this->db->select('*');
                 $this->db->from('fa_user_profile');
                 $this->db->where('type','company');
                 $this->db->join('city','fa_user_profile.city_id=city.id');
                 $this->db->join('fa_user','fa_user_profile.id=fa_user.id');


                 $query=$this->db->get();


The problem is that when lets say in the fa_user_profile table there is a row, that contains lets say city_id=4 and in city table there is no such city with ID 4, then this row is not shown in listing. How to organize the JOIN, that in such case it is joining city field to the result row with "0" result or anything else... ??????


  How to handle SQL Injection
Posted by: El Forum - 10-06-2008, 09:48 AM - Replies (6)

[eluser]Unknown[/eluser]
How to handle SQL injection in CodeIgniter? Many thanks.


  Time-Saving Function (Forms/Validation)
Posted by: El Forum - 10-06-2008, 09:28 AM - Replies (2)

[eluser]fancms[/eluser]
If you're like me, when creating a controller with add/edit functions you constantly find yourself coding something like

Code:
if($this->validation->run() == FALSE {
   $data["variable"] = $something;
   $this->load->view("add",$data);
} else {
  $add = $this->model_name->model_function($this->validation->variable,$something);
  //Display success message here
}

I'm impatient and loathe coding nearly identical lines over and over. So I created a function that helps me reduce the above to this:

Code:
$this->forms->validation_run("add",array("variable"=>$something),"model_name","model_function",array($this->validation->variable,$something));

The code can be found here: http://momgeek.wordpress.com/2008/10/06/...deigniter/
(edit: moved to my blog for easier tweaking to the code)


  What do I not understand about flashdata? specifically keep_flashdata
Posted by: El Forum - 10-06-2008, 09:23 AM - No Replies

[eluser]skattabrain[/eluser]
I thought I understood how flashdata works perfectly but this morning i"m stumped ... maybe I need more coffee.

So the gist of this is...

1 - customer places order
2 - process order and set flashdata for the thank you page
3 - user redirected to thank you page

and ...

4 - if user hit's 'refresh' i can still serve the thank you page
5 - otherwise, i load a different view and verify they are logged in and have access to view the order.

4 & 5 no workie.

so the first view works great, but after that it keeps loading the myaccount/order_view view.

so ... the order process function (minus all the work) ...

Code:
function process()
{
   // blah blah blah
   $this->session->set_flashdata('just_placed_order', 'yes');            
   redirect('order/view/'.$order_id.'/'.$order_hash);
}

and then the view function ...
Code:
function view($order_id='', $order_hash='')
{
   // do stuff

if($this->session->flashdata('just_placed_order'))
{
$this->session->keep_flashdata('just_placed_order');
$this->load->view('thank_you_order', $d);
}
else
{
$this->load->view('myaccount/order_view', $d);
}
}


  Is CI2 Going To Be PHP5 Only?
Posted by: El Forum - 10-06-2008, 09:18 AM - Replies (2)

[eluser]WoOzY KinG[/eluser]
Since PHP4 is officially dead, are we going to see CI2 made in PHP5 only?


  new Jquery pagination with CI?
Posted by: El Forum - 10-06-2008, 08:58 AM - Replies (11)

[eluser]A.M.F[/eluser]
hello everyone

i want to use ajax pagination with CI, and i saw those files in here:
http://tohin.wordpress.com/2008/08/12/co...agination/

i tried to work with it, but i didn't get any result.
does anyone can help me how to use those files, or give me maybe an idea of how to make this jQuery pagination?

thank u!


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

Username
  

Password
  





Latest Threads
Codeigniter4 version 4.5....
by kenjis
6 hours ago
SQL server connection not...
by kenjis
6 hours ago
Problem with session hand...
by kenjis
6 hours ago
Is it possible to go back...
by kenjis
7 hours ago
Cannot access protected p...
by xsPurX
8 hours ago
Update to v4.5.1, same us...
by xsPurX
Today, 08:31 AM
How to use Codeigniter wi...
by kenjis
Today, 05:06 AM
CVE-2022-40834 SQL Inject...
by kenjis
Today, 03:44 AM
Retaining search variable...
by pchriley
Today, 03:15 AM
Disable debug output in v...
by groovebird
Today, 02:26 AM

Forum Statistics
» Members: 85,394
» Latest member: bangaloreescorts01
» Forum threads: 77,581
» Forum posts: 376,007

Full Statistics

Search Forums

(Advanced Search)


Theme © iAndrew 2016 - Forum software by © MyBB