dominod Posted July 26, 2010 Share Posted July 26, 2010 Hi I want to check if a record already exist in MySQL database. If it does it shuld echo "It does exist" and if it dont it shuld do nothing.. Now I figured out the following code but it will not work or give me a error message : if(mysql_num_rows(mysql_query("SELECT * FROM engines WHERE keyword = '$GKeyword'"))){ echo "Its there"; } Can anyone help me? Link to comment https://forums.phpfreaks.com/topic/208903-checking-if-record-already-exists-in-mysql/ Share on other sites More sharing options...
FuThAr Posted July 26, 2010 Share Posted July 26, 2010 formally speaking, your code seems to be good. [...] $my_res = mysql_query("SELECT * FROM engines WHERE keyword = '$GKeyword'"); if ( is_resource($my_res) { $founded = mysql_num_rows($my_res); if( $founded == 1){ echo "founded one result, as expecteed" . "<br />"; } else { die("there is a problem: founded $founded entries"); } } else { die("no resource created"); } [...] Link to comment https://forums.phpfreaks.com/topic/208903-checking-if-record-already-exists-in-mysql/#findComment-1091210 Share on other sites More sharing options...
dominod Posted July 26, 2010 Author Share Posted July 26, 2010 Thanks Link to comment https://forums.phpfreaks.com/topic/208903-checking-if-record-already-exists-in-mysql/#findComment-1091231 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.