php - Custom Forum function not returning correct ID? -
i decided use forum made year ago website working on now, , works (after revisions) except after creating topic, not take new post. here functions supposed accomplish that:
function new_post($name) { $sqlpost = "select `id` `forum_question` `name`='$name' order `datetime` asc limit 1"; $mysqlpost = mysql_query($sqlpost); return $mysqlpost; }
and here how apply that: <a href="view_topic.php?id=<?php echo new_post($name); ?>">view post</a>
(keep in mind $name
defined earlier in document)
this url takes me to, after creating post: http://localhost/nu-bio/view_topic.php?id=resource%20id%20#10
thanks reading , hope can help. also: know should using mysqli. updating once next few things want finish done~
return values result_query()
for select, show, describe, explain , other statements returning resultset, mysql_query() returns resource on success, or false on error.
<?php function new_post($name) { $id = 0; $sqlpost = "select id forum_question name='".$name."' order datetime asc limit 1"; $mysqlpost = mysql_query($sqlpost); if (!$mysqlpost) { die('invalid query: ' . mysql_error()); } else { $array = mysql_fetch_assoc($mysqlpost); $id = $array['id']; } return $id; } ?>
Comments
Post a Comment