Jump to content

{ } Characters In Sql


astralaaron

Recommended Posts


mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB");$page = intval($_GET

);if ($page < 1)  $page = 1;$per_page = 5;$start = (($page - 1) * $per_page);$sql="SELECT * FROM $tbl_name ORDER BY id DESC LIMIT {$start}, {$per_page}";// OREDER BY id DESC is order result by descending $result=mysql_query($sql);

This is obviously just part of the code, but the SQL is there. Someone from this forum wrote the code for me a few years back.It was really helpful, and works perfectly. But, I would like to understand the brackets in there.

Link to comment
Share on other sites

Those characters aren't part of the SQL, that's part of the PHP. If you print $sql you'll see what I mean. That's the way to embed a variable in a string in PHP.
ok, I see that now. but can you clarify for me why in this line:$sql="SELECT * FROM $tbl_name ORDER BY id DESC LIMIT {$start}, {$per_page}";$tble_name doesn't need this as well? variables usually display fine within a double quote string.Is it so that it is still looked at as an integer instead of a string?
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...