Reply to php/sql problem

Your name:

Reply:


Posted by styliek on 03/15/07 19:04

I know this might not be the right place for a sql problem but as im
writhing in php I thought someone might be able to help. Im creating a
registering page, where the scripts should first check if the business
name exists or not, if it doesnt exist it should bring the user to a
page to create the business details.
If the business name already exists it should check if it has been
activated already, again if it has been activated it will guide the
user out of the process, if not it will attach the user to the
business so they can login and modify the details.

Any help greatly appreciated, it worked fine when registering a user
to a business with out the checks, but when I entered the sql checking
queries it went to hell. The answer is probably obvious but i have
been staring at it so long i cant see whats right in front of my eyes


if ($fn && $ln && $e && $p) { // If everything's OK.

//check to see if the business name exists, if it doesnt then
allow the user to enter the business

$queryN = 'SELECT * FROM business_finder WHERE Name =$Name';
$resultN = mysql_query ($queryN) or trigger_error("Query:
$query\n<br />MySQL Error: " . mysql_error());

if (mysql_num_rows($resultN) == 0)
{ // the business name doesnt exists
echo'no such '.$Name.' here lets create it .';
}
else
{

// Make sure the business has not already been activated . non
active is an empty field in DB

$query = 'SELECT * FROM business_finder WHERE active =""';
$result = mysql_query ($query) or trigger_error("Query: $query
\n<br />MySQL Error: " . mysql_error());
if (mysql_num_rows($result) == 0) { // Available.

// Create the activation code.
$a = md5(uniqid(rand(), true));
// Add the user.
$query5 = "INSERT INTO users(email, pass, first_name,
last_name, active, registration_date) VALUES ('$e', '$p', '$fn',
'$ln', '$a', NOW() ) ";
$query1 = "UPDATE business_finder SET active='$a' WHERE Name =
'$Name'";
$result5 = mysql_query ($query5) or trigger_error("Query: $query
\n<br />MySQL Error: " . mysql_error());
$result1= mysql_query ($query1) or trigger_error("Query: $query
\n<br />MySQL Error: " . mysql_error());
if (mysql_affected_rows() == 1)
{ // If it ran OK.
echo '<p><font color="red" size="+1">Everything is ok, please
click <a href="./user_admin.php">here</a> to continue with registering
your business</font></p>';
}
else
{ // If it did not run OK.
echo '<br><br><p><font color="red" size="+1">Business not available.
We apologize for any inconvenience.</font></p>';
}
}//end available
else
{ // The business is registered.
echo '<p><font color="red" size="+1">That business has already been
registered/active. If you have forgotten your password, use the link
to have your password sent to you.</font></p>';
}
}

}
else
{ // If one of the data tests failed.
echo '<p><font color="red" size="+1">Please try again.</font></p>';
}

mysql_close(); // Close the database connection.

} // End of the main Submit conditional.

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация