473,770 Members | 2,143 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

php/sql problem

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_da te) 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">Every thing is ok, please
click <a href="./user_admin.php" >here</ato continue with registering
your business</font></p>';
}
else
{ // If it did not run OK.
echo '<br><br><p><fo nt color="red" size="+1">Busin ess 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">Pleas e try again.</font></p>';
}

mysql_close(); // Close the database connection.

} // End of the main Submit conditional.

Mar 15 '07 #1
2 1617
On Mar 15, 7:04 pm, styl...@gmail.c om wrote:
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_da te) 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">Every thing is ok, please
click <a href="./user_admin.php" >here</ato continue with registering
your business</font></p>';
}
else
{ // If it did not run OK.
echo '<br><br><p><fo nt color="red" size="+1">Busin ess 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">Pleas e try again.</font></p>';
}

mysql_close(); // Close the database connection.

} // End of the main Submit conditional.
Have you tried echoing the quer(y)/ies?

Mar 15 '07 #2
strawberry wrote:
On Mar 15, 7:04 pm, styl...@gmail.c om wrote:
>but when I entered the sql checking queries it went to hell.
I'm not clear what the problem is. Some error message or the results
just not registering in the database?

Have you tried echoing the quer(y)/ies?
Yes put lots of echos/prints to debug.

Mar 16 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

117
7266
by: Peter Olcott | last post by:
www.halting-problem.com
28
5222
by: Jon Davis | last post by:
If I have a class with a virtual method, and a child class that overrides the virtual method, and then I create an instance of the child class AS A base class... BaseClass bc = new ChildClass(); .... and then call the virtual method, why is it that the base class's method is called instead of the overridden method? How do I fix this if I don't know at runtime what the child class is? I'm using Activator.CreateInstance() to load the...
6
3812
by: Ammar | last post by:
Dear All, I'm facing a small problem. I have a portal web site, that contains articles, for each article, the end user can send a comment about the article. The problem is: I the comment length is more that 1249 bytes, then the progress bar of the browser will move too slow and then displaying that the page not found!!!! If the message is less than or equal to 1249 then no problem.
16
4929
by: Dany | last post by:
Our web service was working fine until we installed .net Framework 1.1 service pack 1. Uninstalling SP1 is not an option because our largest customer says service packs marked as "critical" by Microsoft must be installed on their servers. Now german Umlaute (ä, ü, ö) and quotes are returned incorrectly in SOAP fault responses. This can be easily verified: Implement the following in a web service method (just raises a SOAPException with a...
2
4556
by: Mike Collins | last post by:
I cannot get the correct drop down list value from a drop down I have on my web form. I get the initial value that was loaded in the list. It was asked by someone else what the autopostback was set to...it is set to false. Can someone show me what I am doing wrong and tell me the correct way? Thank you. In the page load event, I am doing the following:
0
9619
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9454
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10260
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10102
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8933
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6712
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5354
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3609
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2850
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.