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
https://forums.phpfreaks.com/topic/34390-multiple-entry-checks-not-working/
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
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]

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.