₦airaland Forum

Welcome, Guest: RegisterLoginWith GoogleTrendingRecentNew

Stats: 3,325,112 members, 8,420,421 topics. Date: Thursday, 04 June 2026 at 07:08 PM

Toggle theme

Kingvick's Posts

Nairaland ForumKingvick's ProfileKingvick's Posts

1 2 3 4 5 6 7 8 ... 14 15 16 17 18 19 20 (of 20 pages)

ProgrammingRe: Please How Can I Convert This Mysql Code To Mysqli by Kingvick(op): 7:50am On Nov 15, 2018
Zsatan:
As codeBoy advice please use PDO. This will help you with prepared statements to avoid SQL injection.


In Php7+ magic_quotes_gpc() is depreciated.


Now to your question, the issue was with your datatype. Mysqli_realescape_strug accepts

a. A mysqli Link
b. A string variable data type to be escaped.

Now in your code you passed the GET and POST variable global. So if you really want to escape all the variables in that array. Kindly use a for loop statement..




$iLen = count ($_GET)
cleanedUpGet=array();

foreach( $_GET as $key => $value ) {

cleanedUpGet[$key] = mysqli_realescape_string($dbConnection, $value)

}


var_dump($_GET)



______________________________

If you want to do it the Object Oriented Way do.


mysqli::escapestring($stringVariable)




_________________________

However I will advice you use PDO.


Note: I don't test the above code but I believe it would work.



@commenters: On a side note I no longer work on Php7, I left php a long time to rustLang, I wanted asking if Php community has embraced the static type introduction ??
Thanks would test the codes
ProgrammingRe: Please How Can I Convert This Mysql Code To Mysqli by Kingvick(op): 6:08pm On Nov 14, 2018
Codedboy95:
are you updating to php7.* ? if so get_magic_quotes_gpc() is depreciated as of php5.2 so it will throw an error on higher php versions

make use of this for your connection
<?php
$dbname = " "; // Your Sql Database Name
$dbuser = " "; // Your sql database username

$dbhost = " "; // its always localhost, except if your host states otherwise

$dbpass = " "; // Your sql database password


