Welcome Guest, Not a member yet? Register   Sign In
  determine all variables passed into view
Posted by: El Forum - 05-29-2008, 12:28 PM - Replies (7)

[eluser]louis w[/eluser]
when inside of a view is there a way to access the array of variables which was passed in as a whole? i need to call a sub-view and want to pass everything into the next view but don't know all the the variable names (they will change) which were in the array.


  [DB] Problem connecting to database
Posted by: El Forum - 05-29-2008, 12:19 PM - Replies (3)

[eluser]blackdog[/eluser]
Hello everyone, i'm trying to follow the tutorials for learning the basics of CI but i got a problem in connecting to the database.
I searched the forum, found a topic with similar problem but no one seems to have my same configuration, plus it's months old and no one replied the last question, so seemed right to open a new one.

I'm working on a Mac with MAMP as a server and mysql as db.

A friend of mine taught me how to configure a virtual host "to work more professionally".

So i have CI and the wannabe-test-app in:

users/blackdog/[...]/igniter_test/

while the database is under

[...?]/applications/mamp/db/mysql/igniter_test

when i come up to configuring the database.php i simply change the name, but nothing happens. i change the username parameter to:

$db['default']['username'] = "root@localhost";

because in phpmyadmin front page it says: "User: root@localhost", but still i get an error in selecting the db.
I thought that maybe was the "_" causing problems, so i changed the db_name from "igniter_test" to "test", because i had created one in the past.
It conncets to it

BUT

if i change the name of the original db "igniter_test" to "igniter" or "igniterTest", i still get an error, so i don't think it's the underscore.

I think it's something with the paths or romething like that, caused by the fact that CI libraries are in the virtual host folder and the db under the localhost.
In fact if i try to work with the "test" db already exsiting, i manage to connect to the table with the scaffolding

BUT

when i try using to add a record with it, i get an error

Not Found
The requested URL //spublic/index.php/blog/database/add was not found on this server.
Apache/2.0.59 (Unix) PHP/5.2.3 DAV/2 Server at igniter_test Port 80


Someone has an idea of what i have to fix?


  uploading and preview image with ajax
Posted by: El Forum - 05-29-2008, 10:02 AM - Replies (3)

[eluser]nuttynibbles[/eluser]
hello, im doing a function to upload photo. i would like to use ajax for user to preview the photo before submitting the form. so basically i want the user to click onto preview button where it will use ajax to preview the img to the user by saving the img file in a temp folder.

here is my code for the html:

Code:
<form name="frmregister" method="post" action="http://url/codeigniter/upload/do_upload" enctype="multipart/form-data">
<input type="hidden" name="post" value="1" />        
Upload a photo: <input type="file" name="file" id="file" /><input type="submit"  name="preview" value="preview">
<input class="button" type="submit" name="upload" value="upload" />
</form>

i found a ajax file on CI forum. it looks like this:
Code:
var ajaxPost = function() {
    
    // Get request object
    function getRequest() {
        if (window.XMLHttpRequest)
            return new XMLHttpRequest();
        else if (window.ActiveXObject)
            return new ActiveXObject("Microsoft.XMLHTTP");
        else
            alert('Ajax not supported');
        return null;
    }

    // Basic callback - could add error handler if you wanted
    function handleChange(req, callback) {
        if(req.readyState == 4) {
            if (req.status == 200) {
                if (callback)
                    callback(req.responseText);
            }
            else {
                alert("Ajax request failed.");
            }
        }
    }

    // Create query string from json object
    function handleParams(params) {
        if(!params) {
            return null;
        }
        else {
            var encoded = "";
            for (var field in params) {
                fieldval = params[field];
                encoded += field + '=' + fieldval + '&';
            }
            return encoded;
        }
    }

    // Combine it all in one pretty interface
    return function(uri, callback, data) {
        var request = getRequest();
        request.open('POST', uri, true);
        request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
        request.onreadystatechange = function() { handleChange(request, callback) };
        request.send(handleParams(data));
        return request;
    };
}();

can someone show me how to go about doing this. tks


  turn off global xss on login page
Posted by: El Forum - 05-29-2008, 09:31 AM - Replies (4)

[eluser]Unknown[/eluser]
Okay, so this is what the problem is... I have global xss turned on so it sanitizes _post and what not.

However, I have a lot of users who use special characters in their password for security requirements so CI is converting them and making the password invalid.

How can I leave the global xss on but not sanitize the login page _post vars with its xss_clean function?

I thinking I need to do some kind of hook to turn it off specifically for that controller but just wanted to see what you guys thought.

Thanks


  Solved
Posted by: El Forum - 05-29-2008, 06:35 AM - Replies (2)

[eluser]JasonS[/eluser]
Solved


  help with a custom field_data()
Posted by: El Forum - 05-29-2008, 05:05 AM - Replies (4)

[eluser]dexter21[/eluser]
hi , iam trying to get all fields names and values from a table . i've made a custom query that return an array of elements.if i print $campo->valor, and $campo->nombre i obtain the results but if i call to function in a view it said that campo->nombre and campo->valor dont exisxt;

basicly i use following function as:

Code:
$sql = "select * from news";
$sql  .= " where nCodnoticia = 1";
registro=$this->db->query2($sql,$this->tabla);



