1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Database error help.

Discussion in 'MySQL' started by Zoti Media Group, Dec 13, 2013.

  1. #1
    Hello everyone.
    Am getting this error:
    SQL/DB 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 '-1, 1' at line 1
    Query:"SELECT id, start FROM dates ORDER BY id LIMIT -1, 1"
    Code (markup):


    And the script for this:
    <?php
        // Include Configutarion
        include('../include/config.php');
       
        // Check Logged In
        if (!isset($_SESSION['LoginId'])) {
            header('Location: ../index.php');
            exit;
        }
       
        // Get Settings
        $site_settings = $DB->row("SELECT sitename FROM settings");
        $site_title = $site_settings->sitename;
       
        // Variables
        $userid = $_SESSION['LoginId'];
        $adid = $_GET['id'];
       
        // Check Permission
        $adcheck = $DB->row("SELECT id FROM ads WHERE user='$userid' AND id='$adid'");
        if ($adcheck) {
            $ad = $DB->row("SELECT websites.title, ads.image, ads.linkurl, ads.alttext, blocks.size, blocks.custom1, blocks.custom2, blocks.approve FROM ads LEFT JOIN blocks ON blocks.id = ads.block LEFT JOIN websites ON blocks.website = websites.id WHERE ads.id='$adid'");
            // Determine Ad Size
            if ($ad->size == 0) {
                $width = $ad->custom1;
                $height = $ad->custom2;
            } else {   
                $adsize = $ad->size;
                $getsize = $DB->row("SELECT width, height FROM adsizes WHERE id='$adsize'");
                if ($getsize) {
                    $width = $getsize->width;
                    $height = $getsize->height;
                } else {
                    $width = 0;
                    $height = 0;
                }
            }           
        } else {
            header('Location: myads.php');
            exit;
        }
    ?>
    <?php include("../doctype.php"); ?>
    
    <head>
        <title><? echo $site_title; ?> - Ad Stats for <?php echo $ad->title; ?></title>
        <?php include("../meta.php"); ?>
        <script src="../include/js/highcharts.js" type="text/javascript"></script>
        <script type="text/javascript">   
               
            $(document).ready(function() {       
                var Chart; // globally available
                // Options
                var options = {
                    credits: {
                        enabled: false
                    },
                    chart: {
                        renderTo: 'StatsChart',
                        defaultSeriesType: 'area',
                        backgroundColor: '#f9f9f9',
                        height: 250
                    },
                    colors: [
                        '#32c8fa',
                        '#2ba5cc'
                    ],
                    title: {
                        text: 'Today'
                    },
                    xAxis: {
                        type: 'datetime',
                        tickInterval: 24 * 3600 * 1000,
                        labels: {
                            align: 'center',
                            y: 18
                        }
                    },               
                    yAxis: {
                        title: null,
                        allowDecimals: false
                    },
                    tooltip: {
                        shared: true
                    },
                    series: [{
                        name: 'Views'               
                    }, {
                        name: 'Clicks'           
                    }]
                }
               
                // Get AdId
                var AdId = $(".adid").attr("value");   
               
                // Function: Go Through Options
              function changeFrame(type) {
                    // Get Data
                    jQuery.get('actions/action_stats.php?id='+AdId+'&type='+type, null, function(data2) {
                        var lines = [];
                        var listen = false;
                        var Views = [];   
                        var Clicks = [];   
                        var data;
                       
                        data2 = data2.split(/\n/g);
                       
                        jQuery.each(data2, function(index, value) {
                            value = value.split("||");
                            var newDate = new Date();
                            newDate.setTime(value[0]*1000 - (3600000*5));
                            newDate = Date.parse(newDate);
                            date = newDate;
                            if(date) {       
                                Views.push([
                                    date,
                                    parseInt(value[1], 10)
                                ]);
                                Clicks.push([
                                    date,
                                    parseInt(value[2], 10)
                                ]);
                            }
                        });
                       
                        options.series[0].data = Views;
                        options.series[1].data = Clicks;
                        if (options.series[0].data.length > 7) {
                            options.xAxis.tickInterval = null;
                        } else {
                            options.xAxis.tickInterval = 24 * 3600 * 1000;
                        }
                       
                        // Change Chart Title
                        if (type == 0) {
                            options.title.text = "";
                        } else if (type == 1) {
                            options.title.text = "";
                        } else if (type == 2) {
                            options.title.text = "";
                        }
                                   
                        Chart = new Highcharts.Chart(options);
                    });
                    // Change Text Stats
                    jQuery.get('actions/action_statstext.php?id='+AdId+'&type='+type, null, function(data3) {
                        $("#StatsText").html(data3);
                    });
              }
             
              // Start With Type 0
              changeFrame(0);
             
              // Change Type
              $(".date").change(function() {
                    changeFrame($(this).val());
              });
         
            }); 
         
        </script>
    </head>
    
    <body id="myads">
    
    <div id="whole">
    <div id="top"></div>
        <div id="header">
       
            <div class="inner"><?php include("../header.php"); ?></div>
           
        </div>
       
        <div id="nav">
       
            <div id="nav2"><?php include("../user/usernav.php"); ?></div>
       
        </div>
       
        <div id="main">
       
            <div id="main2">
           
                <div id="box2"><h1>Ad Stats for <?php echo $ad->title; ?></h1></div>
               
                <input type='hidden' class='adid' value='<?php echo $adid; ?>' />
                <select class="date">
                <option name="This Week" value='0'>This Week</option>
                <option name="This Week" value='1'>Last 30 Days</option>
                <option name="This Week" value='2'>All Time</option>
                </select>
           
                <div id="clear"></div>
           
                <br><br>
           
                <div id='StatsChart'></div>
                <div id='yw1'></div>
                <div id='StatsText'>
               
                </div>
            </div>
           
        </div>
       
        <div id="footer">
       
            <div id="footer2"><?php include("../footer.php"); ?></div>
       
        </div>
       
    </div>
       
    </body>
    </html>
    PHP:

    Thank you for the help!
     
    Zoti Media Group, Dec 13, 2013 IP
  2. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #2
    Try changing the LIMIT -1, 1 to LIMIT 1 - and besides, the query you're getting an error on is not in the script you provided, as far as I can see?
     
    PoPSiCLe, Dec 13, 2013 IP
    khodem and sarahk like this.
  3. khodem

    khodem Well-Known Member

    Messages:
    206
    Likes Received:
    8
    Best Answers:
    3
    Trophy Points:
    120
    #3
    provide the orginal query as the error you are getting is not in any query in this script you provided maybe that query is somewhere in your included files? possibly
     
    khodem, Dec 18, 2013 IP