Foser Posted August 16, 2007 Share Posted August 16, 2007 $item_name = $_POST['item_name']; $item_author_id = $_SESSION['id']; $item_location = $_POST['item_location']; $item_description = $_POST['item_description']; $item_type = $_POST['item_types']; $extra_notes = $_POST['item_notes']; $check_name = mysql_query("SELECT * WHERE item_name = '{$item_name}'"); if (mysql_num_rows($check_name) == 0){... error Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\WAMP\www\PP\itemprogram\create_item.php on line 14 trying to make it so it will check if that item name has already been used ot not, if not it will do the if and if no it will do the else. Link to comment https://forums.phpfreaks.com/topic/65213-solved-mysql_num_rows-issues/ Share on other sites More sharing options...
gurroa Posted August 16, 2007 Share Posted August 16, 2007 You have error in the query. select * FROM TABLE where item_name = .... Link to comment https://forums.phpfreaks.com/topic/65213-solved-mysql_num_rows-issues/#findComment-325633 Share on other sites More sharing options...
Foser Posted August 16, 2007 Author Share Posted August 16, 2007 I changed that but the if statement is still going when i have two the same. Link to comment https://forums.phpfreaks.com/topic/65213-solved-mysql_num_rows-issues/#findComment-325635 Share on other sites More sharing options...
tibberous Posted August 16, 2007 Share Posted August 16, 2007 $check_name = mysql_query("SELECT * WHERE item_name = '{$_POST[$item_name]}'");? Everyone needs to turn there register globals back on. Link to comment https://forums.phpfreaks.com/topic/65213-solved-mysql_num_rows-issues/#findComment-325637 Share on other sites More sharing options...
Foser Posted August 16, 2007 Author Share Posted August 16, 2007 $check_name = mysql_query("SELECT * WHERE item_name = '{$_POST[$item_name]}'");? Everyone needs to turn there register globals back on. still not working ??? Link to comment https://forums.phpfreaks.com/topic/65213-solved-mysql_num_rows-issues/#findComment-325638 Share on other sites More sharing options...
Styles2304 Posted August 16, 2007 Share Posted August 16, 2007 For security reasons I store my database connect and all that stuff in an external file and then define the database name as $link. So if you don't do that, change "$link" to the name of your database. so . . . change it to this: $check_name = "SELECT * FROM tablename WHERE item_name = '" . $item_name . "'"; $result = mysql_query($check_name,$link) or die(mysql_error()); if (mysql_num_rows($result) == 1) { } Enter what you're checking for between the {} after the if statement. That should do it. Link to comment https://forums.phpfreaks.com/topic/65213-solved-mysql_num_rows-issues/#findComment-325641 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.