ecabrera Posted December 27, 2012 Share Posted December 27, 2012 <php if(isset($_GET['accept'])){ $theid = $_GET['accept']; require "../database/db.ini.php"; mysql_query("UPDATE `users` SET `active`='1' WHERE `id`='$theid'"); } ?> I cant seem to get this to update on the database any ideas why Link to comment https://forums.phpfreaks.com/topic/272422-update-no-updating/ Share on other sites More sharing options...
Maq Posted December 27, 2012 Share Posted December 27, 2012 Are you sure $theid has a value? If so, are there any errors? You should be catching exceptions from the mysql block. Link to comment https://forums.phpfreaks.com/topic/272422-update-no-updating/#findComment-1401595 Share on other sites More sharing options...
ecabrera Posted December 27, 2012 Author Share Posted December 27, 2012 <?php require "../database/db.ini.php"; $query = mysql_query("SELECT * FROM users WHERE active = 0"); while($rows = mysql_fetch_assoc($query)){ $id = $rows['id']; $name = $rows['name']; $email = $rows['email']; $phone = $rows['phone']; $reason = $rows['reason']; echo " <tr> <td>$name</td> <td>$email</td> <td>$phone</td> <td>$reason</td> <td><a href='?accept=$id'>Yes</a></td> <td><a href='?delete=$id'>Delete</a></td> </tr> "; } ?> it should be carrying a value Link to comment https://forums.phpfreaks.com/topic/272422-update-no-updating/#findComment-1401596 Share on other sites More sharing options...
Maq Posted December 27, 2012 Share Posted December 27, 2012 So you're not sure... Echo your update query and add some error checking: <php require "../database/db.ini.php"; if(isset($_GET['accept'])) { $theid = $_GET['accept']; $queryString = "UPDATE `users` SET `active`='1' WHERE `id`='$theid'"; echo $queryString; try { mysql_query("UPDATE `users` SET `active`='1' WHERE `id`='$theid'"); } catch(Exception $e) { echo $e->getMessage(); } } ?> Link to comment https://forums.phpfreaks.com/topic/272422-update-no-updating/#findComment-1401598 Share on other sites More sharing options...
ecabrera Posted December 27, 2012 Author Share Posted December 27, 2012 if i put this in the phpmyadmin sql UPDATE `users` SET `active`='1' WHERE `id`='7' it works but this means i may not be getting the value from the url Link to comment https://forums.phpfreaks.com/topic/272422-update-no-updating/#findComment-1401603 Share on other sites More sharing options...
Maq Posted December 27, 2012 Share Posted December 27, 2012 Did you even read my previous posts? Link to comment https://forums.phpfreaks.com/topic/272422-update-no-updating/#findComment-1401607 Share on other sites More sharing options...
ecabrera Posted December 27, 2012 Author Share Posted December 27, 2012 I fixed it it was correct the way i had it the only thing that was wrong is that i didnt put the code on top before <html><body> Link to comment https://forums.phpfreaks.com/topic/272422-update-no-updating/#findComment-1401610 Share on other sites More sharing options...
Maq Posted December 27, 2012 Share Posted December 27, 2012 I guess there was more pertinent code you didn't post. Link to comment https://forums.phpfreaks.com/topic/272422-update-no-updating/#findComment-1401618 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.