Jump to content

Search the Community

Showing results for tags 'sql query error in php'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 1 result

  1. SQL QUERY PROBLEM IN PHP. I m using windows xp O.S. I have installed WAMP for learning and practicing PHP. when I execute the following code i m getting an error.I M INCLUDING A FUNCTION FILE(functions.php) IN MY content.php file.MY ALL OTHER FUNCTIONS AND SQL QUERIES ARE WORKING EXCEPT THIS ONE. ---------------------------------------------------------------------------------------------------------------- functions.php(c:/wamp/www/widget_corp/includes/functions.php) function get_subject_by_id($subject_id){ global $connection; $query = "SELECT * "; $query .= "FROM subjects "; $query .= "WHERE id=".$subject_id; $query .= "LIMIT 1"; $result_set = mysql_query($query,$connection); if(!$result_set){ die("database query failed:".mysql_error()); } //if no rows are returned, then fetch array is going to return false if($subject = mysql_fetch_array($result_set)) { return $subject; } else { return NULL; } } ----------------------------------------------------------------------------------------------------------------- content.php(c:/wamp/www/widget_corp/content.php) <?php require("constants.php"); //Creating a database connection $connection = mysql_connect(DB_SERVER,DB_USER,DB_PASSWORD); if(!$connection){ die("DATABASE CONNECTION FAILED:".mysql_error()); } ?> <?php //Selecting a database $db_connect = mysql_select_db(DB_NAME,$connection); if(!$db_connect){ die("Database selection failed:".mysql_error()); } ?> <?php //including functions.php ?> <?php require_once($_SERVER['DOCUMENT_ROOT']."/widget_corp/includes/functions.php") ?> <?php //$_GET['subj'] and $_GET['page'] are returning my subjects and pages ids respectively. ?> <?php if(isset($_GET['subj'])){ $sel_subj = $_GET['subj']; $sel_pg=""; }elseif(isset($_GET['page'])){ $sel_pg= $_GET['page']; $sel_subj = ""; } else { $sel_subj = ""; $sel_pg = ""; } $sel_subject = get_subject_by_id($sel_subj); $sel_page = get_page_by_id($sel_pg); ?> ------------------------------------------------------------------------------------------------------------------ ERROR(ON BROWSER): database query failed:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'LIMIT 1' at line 1
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.