Solved

MYQSLI help with limit

Posted on 2014-11-10
3
97 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 108

Accepted Solution

by:
Ray Paseur earned 500 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 108

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

Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
PHP Healthcheck 2 86
Sql query on a varchar that is numeric. 8 27
Before I get too far.. best way to save dates data 4 16
change database name 2 4
Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
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…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

867 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now