Jump to content

maazzarif

Members
  • Posts

    3
  • Joined

  • Last visited

maazzarif's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Sir i did as you said. and this is what i got 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 4 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 4
  2. @ denno020 I think it will make $subject_id as a string.Well i tried it and i got just a slight change in the error. Following is the error i got: 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 '1' at line 1 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 '1' at line 1
  3. 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.