0

hello my Daniweb friend
i'm trying to get data from database where only users is connect so i user this code i get a errot on navigator
i got this errot on navigator :

Parse error: syntax error, unexpected '=', expecting ',' or ')' in /homepages/0/*/htdocs/domainname.com/*/*.php on line 145

this is the code

  <?php
$idSession_order = "0";
if (isset($_SESSION=['MM_Username'])) { // here is the line 145
  $idSession_order = $_SESSION=['MM_Username'];
}
mysql_select_db($database_marketbase, $marketbase);
$query_order = sprintf("SELECT * FROM commande WHERE commande.client=%s ORDER BY commande.`date` DESC", GetSQLValueString($idSession_order, "text"));
$order = mysql_query($query_order, $marketbase) or die(mysql_error());
$row_order = mysql_fetch_assoc($order);
$totalRows_order = mysql_num_rows($order);


mysql_select_db($database_marketbase, $marketbase);
$query_order = "SELECT * FROM commande WHERE client = ['MM_Username'] ORDER BY commande.`date` DESC";
$order = mysql_query($query_order, $marketbase) or die(mysql_error());
$row_order = mysql_fetch_assoc($order);
?>
3
Contributors
6
Replies
26
Views
4 Years
Discussion Span
Last Post by chrisschristou
1
 $idSession_order = $_SESSION=['MM_Username'];

should be

  $idSession_order = $_SESSION['MM_Username'];
0

after change the code on line 3 and 4 i delete the "=" i have this error

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 '['MM_Username'] ORDER BY commande.`date` DESC' at line 1

this is how the code look now

<?php
$idSession_order = "0";
if (isset($_SESSION['MM_Username'])) {
  $idSession_order = $_SESSION['MM_Username'];
}
mysql_select_db($database_marketbase, $marketbase);
$query_order = sprintf("SELECT * FROM commande WHERE commande.client=%s ORDER BY commande.`date` DESC", GetSQLValueString($idSession_order, "text"));
$order = mysql_query($query_order, $marketbase) or die(mysql_error());
$row_order = mysql_fetch_assoc($order);
$totalRows_order = mysql_num_rows($order);


mysql_select_db($database_marketbase, $marketbase);
$query_order = "SELECT * FROM commande WHERE client = ['MM_Username'] ORDER BY commande.`date` DESC";
$order = mysql_query($query_order, $marketbase) or die(mysql_error());
$row_order = mysql_fetch_assoc($order);
?>
1

You've forgotten to put $_SESSION in front of ['MM_Username'] within your query, and you have not encased the value within quotes. This should fix it:

$query_order = "SELECT * FROM commande WHERE client = '{$_SESSION['MM_Username']}' ORDER BY commande.`date` DESC";

Edited by tpunt

1

Suggest you use mysqli_* or PDO. mysql_* is going to die, slowly...

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.