Jump to content
Larry Ullman's Book Forums

Search the Community

Showing results for tags 'ecommerce & advance php'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Single Editions
    • Modern Javascript: Develop and Design
    • The Yii Book
    • Effortless Flex 4 Development
    • Building a Web Site with Ajax: Visual QuickProject
    • Ruby: Visual QuickStart Guide
    • C++ Programming: Visual QuickStart Guide
    • C Programming: Visual QuickStart Guide
    • Adobe AIR: Visual QuickPro Guide
  • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (5th Edition)
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (4th Edition)
    • PHP 6 and MySQL 5 for Dynamic Web Sites: Visual QuickPro Guide (3rd Edition)
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (2nd Edition)
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (1st Edition)
  • PHP for the Web: Visual QuickStart Guide
    • PHP for the Web: Visual QuickStart Guide (5th Edition)
    • PHP for the Web: Visual QuickStart Guide (4th Edition)
    • PHP for the Web: Visual QuickStart Guide (3rd Edition)
    • PHP for the World Wide Web: Visual QuickStart Guide (2nd Edition)
    • PHP for the World Wide Web: Visual QuickStart Guide (1st Edition)
  • Effortless E-commerce with PHP and MySQL
    • Effortless E-Commerce with PHP and MySQL (2nd Edition)
    • Effortless E-Commerce with PHP and MySQL
  • PHP Advanced: Visual QuickPro Guide
    • PHP Advanced and Object-Oriented Programming: Visual QuickPro Guide (3rd Edition)
    • PHP 5 Advanced: Visual QuickPro Guide (2nd Edition)
    • PHP Advanced: Visual QuickPro Guide
  • MySQL: Visual QuickStart Guide
    • MySQL: Visual QuickStart Guide (2nd Edition)
    • MySQL: Visual QuickStart Guide (1st Edition)
  • Other
    • Announcements
    • Newsletter, Blog, and Other Topics
    • Forum Issues
    • Social

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Found 1 result

  1. Hi I recent combined both "mysql.inc.php" for Effortless Ecommerce and Advance PHP. When I run the script (typing it in the browser of course) it returns this: Warning: mysqli_real_escape_string() expects parameter 1 to be mysqli, string given in C:\xampp\htdocs\day2\mysql.inc.php on line 94 Warning: mysqli_real_escape_string() expects parameter 1 to be mysqli, string given in C:\xampp\htdocs\day2\mysql.inc.php on line 94 Warning: mysqli_query() expects parameter 1 to be mysqli, null given in C:\xampp\htdocs\day2\mysql.inc.php on line 95 Warning: mysqli_close() expects parameter 1 to be mysqli, null given in C:\xampp\htdocs\day2\mysql.inc.php on line 58 Now when I go into to the php.ini.file (xampp) and I set "session.auto=1" (zero "0" is default) it works. I want to know why it doesn't work when I leave it on default. I've combined db_sessions.inc.php from PHP Adance OOP and mysql.inc.php from Effortless. myscript: =========================================== <?php //this is a global variable that will connect to all sessions. $dbc = NULL; function open_session() { global $dbc; //Set the database access information as constants: DEFINE ('DB_HOST', 'localhost'); DEFINE ('DB_USER', 'root'); DEFINE ('DB_PASSWORD', 'password '); DEFINE ('DB_NAME', 'db'); //make the connection: $dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME) or die('did not connect' . mysqli_connect_error()); //set the character set: mysqli_set_charset($dbc, 'utf8'); //Create the function for escaping and trimming form data //Takes one argument: the data to be treated(string) //return the treated data(string) function escape_data($data, $dbc) { //strip the slashes if Magic Quotes is on: if (get_magic_quotes_gpc()) $data = stripslashes($data); //apply trim() and mysqli_real_escape_string(): return mysqli_real_escape_string($dbc, trim($data)); }// end of function escape_data() return true; }// end of open_sesssion() function // define the close_session() function //this function takes no arguments //this function closes the database connection //this function returns the close status. function close_session() { global $dbc; return mysqli_close($dbc); } // End of close_session() function. //define the read_session() function //this function takes one argument: the session ID: //this function retrieves the session data //this function returns the sesion data as a string function read_session($sid) { global $dbc; $q= sprintf('SELECT data FROM sessions WHERE id="%s"', mysqli_real_escape_string($dbc, $sid)); $r= mysqli_query($dbc, $q); //retrieve the results: if (mysqli_num_rows($r) === 1) { list($data) = mysqli_fetch_array($r, MYSQLI_NUM); //RETURN THE DATA: return $data; } else { return; } }//end of read_session() function //define the write_session() function: //this function takes 2 arguments //the session ID and session datat function write_session($sid, $data) { global $dbc; // Store in the database: $q = sprintf('REPLACE INTO sessions (id, data) VALUES ("%s", "%s")', mysqli_real_escape_string($sid, $dbc), mysqli_real_escape_string($data, $dbc)); $r = mysqli_query($dbc, $q); return true; } // End of write_session() function. //define the destroy_session() function: //this function takes 1 argument: the session ID function destroy_session($sid) { global $dbc; $q= sprintf('DELETE FROM sessions WHERE id="%s"', mysqli_real_escape_string($dbc,$sid)); $r= mysqli_query($dbc, $q); //clear the session array $_SESSION = array(); return true; }//end of destroy_session() function //define the clean_session() function //this function takes one argument: a value in seconds. function clean_session($expire) { // this is the garbage collection. can wipe out old sessions that weren't formally destroyed. global $dbc; //delete old sessions: $q = sprintf('DELETE FROM sessions WHERE DATE_ADD(last_accessed, INTERVAL %d SECOND) < NOW()', (int) $expire); $r = mysqli_query($dbc, $q); return true; }// end of clean_session() function /**************** END OF FUNCTIONS *****************/ //declare the functions to use: session_set_save_handler('open_session','close_session', 'read_session', 'write_session', 'destroy_session', 'clean_session'); //session_start() not need because of changes made in php.ini.file session_start(); //omit the PHP tag to avoid 'header already sent' errors! ============================================ end of my script I would like to store the users sessions in a separate table.
×
×
  • Create New...