Solved

MYQSLI help with limit

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
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.

744 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

16 Experts available now in Live!

Get 1:1 Help Now