Glese Posted December 10, 2011 Share Posted December 10, 2011 I am trying to create a simple edit script, which means the user contribution should be editable by simply clicking edit and having the contribution printed out in between the textarea tags, so it is inside the textarea. The problem I am having is that the assoc result is not set (I am checking with isset) in the following script, though I need the result to get the contribution and the description of it. Here's the script so far: <?php if((isset($user_id)) && isset($_GET['con_title'])) { $con_title = $_GET['con_title']; $connection = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); $query_get = 'SELECT contribution, description FROM con WHERE user_id = "{' . $user_id . '}" AND name = "{' . $con_title . '}"'; $query_run = mysqli_query($connection, $query_get) or mysqli_error($connection); $assoc = mysqli_fetch_assoc($query_run) or mysqli_error($connection); $edit_description = $assoc['description']; $edit_contribution = $assoc['contribution']; echo ' edit desc: ' . $edit_description; echo ' user id: ' . $user_id; echo ' con title: ' . $con_title; echo ' assoc: ' . $edit_contribution; mysqli_close($connection); } ?> When I print out the edit_description and the edit_contribution variable I get empty space. Any ideas and suggestions why it is not set? I am also not getting any error messages. Quote Link to comment https://forums.phpfreaks.com/topic/252908-mysqli_fetch_assoc-result-empty/ Share on other sites More sharing options...
Glese Posted December 10, 2011 Author Share Posted December 10, 2011 I found the mistake and solved the problem, the mistake was in the query itself. Quote Link to comment https://forums.phpfreaks.com/topic/252908-mysqli_fetch_assoc-result-empty/#findComment-1296638 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.