Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8097061
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T21:38:26+00:00 2026-06-05T21:38:26+00:00

I am trying to move from MySQL to MySQLi but am having some problems.

  • 0

I am trying to move from MySQLtoMySQLibut am having some problems. MySQLiconnection starts as shown below:

$langCon=mysqli_connect('localhost', 'root', '', 'english');
if (!$langCon) die('Couldn\'t connect: '.mysqli_error());

and I am trying to useMySQLito store my session data, however, I keep getting an error on my _write construct (It is unfinished, posting like this since the error occurs on line 56, the one with$stmt=...):

function _write($id, $data){ /
        global $langCon;
        $stmt=mysqli_prepare($langCon,'REPLACE INTO `sess`(`id`,`access`,`data`) VALUES(?,?,?)');
        $id = mysqli_real_escape_string($langCon,$id);
        $data = mysqli_real_escape_string($langCon,$data);
        $t=$_SERVER['REQUEST_TIME'];
        return mysqli_query($langCon,"REPLACE INTO `sess`(`id`,`access`,`data`) VALUES('$id','$t','$data')");
    }

The error given is: Warning: mysqli_prepare() expects parameter 1 to be mysqli, null given in [...]settings.php on line 56 (the line is $stmt=…)

Could anyone please tip me off on where my problem might be?

EDIT Var dump outside function,var_dump($langCon):

object(mysqli)#2 (18) { [“affected_rows”]=> int(0) [“client_info”]=>
string(50) “mysqlnd 5.0.8-dev – 20102224 – $Revision: 321634 $”
[“client_version”]=> int(50008) [“connect_errno”]=> int(0)
[“connect_error”]=> NULL [“errno”]=> int(0) [“error”]=> string(0) “”
[“field_count”]=> int(0) [“host_info”]=> string(20) “localhost via
TCP/IP” [“info”]=> NULL [“insert_id”]=> int(0) [“server_info”]=>
string(10) “5.5.21-log” [“server_version”]=> int(50521) [“stat”]=>
string(130) “Uptime: 373 Threads: 1 Questions: 5 Slow queries: 0
Opens: 34 Flush tables: 1 Open tables: 27 Queries per second avg:
0.013” [“sqlstate”]=> string(5) “00000” [“protocol_version”]=> int(10) [“thread_id”]=> int(5) [“warning_count”]=> int(0) }

Var dump inside function, global $langCon; var_dump($langCon);: NULL.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T21:38:28+00:00Added an answer on June 5, 2026 at 9:38 pm

    From the manual; try something like this (it has to look like $var->prepare)

    $mysqli = new mysqli("localhost", "root", "", "english");
    if ($mysqli->connect_errno) 
    {
        echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
    }
    
    if (!($stmt = $mysqli->prepare("INSERT INTO test(id) VALUES (?)"))) 
    {
        echo "Prepare failed: (" . $mysqli->errno . ") " . $mysqli->error;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to move a MySQL database from a Linux machine to one running
I am trying to move from Vim to Emacs and have had some translation
I'm trying to move files from myLocation to the Desktop, but my copyTo syntax
I am trying to move from a mysql set to a postgres one, and
I'm trying to move enums from a table into their own table, the easiest
So I am trying to move selected rows from 1 table to another in
I'm trying to move the data from one table to another based on names
I'm trying to move a control from one parent to another (if this will
I am trying to move to UITableView named Cart from UIView by clicking on
I'm trying to move the menu structure from a JMenu into a JMenuBar. The

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.