I have error like this :
Error Number: 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 ‘-2, 2’ at line 4
SELECT * FROM (`user`) ORDER BY `no` ASC LIMIT -2, 2
Filename: D:\xampp\htdocs\cibootstrap\system\database\DB_driver.php
Line Number: 330
this error appear when i am add ” - ” in the pagination.
please help me.
Regards.
Web Developer
Controller
public function userLogin()
{
$this->load->view('header');
$this->load->view('userLogin');
if($_POST) {
$logindata=array(
'email'=>$_POST['email'],
'password'=>$_POST['password']
);
$login_confirm=$this->indexModel->loginManagement($logindata);
if ($login_confirm){
$this->load->view('header');
$this->load->view('user');
$this->load->view('footer');
}
}
$this->load->view('footer');
}
Model
function loginManagement($logindata){
$emailentered=element('email',$logindata);
$passwordentered=element('password',$logindata);
$passwordget = "SELECT password FROM `users` WHERE email=?";
$passwordgotdatabase=$this->db->query($passwordget,$emailentered);
$passworddecrypted=$this->encrypt->decode($passwordgotdatabase);
if ($passwordentered==$passworddecrypted) {
return TRUE;
}
else{
return FALSE;
}
}
But when login button press gives this error.
Fatal error: Call to undefined function element() in C:\xampp\htdocs\mySite\application\models\indexModel.php on line 40
Why is that?
]]>
i am using codeigniter with Smarty template engine and when i try to use pagenition it’s working but if Url is
http://localhost/cic/showq/viewv/8
and i add (’) or (-) i got error
after add
http://localhost/cic/showq/viewv/-8
error msg is
A Database Error Occurred
Error Number: 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 ‘-8, 4’ at line 3
SELECT * FROM (`topic`) LIMIT -8, 4
Filename: C:\xampp\htdocs\cic\system\database\DB_driver.php
Line Number: 330
My Code
controllers :
<?php
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/*
All Copyrights reserved.
Programmer information
Name : Fahad Salim Alrahbi
Location: Sultanate of Oman - Muscat
Email : Ra7bi@hotmail.com
Tel : +968 98985262
*/
class showq extends CI_Controller{
function viewv(){
$this->load->library('pagination');
$config['base_url'] = 'http://localhost/cic/showq/viewv';
$config['total_rows'] =$this->db->get('topic')->num_rows();
$config['per_page'] = 4;
$config['num_links']=5;
$config['first_link'] = 'Start';
$config['last_link'] = 'End';
$config['prev_link'] = 'Back';
$this->pagination->initialize($config);
$s=$this->db->get('topic',$config['per_page'],$this->uri->segment(3));
foreach($s->result() as $datar){
$row[]=$datar;
}
$this->parser->assign('pages',$this->pagination->create_links());
$this->parser->assign('row',$row);
$this->parser->parse('showq.tpl');
}
}
?>
Template showq.tpl
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<meta name="author" content="PHPDes7" />
<title>View data </title>
</head>
<body>
{section name='idx' loop=$row}
{$row[idx]->id}| {$row[idx]->topic} <br />
{/section}
<br />
{$pages}
</body>
</html>
MODEL:
$document_type = $this->input->post('specific_document_type');
$source_type = $this->input->post('specific_source_type');
$source = $this->input->post('specific_source');
$status = $this->input->post('specific_status');
$date = date('Y-m-d', strtotime($this->input->post('specific_date')));
if (!empty($document_type) && !empty($source_type) && !empty($source) && !empty($status) && !empty($date))
{
$query = $this
->db
->select("reference_number, transaction_type, document_type, source_type, source_name, source_location, subject_matter, status")
->select("DATE_FORMAT(datetime, '%m/%d/%Y-%h:%i %p') as datetime_added", FALSE)
->like('document_type', $document_type)
->like('source_type', $source_type)
->like('source_location', $source)
->like('status', $status)
->like('DATE(datetime)', $date)
->order_by('document_id', 'desc')
->get('documents');
return $query->result_array();
}
It’s not really worth creating a new table for only 5 rows, so I’m thinking a helper might be a the answer - some sort of associative array.
However, I’m a bit unsure how to construct the helper’s array - and completely clueless as to how to loop the results in the view file.
Any help, or any links to useful examples, is greatly appreciated! ![]()
<?php
class test extends CI_Controller{
public function form(){
$this->load->view('top');
$this->load->view('form');
$this->load->view('bottom');
}
}
View:
<form action="" method="POST">
<input name="field">
<input type="submit" value="OK">
</form>
<?php
if($this->input->post('field')) echo $this->input->post('field');
?>
When i trying to do it outside of framework it works fine. Im using CI 2.1.3.
]]>My question is, is insert_batch going to be sufficient, fast enough and bug free to such big amount of inserts? Or is it being used for less inserts per batch job. Is it safer or faster to make a custom query with multiple rows in one INSERT? Are there any limitation on the amount of rows that can be inserted with insert_batch?
Thank you in advance.
I will keep you informed of my progress with that for anyone that cares. ![]()
Sotiris
Here is the database config:
$db[‘default’][‘hostname’] = ‘DSN’;
$db[‘default’][‘username’] = ‘joe’;
$db[‘default’][‘password’] = ‘’;
$db[‘default’][‘database’] = ‘timing’;
$db[‘default’][‘dbdriver’] = ‘odbc’;
$db[‘default’][‘dbprefix’] = ‘’;
$db[‘default’][‘pconnect’] = TRUE;
$db[‘default’][‘db_debug’] = TRUE;
$db[‘default’][‘cache_on’] = FALSE;
$db[‘default’][‘cachedir’] = ‘’;
$db[‘default’][‘char_set’] = ‘utf8’;
$db[‘default’][‘dbcollat’] = ‘utf8_general_ci’;
$db[‘default’][‘swap_pre’] = ‘’;
$db[‘default’][‘autoinit’] = TRUE;
$db[‘default’][‘stricton’] = FALSE;
$db[‘my’][‘hostname’] = ‘127.0.0.1’;
$db[‘my’][‘username’] = ‘root’;
$db[‘my’][‘password’] = ‘’;
$db[‘my’][‘database’] = ‘timing’;
$db[‘my’][‘dbdriver’] = ‘mysql’;
$db[‘my’][‘dbprefix’] = ‘’;
$db[‘my’][‘pconnect’] = TRUE;
$db[‘my’][‘db_debug’] = TRUE;
$db[‘my’][‘cache_on’] = FALSE;
$db[‘my’][‘cachedir’] = ‘’;
$db[‘my’][‘char_set’] = ‘utf8’;
$db[‘my’][‘dbcollat’] = ‘utf8_general_ci’;
$db[‘my’][‘swap_pre’] = ‘’;
$db[‘my’][‘autoinit’] = TRUE;
$db[‘my’][‘stricton’] = FALSE;
here is the controller:
public function index()
{
$this->load->database();
$DB2 = $this->load->database(‘my’, TRUE);
$DB2->query(“TRUNCATE TABLE drivers”);
$query = “SELECT * FROM Drivers”;
$result = $this->db->query($query);
$DB2->insert_batch(‘drivers’, $result->result_array());
}
Any ideas why the database connection would fail over CLI but not the browser?
]]>Am working on RightNow Technologies. As if now i have been assinged to work on a widget i have done losts of changes now the major problem am facing now is Am not getting the child till nth level from my tree i have made.
The list basically shows the Products\Sub-Product\Sub-product (a)\Sub-product(1)\..........
I dunn know where is the problem exactly..
Please help me out..
Thanks & Regard
Gurpreet Singh
$route['en/quote/quote-response'] = 'quote/process_form/quote-response';
I need something like this but it doesn’t work:
$route['(en|cz|sp)/quote/quote-response'] = 'quote/process_form/quote-response';
I’m aware this is something simple, the answer might just be a missing symbol at the end of at the beginning? truth is I’m not so good at regex, I’ve tried different things to no avail :/
Thanks for your help.
]]>