Jump to content

Recommended Posts

$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

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.