EllisLab Community Forums 2013-06-19T21:46:05Z Copyright (c) 2013 ExpressionEngine tag:ellislab.com,2013:06:20 Error Number: 1064 when URL add ” - ” tag:ellislab.com,2013:forums/viewthread/.236189 2013-06-19T21:34:15Z 2013-06-19T21:46:05Z johanriyan Hello Guys,

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

]]>
Array element issue tag:ellislab.com,2013:forums/viewthread/.236174 2013-06-19T07:10:01Z 0 Xeroxeen I developed a user login function.

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 have a problem with pagenition pls help tag:ellislab.com,2012:forums/viewthread/.224479 2012-09-18T02:01:51Z 0 Fahad Alrahbi Hello ,all


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
]]>
Multiple search criteria tag:ellislab.com,2013:forums/viewthread/.236151 2013-06-18T03:34:38Z 0 ninjayan I am currently working on generating reports on the application I am developing. In my report (search form), there are several criterias (document_type, source_type, source, status and datetime). In my model, I am checking if the post variables from the form are empty before doing a query. My problem is, what if a user did not select a document_type or he only filled up 1 or 2 or 3 or 4 criteria? How can I make the search query? Thanks in advance.

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();
]]>
How to: create a helper (newbie) tag:ellislab.com,2013:forums/viewthread/.236186 2013-06-19T17:05:05Z 2013-06-19T17:06:23Z epseix I have a number of social networking links (about 5) in the footer of my site and I need to generate data for each of the anchor link’s TITLE and URL - and ICON (image).

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! smile

]]>
National chars - form input tag:ellislab.com,2013:forums/viewthread/.236181 2013-06-19T11:53:03Z 2013-06-19T11:54:37Z Stealth144 Hi, first of all im sorry for my bad english.
Does anyone have idea why my apache (2.2.22) crashes and restarts (nothing in logs) when i try to send some national characters like “ąę揯ĀÿĈĈÜ” using post method? Here is very simple code which cause the restarts.
Controller:

<?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.

]]>
insert_batch performance and limitations?? tag:ellislab.com,2013:forums/viewthread/.236178 2013-06-19T09:52:42Z 0 sotoz Hello everybody!
I’m writing an application that sends sms and I’m keeping (obviously) a copy of the message on the database. Till now, for prototyping purposes, I was inserting each message into the database one by one, but for bulk sending messages I will use insert_batch to fasten the whole process. I’m talking about 1000-5000, and maybe more, sms (inserts) per user request at one time.

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. smile
Sotiris

]]>
CLI and database connectivity. tag:ellislab.com,2013:forums/viewthread/.236177 2013-06-19T08:32:17Z 2013-06-19T08:33:41Z Joe_Archer I have a very simple script which I intended to to call via the command line.
It utilises 2 databases, one MySQL and one which is connected over ODBC. when calling the method via a browser, it functions exactly as intended. However when I attempt to call the method via the CLI I get an error returned:
Unable to connect to your database server using the provided settings.
Filename: DB_driver.php
Line Number: 124

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?

]]>
Tree Structure tag:ellislab.com,2013:forums/viewthread/.236175 2013-06-19T07:21:22Z 0 Gurpreet Hi all,

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

]]>
Routing multilingual pages tag:ellislab.com,2013:forums/viewthread/.236161 2013-06-18T09:08:26Z 0 thekrow I haven’t been able to find a similar situation in previous threads. I’m having trouble setting up my routes correctly. Basically what I need is, regardless of the language key entered I want my uri to be routed to what’s on the right hand side. If I just do this it works fine:

$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.

]]>