mysqli

Place for questions and answers for all newcomers and new coders. This is a free for all forum, no question is too stupid and to noob.
Post Reply
Caroll09
Posts: 2
Joined: Wed Jun 18, 2014 9:54 pm

mysqli

Post by Caroll09 »

hello guys i am really struggling with the new mysqli thing

for example if i had:

$testinfo = "SELECT * from players where username = $player";
$testinfo1 = mysql_query ($testinfo) or die ("Could not query players");
$testinfo2 = mysql_fetch_array ($testinfo1);

what would be the mysqli equivalent

Thank you
User avatar
Script47
Posts: 147
Joined: Thu Nov 21, 2013 6:11 pm

Re: mysqli

Post by Script47 »

Caroll09 wrote:hello guys i am really struggling with the new mysqli thing

for example if i had:

$testinfo = "SELECT * from players where username = $player";
$testinfo1 = mysql_query ($testinfo) or die ("Could not query players");
$testinfo2 = mysql_fetch_array ($testinfo1);

what would be the mysqli equivalent

Thank you
The "i" is imperative as it's MySQLi.

Code: Select all

$testinfo = "SELECT * from players where username = $player";
$testinfo1 = mysqli_query ($testinfo) or die ("Could not query players");
$testinfo2 = mysqli_fetch_array ($testinfo1);
Be sure to make use of MySQLi's prepared statements too.

http://www.php.net//manual/en/book.mysqli.php
http://codular.com/php-mysqli
Caroll09
Posts: 2
Joined: Wed Jun 18, 2014 9:54 pm

Re: mysqli

Post by Caroll09 »

The "i" is imperative as it's MySQLi.

Code: Select all

$testinfo = "SELECT * from players where username = $player";
$testinfo1 = mysqli_query ($testinfo) or die ("Could not query players");
$testinfo2 = mysqli_fetch_array ($testinfo1);
Be sure to make use of MySQLi's prepared statements too.

http://www.php.net//manual/en/book.mysqli.php
http://codular.com/php-mysqli
so the only thing that changes is the 'i'?
User avatar
Script47
Posts: 147
Joined: Thu Nov 21, 2013 6:11 pm

Re: mysqli

Post by Script47 »

Caroll09 wrote:The "i" is imperative as it's MySQLi.

Code: Select all

$testinfo = "SELECT * from players where username = $player";
$testinfo1 = mysqli_query ($testinfo) or die ("Could not query players");
$testinfo2 = mysqli_fetch_array ($testinfo1);
Be sure to make use of MySQLi's prepared statements too.

http://www.php.net//manual/en/book.mysqli.php
http://codular.com/php-mysqli
so the only thing that changes is the 'i'?
Mostly yes, I suggest learning it. Not just guessing as you might get unexpected results.
User avatar
Sharlenwar
Posts: 524
Joined: Mon May 28, 2012 7:14 pm

Re: mysqli

Post by Sharlenwar »

I have found the mySQLi stuff is different. Very different from the old way. You also want to move to what PHP5 is doing with their somewhat object orientated stuff.

In this thread I use mySQLi: http://indie-resource.com/forums/viewto ... 4&start=10

Hope it helps? Plus I'm not expert, just some nobody.
Deep within the Void of Quasion, a creation.

**My Corner of the Web**
***NEW***GrindFest - My own PHP/MySQL game!
Sharlenwar's Adventures
Torn-City - Massively multiplayer online text based RPG
Post Reply

Return to “Beginner Help and Support”