Note that there are some explanatory texts on larger screens.

plurals
  1. PORelate MySQL table to a specific value
    primarykey
    data
    text
    <p>What I want to do is quite simple: I want to recover data from a database, only where the ID of the first table (stored in session) is similar to the ID of the second table. My code is this one below. The only problem: the present code gives me the following error:</p> <p><strong>Query is invalid: 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 '.' at line 1</strong></p> <p>What am I doing wrong? Thanks for your help!</p> <pre><code>&lt;?php include "base.php"; ?&gt; &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1- strict.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt; &lt;?php //We check if the user is logged if(isset($_SESSION['Username'])) { ?&gt; &lt;?php //query $query = mysql_query("select TitreEvent, DescriptionEvent from users_event where ID = .$_SESSION [id].") or die ('Query is invalid: ' . mysql_error()); //write the results while ($row = mysql_fetch_array($query)) { echo $row['TitreEvent'] . " " . $row['DescriptionEvent'] . ""; // close the loop } ?&gt; &lt;div class="message"&gt;To access this page, you must be logged.&lt;br /&gt; &lt;a href="http://www.groupe90.webege.com/index.php"&gt;Log in&lt;/a&gt;&lt;/div&gt; &lt;?php } ?&gt; &lt;div class="foot"&gt;&lt;a href="&lt;?php echo $url_home; ?&gt;"&gt;Go Home&lt;/a&gt; - &lt;a href="http://www.webestools.com/"&gt;Webestools&lt;/a&gt;&lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload