c# - PHP script ,MySQL -
i'm writing php script. need client-server communication database.
i want count how many id's there in dtb, wrote this:
$id= mysql_real_escape_string($_get['id'], $db); $query = "select count( id ) scores id = $id;"; $result = mysql_query($query) or die('query failed: ' . mysql_error()); my php skills low... send in parameter id php script, , count id's in table. don't know how return result (integer) php c#;
my c# script
ienumerator idexist(int id) // ci id existuje { string post_url = getid + "&id=" + id; www hs_get = new www(post_url); yield return hs_get; if (hs_get.error != null) { } debug.log(hs_get.text); } thanks answers.
change code
$query = "select count( id ) scores id = $id;"; $result = mysql_query($query) or die('query failed: ' . mysql_error()); to
$query = "select count( id ) `total_ids` scores id = $id"; $result = mysql_query($query) or die('query failed: ' . mysql_error()); after need
$count = mysql_fetch_assoc($result); echo $count['total_ids']; // give result when writing query there no need use ; inside string unless writing multiple queries. btw not supported normal mysql.
other mysql_* no longer supported please check link mysqli_* database driver
Comments
Post a Comment