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

MySQLi using LIKE with URL parameter not working correctly

Thread began 2/17/2016 7:54 pm by John | Last modified 2/18/2016 7:21 pm by John | 1889 views | 8 replies

John

Well, I hope you can help me with another variation on this. Ok, so I finally got this working and it returns a book with the word "Science" in the subject1 field. This is the link:

http://69.16.243.60/~dijkstr1/books-by-subject.php?subject1=Science

But then I expand the query to also search for books that have Science in the subject2 field (secondary book subject) it returns nothing:

<?php
$rsBySubject = new WA_MySQLi_RS("rsBySubject",$connProjMain1,0);
$rsBySubject->setQuery("SELECT books.isbn13, books.coverimage, books.title, books.full_title, books.subtitle, books.subject1, books.subject2, books.auth_id, books.publisher, books.`description`, authors.authfirst, authors.authlast, authors.auth_id, authors.author_full FROM books, authors WHERE books.active_web = '1' AND (books.subject1 LIKE ? OR books.subject2 LIKE ?) AND authors.auth_id = books.auth_id ORDER BY authors.authlast");
$rsBySubject->bindParam("c", "".(isset($_GET['subject1'])?$_GET['subject1']:"") ."", "-1"); //colname
$rsBySubject->execute();
?>

Pretty simple but it doesn't return any books. It should return 4 books - the one with Science in subject1 and the three with Science in subject2.

The error message is:

Warning: mysqli_stmt::bind_param() [mysqli-stmt.bind-param]: Number of variables doesn't match number of parameters in prepared statement in /webassist/mysqli/rsobj.php on line 128

Again, any help would be appreciated. I have this working on about a dozen other sites, but I didn't realize migrating from MySQL to MySQLi would be so tricky and unfortunately I need to show the client the site tomorrow.

Thanks.

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