close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

MySQLi Query Issue

Thread began 6/14/2014 3:33 pm by randyrie405335 | Last modified 6/17/2014 7:57 am by Jason Byrnes | 1723 views | 4 replies |

randyrie405335

MySQLi Query Issue

With this SQL I'm using in a MySQLi recordset typing in a partial value into a search field will not find any records but typing the complete value does. As an example, if I type in 'abe' no records are found, but if I type in 'abe lincoln', the record is found. Why is the LIKE condition not working in this SQL? Am I using an incorrectly formed variable? Using the MySQLi Query Builder doesn't build a successful SQL statement either.

SELECT publications.*
FROM publications
WHERE publications.Author LIKE varAuthor OR publications.Title LIKE varTitle OR publications.SubmitDate = varSubmitDate

Sign in to reply to this post

CraigRBeta Tester

You need to add your wildcard characters to your parameter string

http://www.w3schools.com/sql/sql_wildcards.asp

Sign in to reply to this post

Jason ByrnesWebAssist

  (The variable is defined as: Name: varAuthor Type: text Default Value: -1 Runtime Value" <?php echo $_GET['Author']; ?> )  



For the like comparison, we created the Begins With, Ends With, and Contains Text variable types. In the variable definition, you need to set the type to one of those instead of using Text.

Sign in to reply to this post

randyrie405335

When I use "Contains text" I get no records found. Going back to "text" will find results as long as I use complete parameters. What am I doing wrong?

Here's the PHP that MySQLi generates:
<?php
$rsSearch = new WA_MySQLi_RS("rsSearch",$JUA_i,1);
$rsSearch->setQuery("SELECT publications.* FROM publications WHERE publications.Author LIKE ? OR publications.Title LIKE ? OR publications.SubmitDate = ?");
$rsSearch->bindParam("s", "".((isset($_GET["Author"]))?$_GET["Author"]:"") ."", "-1"); //varAuthor
$rsSearch->bindParam("s", "".((isset($_GET["Title"]))?$_GET["Title"]:"") ."", "-1"); //varTitle
$rsSearch->bindParam("t", "".((isset($_GET["SubmitDate"]))?$_GET["SubmitDate"]:"") ."", "-1"); //varSubmitDate
$rsSearch->execute();
?>

Sign in to reply to this post

Jason ByrnesWebAssist

you started another thread for this issue and others, i asked for connect information there.

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