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

MySQL ignoring parameter

Thread began 8/23/2020 8:52 am by mlowe4 | Last modified 9/11/2020 9:08 am by Ray Borduin | 16 views | 2 replies |

mlowe4

MySQL ignoring parameter

Hello, I'm having a strange problem where I'm doing a search based on a query string and set value for partnerfor the set value is 456 and the query string looks like ?q=admin, this should return no records because the partnerfor field for the admin is 123 but it's returning the admin record, can anyone help me or tell me what's wrong with this recordset, the qget variable is basically just a $_GET['q'], many thanks.

<?php
$search = new WA_MySQLi_RS("search",$securex,100);
$search->setQuery("SELECT users.id, users.email, users.dispname, users.xkey, users.logindate, users.loginfrom, users.accesslevel, users.datepasschanged, users.picture, users.disabled, users.lockedout, users.lockedoutcount, users.extlockedout, users.authorised, users.delete_date, users.temppic_start, users.temppic_expire, users.schedpic, users.partner_id, users.forpartner, acceslevels.leveldescription FROM users INNER JOIN acceslevels ON users.accesslevel = acceslevels.id WHERE users.forpartner = ? AND users.email = ? OR users.dispname = ? OR users.loginfrom = ? ORDER BY users.dispname ASC");
$search->bindParam("s", "".$_SESSION['piid'] ."", "-1"); //WAQB_Param1
$search->bindParam("s", "".$qget ."", "-1"); //WAQB_Param2
$search->bindParam("s", "".$qget ."", "-1"); //WAQB_Param3
$search->bindParam("s", "".$qget ."", "-1"); //WAQB_Param4
$search->execute();
?>

I've added some screenshots below, phpmyadmin returns the correct result of no records but the above SQL statement returns the admin record


SORTED NOW

The mistake was display name was acting independently I had to enter forpartner AND email OR forpartner AND dispname, Thanks

Sign in to reply to this post

Ray BorduinWebAssist

Your OR statements would override the AND statements... You might mean something like:

WHERE users.forpartner = ? AND users.email = ? AND (users.dispname = ? OR users.loginfrom = ?)

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

mlowe4

Thanks that worked, thank you very much for your help

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...