Jump to content

Recommended Posts

Hi all, was hopeing someone knwos how to help me get past this.

 

    * MySQL server version : MySQL  5.0.89-community

    * the raw MySQL statement :

 

A Mysql error has occurred while running the script:

 

    * The query you are trying to run is invalid

    * Mysql Error Output: 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 'order by theorder' at line 1

    * SQL Query: SELECT * FROM D3_boxes_scroller WHERE uid = order by theorder

 

 

 

 

-- phpMyAdmin SQL Dump

-- version 3.2.4

-- http://www.phpmyadmin.net

--

-- Machine: localhost

-- Genereertijd: 08 Mar 2010 om 07:09

-- Serverversie: 5.0.89

-- PHP-Versie: 5.2.9

 

SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";

 

 

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;

/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;

/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;

/*!40101 SET NAMES utf8 */;

 

--

-- Database: `bendemic_DB`

--

 

-- --------------------------------------------------------

 

--

-- Tabelstructuur voor tabel `D3_boxes_scroller`

--

 

CREATE TABLE IF NOT EXISTS `D3_boxes_scroller` (

  `id` int(11) NOT NULL auto_increment,

  `uid` int(11) NOT NULL default '0',

  `picture` varchar(255) default NULL,

  `show` tinyint(2) default '0',

  `theorder` int(20) NOT NULL default '0',

  `link` varchar(200) NOT NULL,

  PRIMARY KEY  (`id`)

) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ;

 

--

-- Gegevens worden uitgevoerd voor tabel `D3_boxes_scroller`

--

 

INSERT INTO `D3_boxes_scroller` (`id`, `uid`, `picture`, `show`, `theorder`, `link`) VALUES

(1, 0, NULL, 0, 0, ''),

(2, 0, NULL, 0, 1, ''),

(3, 0, NULL, 0, 0, ''),

(4, 0, NULL, 0, 1, '');

 

Link to comment
https://forums.phpfreaks.com/topic/194488-mysql-error/
Share on other sites

The relevant php code that is producing the query would have been nice to see (i.e you are asking someone else to tell you what is wrong with your code without ever seeing your code.)

 

Best guess is you have a php variable that is supposed to supply the uid = _____ value, but the variable is either empty or not set at all and your validation logic did not test if it had a value before putting it into and attempting to execute the query.

 

 

Link to comment
https://forums.phpfreaks.com/topic/194488-mysql-error/#findComment-1022964
Share on other sites

Hi, this is the php :

 

 

<?

session_start();

define ('IN_ADMIN', 1);

include_once ('../includes/global.php');

 

if ($session->value('adminarea')!='Active')

{

header_redirect('login.php');

}

else

{

include_once ('header.php');

 

$msg_changes_saved = '<p align="center" class="contentfont">' . AMSG_CHANGES_SAVED . '</p>';

 

if (isset($_POST['savesettsok']))

{

 

 

$uploaddir = '../scroller/';

 

for ($i=0;$i<count($_FILES['userfile']);$i++) {

$uploadfile = $uploaddir . basename($_FILES['userfile']['name'][$i]);

 

if (move_uploaded_file($_FILES['userfile']['tmp_name'][$i], $uploadfile)) {

mysql_query("INSERT INTO D3_boxes_scroller (uid, picture) VALUES (".$_REQUEST["qid"].",'".$_FILES['userfile']['name'][$i]."')")or die(mysql_error());

}

}

 

for ($i=0;$i<count($_POST['theorder']);$i++) {

$updateQuestion[$i] = mysql_query("

UPDATE D3_boxes_scroller SET

theorder=".$_POST['theorder'][$i].",

link='".$_POST['link'][$i]."'

WHERE id='".$_POST['id'][$i]."'") or die(mysql_error());

}

 

if (count($_POST['delete'])>0) {

for ($i=0;$i<count($_POST['delete']);$i++) {

$deleteQuestion[$i] = mysql_query("DELETE FROM D3_boxes_scroller WHERE id='".$_POST['delete'][$i]."'");

}

}

}

 

 

$getad = $db->query("SELECT * FROM D3_boxes_scroller WHERE uid =".$qid." order by theorder");

$t=0;

while ($row = $db->fetch_array($getad))

{

$background = ($counter++%2) ? 'c1' : 'c2';

 

$item_durations_page_content .="<input type=\"hidden\" name=\"id[]\" value=\"".$row["id"]."\"><tr class=\"".$background."\"> <td width=\"100px\"><img src=\"../thumbnail.php?pic=scroller/".$row["picture"]."&w=100&sq=Y\" name=\"caption[]\"/><br /></td><td><input style=\"width:99%\" name=\"link[]\" type=\"text\" id=\"link[]\" value=\"".$row['link']."\" size=\"50\" /></td><td align=\"center\"><input style=\"width:99%\" name=\"theorder[]\" type=\"text\" id=\"theorder[]\" value=\"".$row['theorder']."\" size=\"50\" /></td><td align=\"center\"><input type=\"checkbox\" name=\"delete[]\" id=\"delete[".$row['id']."]\" value=\"".$row['id']."\"></td></tr>";

}

 

$template->set('item_durations_page_content', $item_durations_page_content);

 

$template_output .= $template->process('D3_add_banners.tpl.php');

include_once ('footer.php');

echo $template_output;

}

?>

Link to comment
https://forums.phpfreaks.com/topic/194488-mysql-error/#findComment-1022965
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.