close ad
Databridge V2 with MySQLi support IS Now Available!
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

In PHP 7.4, I have MySQLi connections with 3 variables in the query — possible? or replace get_magic_quotes_gpc

Thread began 3/11/2021 5:02 pm by dionysus224892 | Last modified 3/12/2021 10:47 am by Ray Borduin | 118 views | 5 replies |

dionysus224892

In PHP 7.4, I have MySQLi connections with 3 variables in the query — possible? or replace get_magic_quotes_gpc

Hi, the problem is that I have multiple bindParams and when I do more than 1, it screws up.

A. Is there a way to put in multiple as in the following?

SELECT * FROM table WHERE var1 = ?, var2 = ?, var3 = ? AND active = 'yes';


Or if that can't work, then...


B) In the past, I could just use:

if (isset($_GET['seas'])) {
$leyear = (get_magic_quotes_gpc()) ? $_GET['seas'] : addslashes($_GET['seas']);
} else {
$leyear = $currentyear;
}

And then use the variable in the queries or wherever.

Thanks very much! Nice to see that everything we bought previously still works well!

Sign in to reply to this post

dionysus224892

The point of this is to do whatever sanitizing/validation is done with a single variable/bindParam.

Using 3 variables causes an error.

I found THIS online :

$calories = 150;
$colour = 'red';
$sth = $dbh->prepare('SELECT name, colour, calories
FROM fruit
WHERE calories < ? AND colour = ?');
$sth->bindParam(1, $calories, PDO::PARAM_INT);
$sth->bindParam(2, $colour, PDO::PARAM_STR, 12);
$sth->execute();



Possible to add order numbers to the existing code?

As in :

$rsShowingsTour->bindParam(1, "i", "".(isset($_GET['id'])?$_GET['id']:"") ."", "-1"); //colname

And then modify the following somehow?

public function bindParam($paramType,$paramValue,$paramDefault="",$paramPosition=false) {




I found this as well :

// A. You can either do one parameter at a time or pass an array to execute().

—$STM->bindParam(":op", "twitter", PDO::PARAM_STR);
—$STM->bindParam(":ou", $user_info->id, PDO::PARAM_INT);

//Or B.

—execute(array(":op"=>"twitter", ":ou"=>$user_info->id));


Thanks!

Sign in to reply to this post

Ray BorduinWebAssist

You can add as many parameters as you need to your recordset. You might consider upgrading to DataBridge v2 in order to create php7 compliant code.

Sign in to reply to this post
Did this help? Tips are appreciated...

dionysus224892

Hey.. thanks for responding!

I can add more than 1 parameter now as I am currently? or do I need Databridge 2 for that?

Because in the past, when I've put more than 1 parameter, I had errors because it seems that it wasn't sure which ? referred to which variable?

Or does it work by the sequence of the listing of the variables?

BTW, I was planning to upgrade Databridge but the money hasn't been there the past little while...as soon as I'm back to normal, I look forward to it.

Sign in to reply to this post

Ray BorduinWebAssist

You can add as many parameters as you want in previous versions as well. It just won't work on php7 or newer.

Sign in to reply to this post
Did this help? Tips are appreciated...

dionysus224892

Ahh OK.. that must be when I hit the snag then. Thanks for that. For now, I will remove the deprecated code and either figure it out in the next few days or wait til I'm all updated.

Thanks again for letting me know

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...