Jump to content

changing from mysql to mysqli but it won't connect?


Tpick

Recommended Posts

Hi, sorry for noob question, first time poster. Hopefully I"m in the correct section of the forum. I'm running php version 5.6.40 and have mysqli enabled on my website. I'm trying to to change over from the old mysql_connect to mysqli_connect (and so on) so that I can eventually upgrade to php 7. I'm wondering if there is anything I'm missing or supposed to do, every resource I can find online says that for something this simple I simply need to add the "i" to the end, but for some reason it won't connect once I add the "i". I'll include the code in question. If I simply delete the "i" it works just fine.

 

$host = "localhost:3036";  
$serverusername = "my_username"; 
$serverpassword = "my_password"; 
$db_name = "my_db_name";

$connection = mysqli_connect("$host", "$serverusername", "$serverpassword")or die("cannot connect");
$db = mysqli_select_db("$db_name", $connection)or die("cannot select DB");

 

Link to comment
Share on other sites

22 minutes ago, Tpick said:

every resource I can find online says that for something this simple I simply need to add the "i" to the end

"Every resource" is wrong. Try reading the free manual. This is too simple to just give you the answer.

https://www.php.net/manual/en/mysqli.quickstart.connections.php

https://www.php.net/manual/en/mysqli.select-db.php

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.