kevinkhan Posted February 23, 2010 Share Posted February 23, 2010 I need to modify this query "INSERT INTO `bebo` VALUES(null, '$user', 'No Comment Posted') so that it will only insert $user if it not already there... Does any one know how i can do this? Thanks Link to comment https://forums.phpfreaks.com/topic/193123-need-a-simple-sql-query/ Share on other sites More sharing options...
lovelyvik293 Posted February 23, 2010 Share Posted February 23, 2010 first select the row where you have to insert the $user.And then insert it. Link to comment https://forums.phpfreaks.com/topic/193123-need-a-simple-sql-query/#findComment-1017019 Share on other sites More sharing options...
scarhand Posted February 23, 2010 Share Posted February 23, 2010 <?php $usercount = mysql_result(mysql_query("select count(*) from users where username='$user'"), 0); if ($usercount == 0) // insert using another mysql query ?> Link to comment https://forums.phpfreaks.com/topic/193123-need-a-simple-sql-query/#findComment-1017043 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.