Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 9 years ago.
Improve this question
I am using FIND_IN_SET in where condition in Codeigniter, and I am facing the following error:
syntax error, unexpected 'FIND_IN_SET' (T_STRING)
How to solve it??
My model is the following:
function getTask($id, $is_master_admin)
{
$this->db->select('task.*, workspace.title as workspacetitle, GROUP_CONCAT(user.title ) AS usertitle,task.assigneduserid,user,id',FALSE);
$this->db->join(WORKSPACE , WORKSPACE . '.id = ' . TASK . '.workspaceid', 'inner');
$this->db->join(USER,USER . '.id = ' . TASK . '.assigneduserid', 'inner');
$this->db->from(TASK);
$this->db->group_by("task.id");
if (!$is_master_admin) {
$this->db->where FIND_IN_SET($id,"task.assigneduserid");
}
$this->db->where(TASK . '.tasktypeid', '1');
if ($query->num_rows() > 0) {
return $query->result();
} else {
return false;
}
}
Please help me to solve this, thank you.
$this->db->where FIND_IN_SET($id,"task.assigneduserid");
to
$this->db->where("FIND_IN_SET($id, task.assigneduserid)");
you forgot to open paranthesis.
You have to use find_in_set as below
$this->db->where("FIND_IN_SET('$id',task.assigneduserid) !=", 0);
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 7 years ago.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Improve this question
I am getting an error while running this code:
Fatal error: Call to a member function bindParam() on boolean in D:\xampp\htdocs\ipack\insertstatus.php on line 9
<?php
header('Access-Control-Allow-Origin: *');
include 'dbconnection.php';
$jobno = "AFE/0001/2015";
$jobseq = 0;
//to get INTJOBNO
$intjobno = "";
$data = $dbh->query("select INTJOBNO from PRTJOBHD where JOBNO = :jobno and JOBSEQ = :jobseq");
$data->bindParam(':jobno',$jobno,PDO::PARAM_STR);
$data->bindParam(':jobseq',$jobseq,PDO::PARAM_STR);
$data->execute();
foreach($data as $row) {
$intjobno = $row['INTJOBNO'];
echo $intjobno;
}
>
Have a look at this answer: PDO's query vs execute. You cannot bind parameters to PDO query, you need to use prepare instead.
header('Access-Control-Allow-Origin: *');
include 'dbconnection.php';
$jobno = "AFE/0001/2015";
$jobseq = 0;
//to get INTJOBNO
$intjobno = "";
$data = $dbh->prepare("select INTJOBNO from PRTJOBHD where JOBNO = :jobno and JOBSEQ = :jobseq");
$data->bindParam(':jobno',$jobno,PDO::PARAM_STR);
$data->bindParam(':jobseq',$jobseq,PDO::PARAM_STR);
$data->execute();
foreach($data as $row) {
$intjobno = $row['INTJOBNO'];
echo $intjobno;
}
PDO::query() returns a PDOStatement object, or FALSE on failure.
Source
It means your query has failed for some reason.
In this case you are using the wrong function to do what you want to do.
You need to prepare your statement since you want to bind two parameters in your query.
Use $dbh->prepare() instead of $dbh->query().
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
I have a big problem
public function get_setting($setting) {
// Prepate statement
$prepared = $this->prepare("SELECT `val` FROM `filex_settings` WHERE `setting`=?", 'get_setting');
$this->bind_param($prepared->bind_param('s', $setting), 'get_setting()');
$this->execute($prepared, 'get_setting()');
$result = $prepared->get_result();// < 5.3 PHP
$row = $result->fetch_object();
return $row->val;
}
Alternative please ?
You can try using fetch() with bind_result() instead.
public function get_setting($setting) {
// Prepate statement
$prepared = $this->prepare("SELECT `val` FROM `filex_settings` WHERE `setting`=?", 'get_setting');
$this->bind_param($prepared->bind_param('s', $setting), 'get_setting()');
$this->execute($prepared, 'get_setting()');
$this->bind_result($col_1,$col_2,..)
while($this->fetch())
{
return $col_n // the value which you want
}
}
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
I'm new here and i'm an absolute beginner.
Please help with that error:
Parse error: syntax error, unexpected T_BOOLEAN_OR in index.php on line 174
First line is line 174
( $sql = || print mysql_error( ) );
if (0 < mysql_num_rows( $sql )) {
while ($row = mysql_fetch_assoc( $sql )) {
#extract( $row );
$numview = ($viewer == 1 ? 'view' : 'views');
$numvideo = ($counter == 1 ? 'video' : 'videos');
$chanlink = 'index.php?channels=browse&channel_id=' . $uid;
if (!empty( $img )) {
$show_images = '<img src="thumbs/channel/' . $img . '" width="' . $chan_img_width . '" height="' . $chan_img_height . '" border"0">';
}
else {
$show_images = '';
}
The error is pretty clear...
unexpected T_BOOLEAN_OR in index.php on line 174
This is line 174:
( $sql = || print mysql_error( ) );
This is a boolean OR:
||
You can't assign a boolean OR operator to a variable, so this doesn't make sense (let alone the rest of the line):
$sql = ||
The PHP parser doesn't expect things that don't make sense, so it throws an error.
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 9 years ago.
Improve this question
Can someone help me to find what is wrong in the $secret line ?
$secret should give :
{"name":"JustAname","extra":"1","password":"ASD123","report":"http:\/\/website.com\/dev\/gamereport\/0001.php"}
here's the PHP code:
<?php
date_default_timezone_set('America/Montreal');
$name = 'JustAname';
$extra = '1';
$password = 'ASD123';
$reception = 'http:\/\/website.com\/dev\/gamereport.php';
// Code de génération de la base64
$secret = '{"name":"'.$name'","extra":"'.$extra'","password":"'.$password'","report":"'.$reception'"}';
$encodedSecret = base64_encode($secret);
$tournementLink = 'pvpnet://lol/customgame/joinorcreate/map1/pick6/team5/specALL/'.$encodedSecret;
echo $tournementLink;
?>
I got: Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in [...] on line 20
You're incorrectly concatenating strings, as #hobbs suggests. You're also using the undefined variable $Tournament, which I think should be $name. Try this:
$secret = '{"name":"' . $name . '","extra":"' . $extra . '","password":"' . $password . '","report":"' . $reception . '"}';
On a side note, a slightly nicer way to create JSON in PHP is to use an array and json_encode():
$secret = json_encode(array(
'name' => $name,
'extra' => $extra,
'password' => $password,
'report' => $reception));
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 9 years ago.
Improve this question
I need to format Date time to specific date format using php.
Now date format
2014-02-10 09:32:24
I need format
2014/02/10
error is :Parse error: syntax error, unexpected '$ModifiedDate' (T_VARIABLE), expecting ',' or ';' in ................. line
Here i tried like this
<?php
include(config.php);
$sql = "SELECT Id,Title,description,Image,Category,ModifiedDate from News WHERE ISActive=true";
$query = mysql_query($sql);
if(mysql_num_rows($query)>0){
while($test = mysql_fetch_array($query))
{
$Mod = $test['ModifiedDate'];
$ModifiedDate = date_format($Mod, 'yyyy/MM/dd');
echo"<td><font color='black'>"$ModifiedDate"</font></td>";
}
}
else
{
echo "No Records";
}
?>
You forgot to concatenate the variable. Do like this
echo"<td><font color='black'>".$ModifiedDate."</font></td>";
//^----- ^----- Add those dots !
Use below format,
date_format($Mod, 'YY/MM/DD');
try this code:
$ModifiedDate = date_format($Mod, 'Y/m/d');