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);
?>
Member Avatar for diafol
 $idSession_order = $_SESSION=['MM_Username'];

should be

  $idSession_order = $_SESSION['MM_Username'];

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);
?>

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";
Member Avatar for diafol

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

i dont know nothing on mysqli but i will star learn step by step

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.