Welcome, Guest: Join Nairaland / LOGIN! / Trending / Recent / New
Stats: 2,548,980 members, 5,872,091 topics. Date: Tuesday, 22 September 2020 at 06:52 PM

Anyone Good In PHP And Mysqli To Tell Me Whats Wrong With This Code?? - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Anyone Good In PHP And Mysqli To Tell Me Whats Wrong With This Code?? (325 Views)

Please,Help Explain This Code In C / Please How Can I Convert This Mysql Code To Mysqli / Java Programmers ,I Need Help Fixing This Code. (2) (3) (4)

(1) (Reply) (Go Down)

Anyone Good In PHP And Mysqli To Tell Me Whats Wrong With This Code?? by PericomaNwankwo: 11:27am On Aug 15
I am trying to upgrade the script from mysql to mysqli but this is the error that has been beating me up please help...

The code:

$theValue = function_exists("mysqli_real_escape_string"wink ? mysqli_real_escape_string("GetSQLValueString", $theValue) : mysqli_real_escape_string("GetSQLValueString", $theValue);

The error:

PHP Warning: mysqli_real_escape_string() expects exactly 2 parameters, 1 given in /home/metrcaho/public_html/backend/index.php on line 10
[15-Aug-2020 06:17:01 America/New_York] PHP Notice: Undefined variable: dbconnect in /home/metrcaho/public_html/backend/index.php on line 10
[15-Aug-2020 06:17:01 America/New_York] PHP Fatal error: Uncaught Error: Function name must be a string in /home/metrcaho/public_html/backend/index.php:10
Stack trace:
#0 /home/metrcaho/public_html/backend/index.php(55): GetSQLValueString('admin', 'text')
#1 {main}
thrown in /home/metrcaho/public_html/backend/index.php on line 10
[15-Aug-2020 06:23:09 America/New_York] PHP Warning: mysqli_real_escape_string() expects parameter 1 to be mysqli, string given in /home/metrcaho/public_html/backend/index.php on line 10
Re: Anyone Good In PHP And Mysqli To Tell Me Whats Wrong With This Code?? by Karleb(m): 11:38am On Aug 15
mysqli_real_escape_string($db, $theValue);

The $db variable is the reference to the mysqli object.

I.e $db = new mysqli();

Gerrit?

BTW, are you a New Yorker?
Re: Anyone Good In PHP And Mysqli To Tell Me Whats Wrong With This Code?? by PericomaNwankwo: 1:18pm On Aug 15
Karleb:
mysqli_real_escape_string($db, $theValue);

The $db variable is the reference to the mysqli object.

I.e $db = new mysqli();

Gerrit?

BTW, are you a New Yorker?

Yes got it, thanks a lot.

NY? That's VPN , I'm in Abidjan
Re: Anyone Good In PHP And Mysqli To Tell Me Whats Wrong With This Code?? by Xperienx(m): 10:16am On Aug 16
You are just about to write another vulnerable code.
Use PDO instead

1 Like

Re: Anyone Good In PHP And Mysqli To Tell Me Whats Wrong With This Code?? by PericomaNwankwo: 6:21am On Sep 16
Xperienx:
You are just about to write another vulnerable code.
Use PDO instead


Yeah I already fixed it, code is okay, used MySQL and just downgraded my php version. That solves it

(1) (Reply)

Help / URGENT: Pls On My Mlm Script /

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2020 Oluwaseun Osewa. All rights reserved. See How To Advertise. 33
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.