Jump to content

Mace

Members
  • Posts

    36
  • Joined

  • Last visited

  • Days Won

    3

Posts posted by Mace

  1. The page you want to fetch is a page that fetches data with ajax. 

    The simplehtmldom class isn't compatible with that.

     

    The requested url = http://www.ebay.com/cln#{"category":{"id":1,"text":"Collectibles"}}

    However, only javascript can read the part after the #.

    So that's why your request returns only http://www.ebay.com/cln#.

     

    So the only thing I tell you is that this won't work what you're trying to achieve.

    Maybe there is an RSS feed? of maybe there is way to browse without a # in your browser?

  2. I wrote you an example to give you an idea how to work with a php class.

    class MyClass {
        
        protected $arg;
        
        // this function will be called if you create the class
        public function __construct($creationArg) {
            // using "$this" will refer to the class itself
            // the protected $arg defined at the start is avaible with $this
            $this->arg = $creationArg;
        }
        
        public function MyFunctionInClass() {
            // the $this is still avaible here.
            return $this->arg;
        }
    }
    
    $myClass = new MyClass('Hello world');
    echo $myClass->MyFunctionInClass();
    exit;
  3. Try this. Just check if the query failed. If not, then redirect.

    Also, dont put your $_POST values unprotected in your INSERT query. Use something like mysql_real_escape_string() on all your $_POST values

    <?php
    
    include_once '../includes/db_connect.php';
    include_once '../includes/functions.php';
    sec_session_start();
    if (login_check($mysqli) == true)
    {
        $logged = 'in';
    }
    
    $error_msg = "";
    $username = $_SESSION['username'];
    $email = $_SESSION['email'];
    $id = $_SESSION['user_id'];
    
    // create string of queries separated by ;
        //var_dump(login_check($mysqli));
        //var_dump($_SESSION); exit;
        //var_dump($_POST);exit;
    
    
    $query  =      "UPDATE
                            members
                SET
                            level = '$_POST[level]'
                WHERE
                            id = $id;";
    $query .=     "INSERT INTO
                            members_info
                (
                            id
                ,             fname
                ,             known_as
                ,             lname
                ,            gender
                ,             race
                ,            start_date
                ,             department
                ,             msisdn
                ,             dob
                ,             details
                ,             emergency_contact
                ,             emergency_msisdn
                )
                VALUES
                (
                            '".mysql_real_escape_string($_POST['user_id'])."'
                ,             '".mysql_real_escape_string($_POST['fname'])."'
                ,             '".mysql_real_escape_string($_POST['known_as'])."'
                ,             '$_POST[lname]'
                ,             '$_POST[gender]'
                ,             '$_POST[race]'
                ,            '$_POST[start_date]'
                ,             '$_POST[department]'
                ,             '$_POST[msisdn]'
                ,             '$_POST[dob]'
                ,             '$_POST[details]'
                ,             '$_POST[emergency_contact]'
                ,             '$_POST[emergency_msisdn]'
                );";
    
    // execute query - $result is false if the first query failed
    $result = mysqli_multi_query($mysqli, $query);
    $failed = false;
    
    if ($result) {
        do {
            // grab the result of the next query
            if (($result = mysqli_store_result($mysqli)) === false && mysqli_error($mysqli) != '') {
                echo "Query failed: " . mysqli_error($mysqli);
                $failed = true;
            }
        } while (mysqli_more_results($mysqli) && mysqli_next_result($mysqli)); // while there are more results
    }
    
    else {
        echo "First query failed..." . mysqli_error($mysqli);
        $failed = true;
    }
    $mysqli->close();
    
    if($failed == false) {
        header('Location: ../success.php');
        exit;
    }
  4. I'm not sure if you mean something like this, but i'll give it a try :)

    function checkLoginLevel() {
            $allowed = array(
                '1' => array('first-page.php'),
                '2' => array('first-page.php', 'second-page.php'),
                '3' => true,
            );
        
            if(!isset($allowed[$_SESSION['level']])) {
                echo 'You have no login level';
                exit;
            }
        
            if(is_array($allowed[$_SESSION['level']])) {
                $file = $_SERVER["PHP_SELF"];
                $file = explode('/', $file);
                $file = end($file);
                if(!in_array($file, $allowed[$_SESSION['level']])) {
                    echo 'You are not allowed on this page';
                    exit;
                }
            }
        
            if(is_bool($allowed[$_SESSION['level']])) {
                // you're allowed;
            }
        }
    
  5. It might be easier to find the problem by finding out which condition is invalid. Try an echo at every possible return false.

                    if ($login_check == $login_string) {
                    // Logged In!!!!
                        return true;
                    } else {
                    // Not logged in
                        echo 1;
                        return false;
                    }
                } else {
                // Not logged in
                    echo 2;
                    return false;
                }
            } else {
            // Not logged in
                echo 3;
                return false;
            }
        } else {
        // Not logged in
            echo 4;
            return false;
        }
    }

    Depending on which number is echo'd you know where your problem is.

  6. I have been looking for some good libraries a couple of months ago and I found the following lib:

    http://simplehtmldom.sourceforge.net/

     

    It has very easy documantion and it really does everything you want to achive.

    // Create DOM from URL or file
    $html = file_get_html('http://www.google.com/');
    
    // Find all images 
    foreach($html->find('.maintbl td') as $element)
           echo $element->src . '<br>';

    See if maybe this lib helps

  7. After setting the mysql_query you still have to call a mysql_fetch function with the result.

    use for an example:

    http://nl3.php.net/manual/en/function.mysql-fetch-assoc.php

    $result=mysql_query("SELECT * FROM `eusers` WHERE id='".$_SESSION['uid']."'");
    
    while ($row = mysql_fetch_assoc($result)) {
    if($row['MENUAdviser']=="Y"){
    echo '<script type="text/javascript" src="ExtranetMenu.js"></script>';
    }
    if($row['MENUPAS']=="Y"){
    echo '<script type="text/javascript" src="PASMenu.js"></script>'; 
    }
    if($row['MENUStaff']=="Y"){
    echo '<script type="text/javascript" src="IntranetMenu.js"></script>';
    }
    if($row['MENUWebAdmin']=="Y"){
    echo '<script type="text/javascript" src="WebAdminMenu.js"></script>';
    }
    }

    Also, if you use if statements. Use the == operator instead of a single =.

    Otherwise it wont work.

  8. the function you're calling for send is indeed setting the headers for a download, however it does not contain the file you want to save.

    Usually when these headers are sent the file is already saved on your server en after setting the headers the function readfile or file_get_contents is called to complete the download request.

    So, the send function is not sufficient to help you on saving the file. If you have found the filedata you want to save, try using the file_put_contents function. That's my favorite function to save files on the server.

     

    Since your current function is an export it's logical to open the export in a new window. The new window will become a download.

    However if you want to save the file, maybe try something like this:

    var myWindow = window.open('inc/export_hitlist.php?paid='+info, 'Export');myWindow.opener.alert('File is saved');
    myWindow.close();
  9. You have a ; after your if statement

    if (! $insert_stmt->execute());

    remove that ; because a ; means that no action will follow if the if statement is valid.

    Also, put this line in comments

    printf("%d Row inserted.\n", $insert_stmt->affected_rows);

    Otherwise you'll get a syntax error because the { will open too late.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.