$db=($db = mysqli_connect("$dbhost", "$dbuser", "$dbpass", "$dbname", "3306"wink) or die ('Cannot connect to the database because: ' . ((is_object($db)) ? mysqli_error($db) : (($___mysqli_res = mysqli_connect_error()) ? $___mysqli_res : false)));
?>

then the best way to sanitize user input is using prepared statement (PDO) instead of mysqli_real_escape. Read about prepared statement pdo
Yes am updating to php7. Thanks for this information
ProgrammingRe: Please How Can I Convert This Mysql Code To Mysqli by Kingvick(op): 2:10pm On Nov 14, 2018
MrWondah:
Your code looks good. But it might be a problem with your DB connection. Did you use mysqli or mysql in your db connection? if there is discrepancy your code wont work. So it would be better if you share the error code you got and the db connection code
i made use of mysqli here is the complete convertion i tried

<?php

$dbname = ""; // Your Sql Database Name

$dbuser = ""; // Your sql database username

$dbhost = ""; // its always localhost, except if your host states otherwise

$dbpass = ""; // Your sql database password


$db = mysqli_connect("$dbhost", "$dbuser", "$dbpass"wink or die("Could not connect."wink;
if(!$db)
die("no db"wink;
if(!mysqli_select_db($db,"$dbname"wink)
die("No database selected."wink;
if(!get_magic_quotes_gpc())
{
$_GET = array_map(mysqli_real_escape_string($db, $_GET));
$_POST = array_map(mysqli_real_escape_string($db, $_POST));
$_COOKIE = array_map(mysqli_real_escape_string($db, $_COOKIE));
}
else
{
$_GET = array_map('stripslashes', $_GET);
$_POST = array_map('stripslashes', $_POST);
$_COOKIE = array_map('stripslashes', $_COOKIE);
$_GET = array_map(mysqli_real_escape_string($db, $_GET));
$_POST = array_map(mysqli_real_escape_string($db, $_POST));
$_COOKIE = array_map(mysqli_real_escape_string($db, $_COOKIE));
}
?>

Am geting this errors

[14-Nov-2018 03:13:03 UTC] PHP Warning: mysqli_real_escape_string() expects parameter 2 to be string, array given in /home/yukhubco/public_html/incfiles/connect.php on line 19
[14-Nov-2018 03:13:03 UTC] PHP Warning: array_map() expects at least 2 parameters, 1 given in /home/yukhubco/public_html/incfiles/connect.php on line 19
[14-Nov-2018 03:13:03 UTC] PHP Warning: mysqli_real_escape_string() expects parameter 2 to be string, array given in /home/yukhubco/public_html/incfiles/connect.php on line 20
[14-Nov-2018 03:13:03 UTC] PHP Warning: array_map() expects at least 2 parameters, 1 given in /home/yukhubco/public_html/incfiles/connect.php on line 20
[14-Nov-2018 03:13:03 UTC] PHP Warning: mysqli_real_escape_string() expects parameter 2 to be string, array given in /home/yukhubco/public_html/incfiles/connect.php on line 21
[14-Nov-2018 03:13:03 UTC] PHP Warning: array_map() expects at least 2 parameters, 1 given in /home/yukhubco/public_html/incfiles/connect.php on line 21
ProgrammingRe: Please How Can I Convert This Mysql Code To Mysqli by Kingvick(op): 1:19pm On Nov 14, 2018
MrWondah:
Can you give more details?
Pls check the topic again I modified it
ProgrammingPlease How Can I Convert This Mysql Code To Mysqli by Kingvick(op):
I need help in converting this codes

if(!get_magic_quotes_gpc())
{
$_GET = array_map('mysql_real_escape_string', $_GET);
$_POST = array_map('mysql_real_escape_string',
$_POST);
$_COOKIE = array_map('mysql_real_escape_string',
$_COOKIE);
}
else
{ $_GET = array_map('stripslashes', $_GET);
$_POST = array_map('stripslashes', $_POST);
$_COOKIE = array_map('stripslashes', $_COOKIE);
$_GET = array_map('mysql_real_escape_string', $_GET);
$_POST = array_map('mysql_real_escape_string',
$_POST);
$_COOKIE = array_map('mysql_real_escape_string',
$_COOKIE);
}

tried this but its not working



if(!get_magic_quotes_gpc())
{
$_GET = array_map(mysqli_real_escape_string($db, $_GET));
$_POST = array_map(mysqli_real_escape_string($db, $_POST));
$_COOKIE = array_map(mysqli_real_escape_string($db, $_COOKIE));
}
else
{
$_GET = array_map('stripslashes', $_GET);
$_POST = array_map('stripslashes', $_POST);
$_COOKIE = array_map('stripslashes', $_COOKIE);
$_GET = array_map(mysqli_real_escape_string($db, $_GET));
$_POST = array_map(mysqli_real_escape_string($db, $_POST));
$_COOKIE = array_map(mysqli_real_escape_string($db, $_COOKIE));
}
WebmastersRe: Create Your Own Nairaland Forum Or Your Blog For Just N5000 by Kingvick(op): 9:09am On Sep 17, 2018
Get your own site
WebmastersRe: I Can Show You How To Make Up-to 30 Pounds Daily On Your Adsense by Kingvick: 9:04am On Sep 17, 2018
Add 08085921310
ProgrammingRe: Please Who And How Was Nct Community And Every Knows Built by Kingvick: 10:41pm On Sep 16, 2018
If you want to create a site like that I can do it for you.. Nct is making use of mybb forum script
WebmastersRe: Buy Verified Non Hosted Nigerian Adsense Account With $16 In It by Kingvick(op): 9:42am On Sep 12, 2018
Still available
WebmastersRe: Buy Verified Non Hosted Nigerian Adsense Account With $16 In It by Kingvick(op): 8:43pm On Sep 11, 2018
Lauraeze:
Are you on whatsapp
No but you can call me if you interested
WebmastersBuy Verified Non Hosted Nigerian Adsense Account With $16 In It by Kingvick(op):
I have a verified non hosted Nigerian Adsense Account with $16 for sell which i got for my website
SOLD

WebmastersRe: Create Your Own Nairaland Forum Or Your Blog For Just N5000 by Kingvick(op): 5:24pm On Sep 11, 2018
ClixMaster:
Which side are you in Wise and how can we hookup huh Need ur help on a blog
Am at abuja you can contact me via facebook
WebmastersRe: Create Your Own Nairaland Forum Or Your Blog For Just N5000 by Kingvick(op): 3:48pm On Sep 11, 2018
yaksnet:
Meanwhile clean and affordable laptop for sale contact me on (090) 29,6252,55 for negotiable and more information
Mr man go and create your own thread
WebmastersRe: Create Your Own Nairaland Forum Or Your Blog For Just N5000 by Kingvick(op): 2:57pm On Sep 11, 2018
Get Yours
WebmastersRe: Create Your Own Nairaland Forum Or Your Blog For Just N5000 by Kingvick(op): 11:15am On Sep 10, 2018
Get your own forum now
WebmastersRe: Create Your Own Nairaland Forum Or Your Blog For Just N5000 by Kingvick(op): 9:28am On Sep 08, 2018
still available
WebmastersRe: Create Your Own Nairaland Forum Or Your Blog For Just N5000 by Kingvick(op): 3:02pm On Sep 07, 2018
Get your own site today
WebmastersRe: Create Your Own Nairaland Forum Or Your Blog For Just N5000 by Kingvick(op): 4:39pm On Sep 06, 2018
offer still on
WebmastersRe: Create Your Own Nairaland Forum Or Your Blog For Just N5000 by Kingvick(op): 8:54am On Sep 06, 2018
Get your own forum now
WebmastersRe: How To Remove Sora Template Copyright by Kingvick: 7:39am On Aug 29, 2018
The copyright in the template is Encrypted it would be hard to remove it
WebmastersRe: I Want To Buy An Established Blog With Over 10,000 Daily Pageviews by Kingvick: 11:00am On Aug 27, 2018
noblefrank31:
If you have an established non-entertainment blog with over 10,000 page views everyday, good Seo and impressive Alexa rank, I am interested in buying it. Drop your offers if you have any. You can also whatsapp 0 8 1 7 9 1 2 9 8 3 6.
Check http://yukhub.com good seo
For 100k with its adsense
WebmastersRe: I Need A Cool Forum Script. Come In by Kingvick: 10:20pm On Aug 26, 2018
abelanthonyblog:
I need a cool php forum scripts. Drop demos of any forum or forums you have done and your contact details.
Checkout http://yukhub.com
WebmastersRe: Buy Verified Non Hosted Nigerian Adsense Account by Kingvick(op): 5:23pm On Aug 20, 2018
Still available
WebmastersBuy Verified Non Hosted Nigerian Adsense Account by Kingvick(op):
I have a verified non hosted Nigerian Adsense Account for sell if interested call me on 08085921310
WebmastersRe: General Discussion Forum With Adsense For Sale by Kingvick(op): 10:04am On Aug 20, 2018
Immaculatesnow:
Is your adsense verified and if yes call my line on my profile, I will buy it only if it is verified.
Yes its fully verified with balance of $14.56
WebmastersRe: General Discussion Forum With Adsense For Sale by Kingvick(op): 9:12am On Aug 20, 2018
Offer still on
WebmastersGeneral Discussion Forum With Adsense For Sale by Kingvick(op): 11:46pm On Aug 19, 2018
www.yukhub.com forum is up for sale with its adsense account with high search engine optimization.
If interested email me at kingvectorark@gmail.com
WebmastersRe: Create Your Own Nairaland Forum Or Your Blog For Just N5000 by Kingvick(op): 6:39pm On Aug 08, 2018
AdejorLawrence:
Your whatsapp number sir.
Am not on whatsapp email me at kingvectorark@gmail.com or call me 0 8 0 85921310
WebmastersCreate Your Own Nairaland Forum Or Your Blog For Just N5000 by Kingvick(op):
Do You need a website I am a webmaster and
have been on net for a
long time. I create, download and install,and build websites, social
networks, blogs,
forums, wapsites, etc.,
for people and
organizations.

Check some of the
sites I have made:
http://afriforum.net
http://fundingforstudy.com
among others.
People collect thousands of Naira to
just sell scripts to people ranging from
N10000 to N100000 just to design your script.
Today I bring you an unimaginable offer, I
will install your desired
type of website, for just N5000!

No long stories, call or whatsapp me at 08085921310
If interested.
WebmastersRe: Whats ur forum address(link) by Kingvick: 8:44pm On Jul 09, 2018
Check out http://yukhub.com forum

1 2 3 4 5 6 7 8 ... 14 15 16 17 18 19 20 (of 20 pages)