Note that there are some explanatory texts on larger screens.

plurals
  1. POMysql get id from url
    text
    copied!<p>Hi im trying to do the simple task of grabbing an Id from the url and using that id to only show a specific article from my database. The Id is being grabbed from a link and is showing in the url - so im guessing my problem is with the WHERE part of my query. </p> <p>Here is the query i have made: </p> <pre><code>$dblink = mysqli_connect("localhost", "*", "*", "*") or die ("Error: Can't connect to the database.."); $id=mysql_real_escape_string($_GET['id']); $query = "SELECT * FROM articles WHERE articles_id = '" . $id . "'"; $largearticleresult = mysqli_query($dblink, $query) or die( "Request could not be made: " . mysqli_error($dblink)); </code></pre> <p>And here is how it is being echoed out in the html:</p> <pre><code>&lt;?php while($row = mysqli_fetch_assoc($largearticleresult)) { echo "&lt;all the html markup i have made&gt;"; } ?&gt; </code></pre> <p>Im thinking that i am doing something wrong around the <code>= '" . $id . "'";</code> part of my query and have been wondering about doing something to the likes of this:</p> <pre><code> $id=mysql_real_escape_string($_GET['id']); $largearticleresult = mysql_query("SELECT * FROM groups where id=".$id.";"); </code></pre> <p>but im simply stuck on this problem now :-) Sorry for the simple question.</p> <p>UPDATE:</p> <p>I have tried replacing the <code>'" . $id . "'</code> with a number - and this works and shows the article</p> <p>UPDATE 2:</p> <p>Now i have tried an if statement to see if the $id is even getting set.. which it seems not to be... </p>
 

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