1064 - You have an error in your SQL syntax помогите исправить

manaz
На сайте с 13.12.2013
Offline
61
1081

добрый день, есть скрипт который заносит значения в бдя, сейчас выдает ошибку

1064 - 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 '.$this->article->id.'";}','0','1ebbb6aeb6f88e48bfa16269fc830b5d','d7c3743effea45' at line 1 SQL=INSERT INTO art3_payforcontent (`id`, `email`, `articleids`, `payment_amount`, `hashtoemail`, `hashtologin`, `url`, `datetime`, `timelimit`, `paidstatus`) VALUES ('','8@yandex.ru','a:1:{i:0;s:22:"'.$this->article->id.'";}','0','1ebbb6aeb6f88e48bfa16269fc830b5d','d7c3743effea4522f2f441c10ed48072','http://сайт','2014-07-23 11:36:31','1',0)

сам скрипт

<?php

/**
* @version $Id: user.php 14401 2010-01-26 14:10:00Z louis $
* @package Joomla
* @subpackage User
* @copyright Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved.
* @license GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant to the
* GNU General Public License, and as distributed it includes or is derivative
* of works licensed under the GNU General Public License or other free or open
* source software licenses. See COPYRIGHT.php for copyright notices and
* details.
*/

// Check to ensure this file is included in Joomla!
defined( '_JEXEC' ) or die( 'Restricted access' );

jimport('joomla.application.component.model');

/**
* User Component User Model
*
* @package Joomla
* @subpackage User
* @since 1.5
*/
class UsersModelPayforcontent extends JModelLegacy
{
/**
* User id
*
* @var int
*/
var $_id = null;

/**
* Constructor
*
* @since 1.5
*/
function __construct()
{
parent::__construct();

$id = JRequest::getVar('id', 0, '', 'int');
$this->setId($id);
}

function setId($id)
{
// Set weblink id and wipe data
$this->_id = $id;
$this->_data = null;
}

function getRegUser($id){
$db =& JFactory::getDBO();
$this->setId($id);

$query = 'SELECT * FROM #__payforcontent WHERE id='.$id;
$db->setQuery( $query );
$result = $db->loadObject();

return $result;
}
function getUserByHash($hash){
$db =& JFactory::getDBO();


$query = "SELECT * FROM #__payforcontent WHERE hashtoemail='".$hash."'";
$db->setQuery( $query );
$result = $db->loadObject();

$this->setId($result->id);

return $result;
}

function updateField($field,$value){
$db =& JFactory::getDBO();

$query = "UPDATE #__payforcontent SET " . $field . "=" . $value . " WHERE id=".$this->_id;
$db->setQuery( $query );
$result = $db->query();
if(!$result){
print_r($db->stderr());
}
return $result;
}
function store($data)
{
$db =& JFactory::getDBO();

$query = 'INSERT INTO #__payforcontent (`id`, `email`, `articleids`, `payment_amount`, `hashtoemail`, `hashtologin`, `url`, `datetime`, `timelimit`, `paidstatus`) VALUES ';
$query .= "('','".implode("','",$data)."',0)";

$db->setQuery( $query );
$result = $db->query();
if($result){
$result = $db->insertid();
}else{
print_r($db->stderr());
}
return $result;
}

}
?>

Я так понимаю что из-за кавычек, но не как не могу понять где именно исправить эти кавычки в запросе...

ДП
На сайте с 23.11.2009
Offline
203
#1

У вас в запрос попал код php - $this->article->id

Такого быть не должно, если ошибка именно в этом классе - то ищите вызовы метода UsersModelPayforcontent::store() - судя по ошибке ему приходит неправильный параметр (одно из значений в массиве $data) - $this->article->id, а должен числовой айдишник.

Авторизуйтесь или зарегистрируйтесь, чтобы оставить комментарий