Jump to content

multiple entry checks not working


Renlok

Recommended Posts

i have some check which are spose to run before entering data into a data base but none of them work if you run it it will just return with an error.

thanks in advance for any help.

[code]<?php
include("/home/renlok/public_html/roe/includes/header.php");
$guildname = $_POST['name'];
$guilddesc = $_POST['description'];
$guildprivate = $_POST['private'];
$guildlocation = $_POST['location'];
$guildowner = $row['username'];
$guildownerid = $row['id'];
$sqlname = mysql_query("SELECT * FROM guild WHERE guildname='$guildname'") or die("error1".mysql_error());
$namecheck = mysql_num_rows($sqlname) or die("error1".mysql_error());
if($namecheck > 0) {
echo "Name has already been taken";
exit;
}
$ownercheck = mysql_num_rows(mysql_query("SELECT * FROM guild WHERE owner='$guildowner'")) or die("error2".mysql_error());
if($ownercheck > 0) {
echo "You already own a guild has already been taken";
exit;
}
$guildcheck = mysql_num_rows(mysql_query("SELCET * FROM guildmembers WHERE userid='$guildownerid'")) or die("error3".mysql_error());
if($guildcheck > 0) {
echo "Your already part of a guild. You must first leave that guild before setting up a new one";
exit;
}
[/code]
Link to comment
Share on other sites

OK,  It's returning error1 because that's what you've told it to return...

[code]$sqlname = mysql_query("SELECT * FROM guild WHERE guildname='$guildname'") or die("error1".mysql_error());[/code]

It means that the call to mysql_query() is failing.  I'm assuming that header.php includes your database connect code.  If it does, can you post it here (but replace the username and password with asterisks).

Regards
Huggie
Link to comment
Share on other sites

yeah it urm here it is
[code]include("config.php");
// connect to the mysql server
$link = mysql_connect($server, $db_user, $db_pass)
or die ("Could not connect to mysql because ".mysql_error());

// select the database
mysql_select_db($database)
or die ("Could not select database because ".mysql_error());[/code]
Link to comment
Share on other sites

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.