Title: Executing SQL within php
Last modified: August 30, 2016

---

# Executing SQL within php

 *  [dda0s](https://wordpress.org/support/users/dda0s/)
 * (@dda0s)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/executing-sql-within-php/)
 * it might be my newbiness, but i’m having problems trying to execute sql queries
   within a post:
 *  $query = “SELECT MIN(TrgDuration) FROM C2LogBook WHERE TrgDistance =5000”;
 *  $result = mysql_query($query);
 *  while ($row = mysql_fetch_assoc($result)) {
    echo $row[‘TrgDuration’]; echo 
   $row[‘TrgDate’]; echo $row[‘TrgDistance’]; }
 * mysql_free_result($result);
 * its not returning anything
 * not quite sure where the error is 8probably my SQL Query) but any help would 
   be appreciated.
 * [https://wordpress.org/plugins/allow-php-in-posts-and-pages/](https://wordpress.org/plugins/allow-php-in-posts-and-pages/)

The topic ‘Executing SQL within php’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/allow-php-in-posts-and-pages_edefed.
   svg)
 * [Allow PHP in Posts and Pages](https://wordpress.org/plugins/allow-php-in-posts-and-pages/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/allow-php-in-posts-and-pages/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/allow-php-in-posts-and-pages/)
 * [Active Topics](https://wordpress.org/support/plugin/allow-php-in-posts-and-pages/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/allow-php-in-posts-and-pages/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/allow-php-in-posts-and-pages/reviews/)

 * 0 replies
 * 1 participant
 * Last reply from: [dda0s](https://wordpress.org/support/users/dda0s/)
 * Last activity: [10 years, 8 months ago](https://wordpress.org/support/topic/executing-sql-within-php/)
 * Status: not resolved