$registro->campos[0]->type ->ok it print it
$registro->campos[0]->valor ->it give me an error, dont exist


any could help me plz ?


following function:

Code:
function query2($sql,$tabla)
    {

        $query = $this->query($sql);


        if ($query->num_rows() > 0)
        {
            $objeto = null;
            $objeto->campos = $query->field_data();

            $valores = $query->row();
            
            foreach($objeto->campos as $campo)
            {    
            
               echo $campo->name."<br>";
               echo $campo->type."<br>";
               echo $campo->max_length."<br>";
               echo $campo->primary_key."<br>";
                              

                foreach($valores as $nombre=>$valor)
                {
                    if($nombre == $campo->name)
                    {    
                    
                           $campo->valor = $valor;
                           $campo->nombre = $this->traduceCampo($tabla,$campo->name);


                            echo "campo->valor:".$campo->valor."<br>";
                            echo "campo->nombre:".$campo->nombre."<br>";
                                                
                           break;  
                     }
                 }
                
           }
        }
        else
        {
            $objeto = null;
            $objeto->campos = $query->field_data();
            foreach($objeto->campos as $campo)
            {
                   $campo->valor = null;
                   $campo->nombre = $campo->name;
            }
        }
        //echo var_dump($objeto);      
       return $objeto;
    }


  Multiple Databases Best Practice
Posted by: El Forum - 05-29-2008, 04:55 AM - Replies (4)

[eluser]matthewr[/eluser]
Hi! What's the best practice for connecting to multiple databases and using Active Record to access them both. I'll have 1 primary database that my app will access a lot, and one secondary database that my app will check out probably only during logins. I need two databases because the second database will be accessed by multiple apps. Could someone show me the best practice for doing this? I just want to do it right.

Thanks
Matthew


  2 or 3 fields of search
Posted by: El Forum - 05-29-2008, 04:16 AM - Replies (1)

[eluser]JUANITO26[/eluser]
Very Very Very good and impressive widget !
It is possible to activate 2 or 3 fields of search? (Quick Search)
Example ISO+NAME+NUMBER CODE.
If it is not much to ask, the form to do it
Thanks!


  .htaccess problem
Posted by: El Forum - 05-29-2008, 04:08 AM - Replies (5)

[eluser]Mitja[/eluser]

Code:
RewriteEngine on
RewriteRule ^$ /index.php [L]
RewriteCond $1 !^(index\.php|img|css|js|video_files|robots\.txt|favicon\.ico)
RewriteRule ^(.*)$ /index.php/$1 [L]

i still need to write index.php in url adress. It is not recognized automatically. Anyone know why?


  XML-RPC Empty Return Structs
Posted by: El Forum - 05-29-2008, 04:07 AM - No Replies

[eluser]Elliot Haughin[/eluser]
Under 1.6.2, when using the XML-RPC Client library, an error occurs when handling 'empty' struct's.

libraries/Xmlrpc.php Line 1326:

Code:
switch($this->xmlrpcTypes[$typ])
{

    case 3:

        // struct

        $rs .= "<struct>\n";

        reset($val);

        while(list($key2, $val2) = each($val))

        {

            $rs .= "<member>\n<name>{$key2}</name>\n";

            $rs .= $this->serializeval($val2);

            $rs .= "</member>\n";

        }

        $rs .= '</struct>';

    break;

Produces:

Quote:A PHP Error was encountered

Severity: Warning

Message: reset() [function.reset]: Passed variable is not an array or object

Filename: libraries/Xmlrpc.php

Line Number: 1331
A PHP Error was encountered

Severity: Warning

Message: Variable passed to each() is not an array or object

Filename: libraries/Xmlrpc.php

Line Number: 1332


The library doesn't take into account that the struct could be empty...
should be:

Code:
switch($this->xmlrpcTypes[$typ])
{

    case 3:

        // struct

        $rs .= "<struct>\n";
        
        if ( !empty($val) )
        {

            reset($val);

            while(list($key2, $val2) = each($val))

            {

                $rs .= "<member>\n<name>{$key2}</name>\n";

                $rs .= $this->serializeval($val2);

                $rs .= "</member>\n";

            }
        }

        $rs .= '</struct>';

    break;

Maybe this isn't a bug... but just thought you might want to check it out.


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

Username
  

Password
  





Latest Threads
Filters in filters folder...
by xsPurX
52 minutes ago
Integrating Bootstrap 5 i...
by captain-sensible
6 hours ago
request URL not found
by captain-sensible
6 hours ago
Top 10 PHP Testing Framew...
by php_rocs
7 hours ago
As experienced web develo...
by luckmoshy
11 hours ago
CL4 Connecting to a Remot...
by cx3700
Yesterday, 10:48 PM
Multiple App with .env
by kenjis
Yesterday, 06:53 PM
Multiple filters set on a...
by kenjis
Yesterday, 06:50 PM
error update form 4.3.7 t...
by codeus
Yesterday, 01:16 PM
Basic Algorithms
by InsiteFX
Yesterday, 01:56 AM

Forum Statistics
» Members: 85,977
» Latest member: kubet88money1
» Forum threads: 77,599
» Forum posts: 376,102

Full Statistics

Search Forums

(Advanced Search)


Theme © iAndrew 2016 - Forum software by © MyBB