close ad
Install the LAtest Updates to Work with CC 2017 and CC 2018
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Limitations ?

Thread began 10/29/2015 9:21 pm by Steve | Last modified 11/03/2015 1:29 pm by Ray Borduin | 826 views | 15 replies |

Steve

Limitations ?

Hello,
Been beating my head against the wall all day and am leaning towards the issue might be an aspect of the MySQLi behavior.

Problem:
I have a MySQLi recordset that should be pulling 29 records but is only showing three. The three is only the records from the first value in an IN () statement.

I've attached the file with comments and will outline what it does in the following steps:

1) Select a Member ID and put it in an array
2) Using a recordset query , poll the DB for any candidates to add to the array
3) Implode the array to have individual values comma separated and reset to the var
4) use that variable in a MySQLi recordset
5) use debugSQL() to see results of final query

Results are:
SELECT tblinventory.invId FROM tblinventory WHERE tblinventory.mid IN ('11','10','20') AND tblinventory.invReleased = 0 ORDER BY rand()

If tested in PHPmyAdmin , 29 records are returned that is accurate for the three values in the IN selector
BUT as a result of the MySQLi recordset behavior only the 1st value in the IN selection is used so only 3 records are the result.

Why is this?

Attached Files
test.php
Sign in to reply to this post

Ray BorduinWebAssist

That is because you have the type of the parameter set to be a string... and really it is a comma separated list of integers.

To fix the problem, just change the parameter type of the target parameter you have in your query. It should update line 31 to:
$Recordset2->bindParam("il", "".$mids ."", "10"); //target

Sign in to reply to this post

Steve

Thanks Ray but I tried that... It removes the leading quotes when as an Integer and still gives the limited results

Screen shot showing those results:


And an SQL error in PHPmyAdmin

Sign in to reply to this post

Ray BorduinWebAssist

Can I get FTP access? I'll have to test it live.... that looks like the result with "integer" and not set as repeated list. Does it have "il" in the code?

Sign in to reply to this post

Steve

Sure, let me double check and resend you the FTP access we already have set up for you..

Sign in to reply to this post

Ray BorduinWebAssist

I'll also need the url to browse the page.

Sign in to reply to this post

Steve

details below

Sign in to reply to this post

Steve

"il" does not render a usable IN string. "s" does a perfect job as shown here:

IN ('11','10','20')

but for some reason it's not working. But the result of debugSQL() does work perfectly fine when executed independently (in PHPmyAdmin). That's why I am thinking there is code in one of the support files that is having trouble with the sql query result even though it is rendered in a usable manner. Security concern?

Sign in to reply to this post

Steve

I've found that integers also work if you implode the array within the SQL Query.

Granted I am not using the MySQLi Behavior but here is a solution, but we now need to figure how to do this WITH the behavior

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}

$sql = "SELECT tblinventory.invId FROM tblinventory WHERE tblinventory.mid IN (".implode(',',$mids).") AND tblinventory.invReleased = 0 ORDER BY rand()";
$result = $conn->query($sql);
echo $sql;

$conn->close();



Result:
SELECT tblinventory.invId FROM tblinventory WHERE tblinventory.mid IN (11,10,20) AND tblinventory.invReleased = 0 ORDER BY rand()

1227
1339
2734
1372
516
1681
... etc

Sign in to reply to this post

Ray BorduinWebAssist

It looks like that ftp account doesn't have write access, so I can't debug the files.

The DebugSQL() function just replaces the parameters in the string... it doesn't have the SQL injection security checks the actual parameterized query would run when replacing parameters.

You won't be able to pass in multiple values using "s". If you can update my FTP privileges I'll debug it and get it working for you.

Sign in to reply to this post
loading

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