SELECT COUNT(*) AS test FROM %s WHERE id = %d AND tmp_mail <> ''
What are %s
and %d
for?
%d – the argument is treated as an integer, and presented as a (signed) decimal number. %s – the argument is treated as and presented as a string. in your examples, $slug is a string and $this->id is an integer.
%s is a placeholder used in functions like sprintf. Check the manual for other possible placeholders. $sql = sprintf($sql, "Test"); This would replace %s with the string "Test".
php require_once 'config. php'; $id = $_GET["id"]; //ID OF THE CURRENT CONTACT $user = $_GET["user"]; //ID OF THE CURRENT USERS $query = mysql_query("SELECT name FROM contacts WHERE contact_id='". mysql_real_escape_string( $id ) .
Those are format symbols used e.g. by sprintf()
. Example:
<?php
$sql_template = "SELECT COUNT(*) AS test FROM %s WHERE id = %d AND tmp_mail <> ''";
$sql_real = sprintf($sql_template, 'sometable', 12345);
echo $sql_real;
?>
Output:
SELECT COUNT(*) AS test FROM sometable WHERE id = 12345 AND tmp_mail <> ''
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With