Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

MYQSLI help with limit

Posted on 2014-11-10
3
Medium Priority
?
117 Views
Last Modified: 2014-11-10
Hi,

Im using Mysqli and im trying to limit the results by 10 and order them from last to first from the database.

$sqlhorses = "SELECT Place FROM `*` WHERE `Horse` ='".$db->real_escape_string($row['horse']). "'";

Open in new window


the above works but when i added the limit 6 to the end it shows errors.

Can anyone help?
0
Comment
Question by:runnerjp2005
  • 2
3 Comments
 
LVL 111

Accepted Solution

by:
Ray Paseur earned 2000 total points
ID: 40432457
Is this the table name? `*`

It's usually easier to get query strings right if you avoid compound statements and use HEREDOC notation (search PHP.net for that) or if you use double quotes.  Maybe something like this:

$horse = $db->real_escape_string($row['horse']);
$sqlhorses = "SELECT * FROM Place WHERE  HORSE = '$horse' ";
// OR...
$sqlhorses = "SELECT * FROM Place WHERE  HORSE = '$horse' LIMIT 10";

Open in new window

0
 

Author Closing Comment

by:runnerjp2005
ID: 40432480
Perfect thanks.... i just added * to limit the amount of my table structure im sharing
0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 40432746
Thanks for the points - glad you've got it pointed in the right direction! ~Ray
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This post contains step-by-step instructions for setting up alerting in Percona Monitoring and Management (PMM) using Grafana.
In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller singl…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

885 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