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.
Related
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
Im trying to run a query(UPDATE) inside a while loop like this:
<?php
session_start();
include("../DB/thedb.php");
$user = $_POST['u'];
$ruta = $_POST['r'];
$select_all_p_from_user = #mysql_query("SELECT * FROM publicaciones WHERE from_user_p = '$user' AND user = '$user'");
while($rows_all_user = #mysql_fetch_array($select_all_p_from_user)){
$update_from_user = $rows_all_user['from_user_p'];
$update_user = $rows_all_user['user'];
$update_foto = $ruta;
$update_nombre = $rows_all_user['nombre'];
$update_comentario = $rows_all_user['comentario'];
$update_time = $rows_all_user['time'];
$update_date = $rows_all_user['date'];
$update_p_photo = $rows_all_user['p_photo'];
$update_to_delete = $rows_all_user['to_delete'];
//Process to update selected ROW
// This is the line 55
$update_current_row = #mysql_query("UPDATE publicaciones SET from_user_p = '$update_from_user', user = '$update_user', foto = '$ruta', nombre = '$update_nombre', comentario = '$update_comentario', time = '$update_time', date = '$update_date', p_photo =
'$update_p_photo', to_delete = '$update_to_delete' WHERE from_user_p = '$user' AND user = '$user'") or die mysql_error(); // End of the line
}
?>
I'm getting the following error:
Parse error: syntax error, unexpected T_STRING on line 55
Try this,
or die (mysql_error());
instead of
or die mysql_error();
Also, in update query, for the time and date columns need to be wrapped with backticks since those are all reserved words.
`time` = '$update_time', `date` = '$update_date'
The error you're encountering is a parse error. It does not have anything to do with MySQL. The error is that you have not placed the argument for or die inside parenthesis.
A couple of BIG warnings:
You've not escaped the data you send to MySQL. If any of the fields you're fetching from the publicaciones table contains ' you'll get errors.
If a user logs in with $_POST['u'] = "' OR ''='" the select statement will result in every record.
Please look into http://no2.php.net/mysql_real_escape_string to fix your big security issues.
Illustrative comic:
(source: smashingmagazine.com)
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');
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 have got Parse error like this:
syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting
identifier (T_STRING) or variable (T_VARIABLE) or number
(T_NUM_STRING)
For below code line
<?php
$query = "SELECT license_parent_type_details.ParentTypeId,license_parent_type_details.TypeName FROM tenant.license_parent_type_details order by TypeName asc";
$result = mysql_query($query);
while($row_list = mysql_fetch_assoc( $result )) {
For below code line
echo '<option value="'.$row_list['ParentTypeId'].'">'<"'.($_POST['seltypes']==$row_list['ParentTypeId'] ? ' selected="selected" : '').'>'. $row_list['TypeName']."'</option>';
Here is the corrected version:
echo '<option value="', $row_list['ParentTypeId'], '"', ($_POST['seltypes']==$row_list['ParentTypeId'] ? ' selected="selected" ' : ''), '>', $row_list['TypeName'], '</option>';
Mistakes:
Missing single quote
Superfluous double quote
Finding the original position of those errors is left as an exercise for the reader.
Corrected Coded.
echo '<'. ($_POST['seltypes'] == $row_list['ParentTypeId']
? ' selected="selected" '
: '').'>'. $row_list['TypeName'] .'</option>';
You forgot a ' after selected="selected"
You had an extra " after $row_list['TypeName']
Visual Aid of above.
Here's a visual. Look for --> and <--. The one is brackets is the one I removed.
echo '<'. ($_POST['seltypes'] == $row_list['ParentTypeId']
? ' selected="selected" --> ' <--
: '').'>'. $row_list['TypeName'] --> (") <-- .'</option>';
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);