Programming › Re: 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 |
Programming › Re: 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" ) 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 |
Programming › Re: 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"  or die("Could not connect."  ; if(!$db) die("no db"  ; if(!mysqli_select_db($db,"$dbname"  ) die("No database selected."  ; 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 |
Programming › Re: 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 |
Programming › Please How Can I Convert This Mysql Code To Mysqli by Kingvick(op): 8:07am On Nov 14, 2018*. Modified: 1:18pm On Nov 14, 2018 |
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)); } |
|
Webmasters › Re: Create Your Own Nairaland Forum Or Your Blog For Just N5000 by Kingvick(op): 9:09am On Sep 17, 2018 |
Get your own site |
Webmasters › Re: 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 |
Programming › Re: 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 |
Webmasters › Re: Buy Verified Non Hosted Nigerian Adsense Account With $16 In It by Kingvick(op): 9:42am On Sep 12, 2018 |
Still available |
Webmasters › Re: 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 |
Webmasters › Buy Verified Non Hosted Nigerian Adsense Account With $16 In It by Kingvick(op): 7:44pm On Sep 11, 2018*. Modified: 6:03pm On Sep 12, 2018 |
I have a verified non hosted Nigerian Adsense Account with $16 for sell which i got for my website SOLD
|
Webmasters › Re: 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 Need ur help on a blog Am at abuja you can contact me via facebook |
Webmasters › Re: 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 |
Webmasters › Re: Create Your Own Nairaland Forum Or Your Blog For Just N5000 by Kingvick(op): 2:57pm On Sep 11, 2018 |
Get Yours |
Webmasters › Re: 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 |
Webmasters › Re: Create Your Own Nairaland Forum Or Your Blog For Just N5000 by Kingvick(op): 9:28am On Sep 08, 2018 |
still available |
Webmasters › Re: 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 |
Webmasters › Re: Create Your Own Nairaland Forum Or Your Blog For Just N5000 by Kingvick(op): 4:39pm On Sep 06, 2018 |
offer still on |
Webmasters › Re: 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 |
Webmasters › Re: 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 |
Webmasters › Re: 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 |
Webmasters › Re: I Need A Cool Forum Script. Come In by Kingvick: 10:20pm On Aug 26, 2018 |
|
Webmasters › Re: Buy Verified Non Hosted Nigerian Adsense Account by Kingvick(op): 5:23pm On Aug 20, 2018 |
Still available |
Webmasters › Buy Verified Non Hosted Nigerian Adsense Account by Kingvick(op): 1:34pm On Aug 20, 2018*. Modified: 5:23pm On Aug 20, 2018 |
I have a verified non hosted Nigerian Adsense Account for sell if interested call me on 08085921310 |
Webmasters › Re: 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 |
Webmasters › Re: General Discussion Forum With Adsense For Sale by Kingvick(op): 9:12am On Aug 20, 2018 |
Offer still on |
Webmasters › General 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 |
|
Webmasters › Re: 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 |
Webmasters › Create Your Own Nairaland Forum Or Your Blog For Just N5000 by Kingvick(op): 7:51am On Aug 08, 2018*. Modified: 9:07am On Sep 17, 2018 |
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. |
Webmasters › Re: Whats ur forum address(link) by Kingvick: 8:44pm On Jul 09, 2018 |
|