Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


Transitioning to PDO/MySQL.  Need help  with SELECT statement, Do I have to bind value?

Posted on 2014-12-20
Medium Priority
Last Modified: 2014-12-20
On a select statement without a WHERE clause, do I have to bind anything using PDO?

I am getting the following error:
Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 32 bytes)
on "$query2->execute();" line.

$query2 = $conn->prepare('SELECT * FROM `download');
// Do I bind a value here?

while ($row2 = $query2->fetch(PDO::FETCH_ASSOC))
 echo $row2['image']."<BR>";


Open in new window

Question by:lawrence_dev
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
LVL 58

Accepted Solution

Gary earned 2000 total points
ID: 40511308
No you can just do

$query2 = $conn->query('SELECT * FROM `download');

while ($row2 = $query2->fetch(PDO::FETCH_ASSOC))

Open in new window

But that error means you are running out of memory
Are there a lot of rows being returned?

Search the php.ini file for
memory_limit =

...and increase the limit.

Author Comment

ID: 40511320
Thanks Gary!
I have 17040 rows,  None being returned.  If I place php.ini in the same folder, PDO stops working for some reason...  

Still working on it...
LVL 58

Expert Comment

ID: 40511324
Add this to the top of the php page to get any errors reported


32 MB is rather small for a site, 64 or 128 would be better.
But you are returning a lot of rows - is there a reason?

If you are using a custom php.ini file you should place it in the site root.
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

LVL 58

Expert Comment

ID: 40511325
I've just noticed a syntax error in your code

Should be (no need for the backticks and you were missing the closing one)

$query2 = $conn->query('SELECT * FROM download');

Open in new window


Author Comment

ID: 40511331
Thanks Gary for all of your help!!  Memory Limit issue with IonCube required for PDO.  Fixed it and it is good!

Author Closing Comment

ID: 40511333
Thanks again!

Featured Post


Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question