Jump to content

Recommended Posts

Users on my website are able to submit a website. I need to create a check that ensures that website has not already been added by the current user (It does not matter if any other user adds the same website).

 

So for example, I need to check if the url they have submitted is equal to a url in the database that has the userid of that user.

 

Hope I am making sense

 

Here is a bit of pseudocode to kind of explain better what I mean:

 

if $url == for userid $userid:

echo "That site has already been submitted"

 

thanks

"SELECT [fields] WHERE userid = $userid AND url = $url";

 

Users on my website are able to submit a website. I need to create a check that ensures that website has not already been added by the current user (It does not matter if any other user adds the same website).

 

So for example, I need to check if the url they have submitted is equal to a url in the database that has the userid of that user.

 

Hope I am making sense

 

Here is a bit of pseudocode to kind of explain better what I mean:

 

if $url == for userid $userid:

echo "That site has already been submitted"

 

thanks

I am getting this error: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource

 

The code I have is:

 

//Check if URL is a Duplicate for current user
		$urlcheck = mysql_query("SELECT `url` FROM `websites` WHERE `userid` = $userid AND `url` = $url");
		$urlcount = mysql_num_rows($urlcheck);
		if ($urlcount==0)
		{
			echo "Your Site Has Been Submitted";
			$query2 = mysql_query("INSERT INTO websites VALUES ('','$userid','$url','$credits','','','','$title')");

		}
		else{
			echo "You have already submitted that site";
		}

 

I tried typing in:

if (!$result = mysql_query($query)) {
die(mysql_error());
}
$num_result = mysql_num_rows($result);

 

and it states that "Query was empty"

 

 

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.