Results 1 to 3 of 3

Thread: what is wrong with this sql commands?

  1. #1
    Join Date
    Oct 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default what is wrong with this sql commands?

    Hi,

    I need to display data in atble format in pdf..when i am using FPDF and below slq command i receive the following error...


    The user will select the year, based on the year the data will be displayed in table format in pdf…I receive the below errors….

    Error: 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 '-45' group by `Date`, Node_ID' at line 1
    Query: -45' group by `Date`, Node_ID


    My codes are as bellows:

    $sql = "SELECT Node_ID ,Date, AVG(voltage),AVG(Temper), AVG(light),AVG(accel_x), AVG(accel_y), AVG(mag_x), AVG(mag_y), AVG(mic) from suhu where Date >'{$_POST['year']}-01-01' and Date <= '{$_POST['year']}-12-31'
    group by `Date`,Node_ID ";

    Do you know where is the error?



    The user will select the year,based on the selected year ,data will be displayed.before ths ,i receive the output,but whn i am trying convert the output into pdf format,i got errors...my full coding is belows:


    Code:
    <?php
    define('FPDF_FONTPATH','font/');
    require('mysql_table.php');
    
    class PDF extends PDF_MySQL_Table
    {
    function Header()
    {
    	//Title
    	$this->SetFont('Arial','',18);
    	$this->Cell(0,6,'Average data order by node ID and Date',0,1,'C');
    	$this->Ln(10);
    	//Ensure table header is output
    	parent::Header();
    }
    }
    
    //Connect to database
    mysql_connect('localhost','','');
    mysql_select_db('wsn');
    $pdf=new PDF();
    $pdf->Open();
    $pdf->AddPage();
    
    $pdf->Table('SELECT Node_ID as node, AVG(voltage) as volt,AVG(Temper) as temper, AVG(light) as light,AVG(accel_x) as accel_x, AVG(accel_y) as accel_y, AVG(mag_x) as mag_x, AVG(mag_y)as mag_y, AVG(mic) as mic,Date as date from suhu where Date >='.'\''.$_POST['year']-01-01 .'\''.' AND Date <='.'\''.$_POST['year']-12-31 .'\''.' group by `Date`, Node_ID');
    $pdf->AddPage();
    $pdf->Output();
    ?>

    Help me...


    thank you
    Last edited by 185; 10-24-2007 at 05:44 AM. Reason: wrong submitting

  2. #2
    Join Date
    Jul 2006
    Location
    just north of Boston, MA
    Posts
    1,806
    Thanks
    13
    Thanked 72 Times in 72 Posts

    Default

    $sql = "SELECT Node_ID ,Date, AVG(voltage),AVG(Temper), AVG(light),AVG(accel_x), AVG(accel_y), AVG(mag_x), AVG(mag_y), AVG(mic) from suhu where Date >'{$_POST['year']}-01-01' and Date <= '{$_POST['year']}-12-31'
    group by `Date`,Node_ID ";
    the error is most likely occuring at the () braces. are those the EXACT name that you have in the database? if so I would advise to change them as they can cause
    also your browser may not support the inline php quirk.

  3. #3
    Join Date
    Oct 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    thanks,

    I found the soultion ready....

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •