开发者

SQL request in PHP page

开发者 https://www.devze.com 2023-03-30 22:33 出处:网络
I would like to do a SQL-request within my php-page. Currently, the code looks like: $activiteitname = mysql_query(\"SELECT开发者_JAVA百科 titel FROM tblLeidingAgenda WHERE id=\'{$_POST[\'id\']}\'\")

I would like to do a SQL-request within my php-page.

Currently, the code looks like:

$activiteitname = mysql_query("SELECT开发者_JAVA百科 titel FROM tblLeidingAgenda WHERE id='{$_POST['id']}'");
$message = 'Herinnering!';
mail('me@test.be', 'Reminder: '.$activiteitname.'', $message);

But on execution, I get an Resource id #15 error...


When MySQL returns data to PHP, the information is put into a variable called a resource special data type. When you attempt to treat this as if it were a string data type, all that it 'reveals' is the ResouceID


mysql_query returns a handler but you can retirve that result with mysql_result

<?php $activiteitname = mysql_result(mysql_query("SELECT titel
                                            FROM tblLeidingAgenda 
                                            WHERE id='".mysql_real_escape_string($_POST['id'])."'"),0,'titel');
?>


try

$activiteitname = mysql_query("SELECT titel FROM tblLeidingAgenda WHERE id='{$_POST['id']}'");

var_dump(mysql_fetch_array($activiteitname));
0

精彩评论

暂无评论...
验证码 换一张
取 消