shadowx
Aug 29 2006, 11:55 AM
| | Hi all
Im having problems with this peice of code:
CODE $result = mysql_query("SELECT 'ID' FROM 'login' WHERE username=$dusername",$link); if($result != NULL){ //username DOES exsist so they cant have it! include("scripts/userexsists.php");
The idea is, this query will take the variable $dusername which is the usernbame that a user wants to have, and check it in the database to see if it already exsists. and depending on whether it does or not it will include one of two different scripts.
The problem I'm having is that the variable $result seems to be emtpy. Does anyone know why? Its really annoying! |
Reply
leiaah
Aug 29 2006, 02:04 PM
Try the code below. I've modified it since there's some minor problems with the use of quotation marks and mysql is strict with closed and unclosed strings so we have to be careful. You can use a variable first to store your string query so you can see if all quotation marks are closed (with beginning and ending quotes) but it's just optional. I hope this helps. CODE String $qry = "SELECT ID FROM login WHERE username='" .$dusername. "'"; $result = mysql_query($qry); if($result != NULL){ //username DOES exsist so they cant have it! include("scripts/userexsists.php");
Reply
Chatz
Aug 29 2006, 05:51 PM
QUOTE(leiaah @ Aug 29 2006, 02:04 PM)  Try the code below. I've modified it since there's some minor problems with the use of quotation marks and mysql is strict with closed and unclosed strings so we have to be careful. You can use a variable first to store your string query so you can see if all quotation marks are closed (with beginning and ending quotes) but it's just optional. I hope this helps. CODE String $qry = "SELECT ID FROM login WHERE username='" .$dusername. "'"; $result = mysql_query($qry); if($result != NULL){ //username DOES exsist so they cant have it! include("scripts/userexsists.php");
That code should work.If not then maybe you should go over the all script to make sure you didn't leave out anything example a symbol that could be interfering with that section of the script.
Reply
shadowx
Aug 30 2006, 03:12 PM
Thanks leiaah. Ive always had trouble with select where queries but never knew why, but now i do know why! That code worked perfectly although i had to remove "String" Just before the variable $qry. Not sure why i had to do that but it worked perfectly once i did  Thanks.
Reply
electron
Aug 31 2006, 03:08 AM
As this is a username query be careful of MySQL injections. People could hack it due to that. Use htmlentities() to save your script of being vulnerable.
Reply
masterio
Sep 15 2006, 07:11 AM
Other function that usefull to sanitize user input before being executed by MySQL is using addslashes() sunction. but now most server is add escaping character automatically.
Reply
Similar Topics
Keywords : wrong, php, sql, select, statement
- Why Is The Shoutbox Time Wrong?
(10)
What's Wrong With The Dodgers These Days?
(1) I mean, what the heck? They were doing so well, sweeping the Phillies and going 2 out of 3 against
the Brewers, then they lost 2 out of 3 against the Rockies, then It all went downhill after they got
Maddux. Since they got Maddux from the Madres (Padres), they were blasted by the Phillies 25-5 I
think over the series, and now they lose against the nationals. I think they are like 0-5 since
getting Maddux. Is it a curse or something cause the Dodgers suddenly ain't producing runs, and
now they are 3.5 games behind the Diamondbacks. I don't like where this is headi....
Select All Rows With Same Name
how to do this ??? (7) I have a table called albums it contains the following: QUOTE albumid bandname albumname the
following data is in it CODE albumid bandname albumname 0 Grendel test
album 1 1 Grendel test album 2 2 VNV test album 1
3 VNV test album 2 Now I want to display the albumname from only grendel or
vnv or anyother band who comes in the table. How can I do this ??? thanks in advance....
Timer
is it possible in vb 6.0 to make a while statement which executes ever (6) Is it possible in vb 6.0 to make a while statement which executes every 10 minutes? Any ideas?....
Best Browser To Desighn Your Site To
not much of a question but more like a statement (16) well since i started web desighning i've always used internet explore (why?) well when i first
tried FF2, i wasn't a "web-designer" then so i didn't care much about css and htlm stuff, i
din't like it and one of the reason was beacause a couple of the sites i visited wasnt firefox
compatible. but anyways recently i was desighning a site for this community. so like two weeks ago i
downloaded FF3 for testing purposes. in IE the site looked great but what i found was that in
firefox the site was horible, as bad as they could come. so since firefox was better....
Configuring The Httpd.conf And Php.ini
Where did I go wrong? (7) Hey guys! I installed Apache2.2.x on my machine running on XP SP3 and it worked. When I tried
to install php5 from a .msi I then got " Error trying to access httpd.conf file. You will need to
manually configure the web server. " This is a re-installation on a machine that had php5, Apache2.2
and MySQL, all running in hamony. After "manually configuring the server" (editing the httpd.conf) I
restarted Apache and when I try to open a .php file I get a blank page and the browser says
"done". Tried phpinfo () but I still get the blank page. Now I don't know wh....
What Is Wrong With Consumers Today?
Horror Stories of Customer's from the Retailer's Point of View (7) If you work in retail or any other customer-based environment, I want to hear replies on
customer's who are stupid, mean, ignorant, or just down-right retarded: I am the asst mgr. of a
well-known electronic retail store. I had a customer come in who wanted to return something. So I
followed procedure to a tee. I asked her to enter her phone number on a pad. She asked why. I
said it was required for the return. I then asked her for her name and address. "You don't need
that." "Yes, I do, ma'am. Our company tracks all returns." "I'm not telling you"....
Could Someone Please Review My Site.
Help...what did i do wrong? (17) So i followed jlhaslip's advice and got rid of the .tk domain, still no more visitors. I've
told everyone on my contact list, posted it to blogs and forums and still not many people visit my
site... What's wrong with it, i just spent 30 minutes (not long but hey) re-vamping the forum so
its now friendly to guests (i think that might of been a mistake but hey). It has 95 ish good
working games, a guest book, its on Google, it has a search engine, contact us form about us form
nearly everything i can think of. So please tell me whats wrong with it and what i c....
Something Wrong?
(8) Ok so for the last couple of weeks, ive been feeling ODD. All of the sudden ive lost appetite, i
smell food, want to eat it, but i cant, the minute i try to, i just feel disgusted/or full even if i
havent eaten anything, & stop. My stomach rembles but its not hungry? no im not pregnant, someone
asked me that lmfao.. thats a NO! lol anywho, ive also been feeling extra thirsty lately, and
wanting to urinate a lot, idk whats wrong with me? i just feel sick, anxious, & disgusted by many
things, i cant even look at myself in the mirror, it just puts me in whatever mode ev....
Flash Problem
sometimes the buttons will load the wrong link. (9) Its weird but sometimes when you hit the forums or roster button on my flash banner it will load:
www.childrenofconan.trap17.com/index.html instead of what its suppost to. It works fine, but if you
mess around and click the buttons for a little bit you will notice this happening. This is a problem
because people visiting the site will sometimes click the button once and be like oh I guess the
link is broken and never come back, if anyone has a solution to what could be the problem it would
be awesome. This is one of my first custom flash banners and im just confused what....
I Think I Made A Wrong Choice
(5) So next year I am attending "videregående." I do not know what you call it, I guess the school
system is a bit different. But this is my 10th school year, so next year will be my 11th. About two
months ago, we had to make a choice what we wanted to do next year, and where we wanted to go. I
decided to go with "Allmenn." The first year is very similar to all my previous school years, so it
is about the same. They have the "normal classes", like English, mathematics, gymnastics, history,
science and such. In the second and third year you get to choose what classes you want....
I Really Need Some Help
Long Term Relationship Gone Soo Wrong (3) Hey everyone, thanks for taking your time in reading this. What it is that, im only 16 years old and
have been with my boyfriend for almost 2 years, well i have been texting this boy from work, nothing
bad, just as mates.. and i didnt tell my bf coz i no he will go mad, anyway he has found out and now
he is saying he dot trust me, I love him so much, and i dont no whether he is goin 2 split up with
me, over the last 2 days or so, i haven't been sleeping or eating properly, coz im so scared im
goin 2 loose him. I no im young and got my while life ahead, but i love him....
Drinking Cold Water
A wrong concept of weight loss (2) Recently I found that, there is a wrong concept to many people that drinking cold water can reduce
weight. They sowed me few interesting thermodynamics prove (actually they were wrong). They showed
that if some one drinks cold water, it will be increase its temperature inside our body. In another
word, it will burn few calories to increase its temperature. In this way, some one can burn their
calories and can loose their weight. They also showed me if I drink 1000g (around 1 L) water
having temperature 5 deg. C and it increase its temperature 25 deg C (to reach our b....
The Atom
Everything we've ever "known" is wrong. (8) I was just ponderings of the universe today and I thought to myself. If we have never seen an atom
because it's far too small to see. How do we know that they are even real. I mean there could be
this theory that is completely fool proof. The periodic table of elements might work perfectly and
all the groups and rows and stuff might work perfectly but what if the atom is nothing like what we
originally thought. It could change the idea of physics. To my understanding quantum physics (or
something like that) depends primarily on the eratic movements of the electron. W....
The Nhs
What Went Wrong??? (0) Oh dear... Somewhere along the line the NHS and the British Government did something very wrong.
Infectious diseases are reaping havoc such as MRSA and the only choice for the hospitals is to empty
the building and then steam clean it completely. I think that we should completely reform the NHS
ie. New chairman etc. Changes need to be made.....
Vb Select Mysql Database
(2) I am trying to make a script to pull mysql data into a vb application. This will connect to windows
media player so that people can select a song through my website, and windows media player would
play it through vb automatically. Can anybody help me?....
Suicide Is Wrong
(37) Well since trap17 seems to be down.. or just my gay site, im going to talk about suicide and about
how wrong it is. Ok first of all IF YOUR LIFE IS SO MISERABLE AND EVERYONE HATES YOU AND YOU JUST
CANT TAKE IT ANYMORE why in the world would you give the things that are hurting you (most likely
people duh) the joy the HAPPINESS of seeing you give up? and kill yourself! come on.. you are
only making them happy not yourself! and so what you kill yourself thats it! theres no
turning back once you kill yourself.. nothing.. unless your extremely religious and beli....
Os Commerce Problems
I'm trying again! something went wrong on my last post! (2) Something went wrong and it wouldn't come up not even in a search so im posting again /mad.gif"
style="vertical-align:middle" emoid=":angry:" border="0" alt="mad.gif" /> . I really need some
help! I installed oscommerce through fantastico and when i try to access it it says QUOTE
Server Requirement Error: register_globals is disabled in your PHP configuration. This can be
enabled in your php.ini configuration file or in the .htaccess file in your catalog directory.
anyone got any ideas? Please can someone help me!....
Is Something Wrong With Me?
(11) All the women I' have been with in the past few years starts losing weight after going out with
me for a few months. Even if we're not having sex. i suspected psychological reasons at first,
but all of them seem to be happy to be with me. Maybe it's just coincidental I don't know
but it's really disturbing. Should I see a therapist? /sad.gif" style="vertical-align:middle"
emoid=":(" border="0" alt="sad.gif" />....
Firefox 2.0.9 It Css Position A Bit Wrong.
(6) Well, I have installed the lastest version of Firefox 2.0.9. But it got some issues that when I have
browse few web site such yahoo. It got some text wrong positioned. Anyone got this problems too ?
Thanks. ....
Ie 6 Conditional Statement Problems
Wont Work (3) CODE <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html
xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head> <title>Home</title> <meta
http-equiv="Content-Type" content="text/html; charset=utf-8"/> <link
rel="stylesheet" type="text/css" href="style.css" />
<!--[if IE 6]> <link rel="styl....
Robot Rights : Right Or Wrong
(30) hi friends, actually this might seem quiet far fetched but it has come to my mind after reading an
article in a very prominent science magazine. i was going through the magazine and i saw that their
was this article in which a scientist of United kingdom has suggested that within 20 years their
will be something of the sort of "Robot Rights" on the format of human rights and animal rights. i
just was thinking since then that how much will it be right doing that...i mean i do not know... i m
a strong supporter of developing artificial intelligence, though i am one of t....
Islam, Not Terrorism
Proving you wrong (35) KILLING INNOCENT PEOPLE - Many people say that Islam promotes violence, war etc. BUT it actually
doesn't. What Allah does say is that do not be afraid when the kafirs (non-believers) start war
with you. Islam only tells Muslims to put the fire out once it has been lit up, not to light the
fire ourselves because that would be a sin. Allah Himself says in the Qur'an: QUOTE "...For
persecution is worse than killing" Surah Al Baqarah, Chapter 2, Verse 217 "But the other's
mind imposed him on the killing of his brother, so he slew him and became one of the....
Delete A Bunch Of Files Using Dos Statement
DOS Delete Command (4) when we are running a program.they usually create many files that we don't need.Anyone knows the
dos commands that we can delete those file at once?if you know could you please tell me that.thanks
Edit title for spelling error. ....
The Icons Of Zip Files Are Wrong Everytime!
Windows 2000 (3) Hello! I am going crazy for a silly little thing. Please help me anyone! The icon for
ZIP files never shows the way it is supposed to. Instead it insists on displaying the Windows
'default document' icon for ZIP files. If I rightclick a zip and choose icon properties, I
can set the icon to be fetched from the winzip executable instead, and all looks fine and dandy
inside the properties dialog, but after refreshing or repairing icon cache it is still the default
document icon that is displayed. If I try to change the icon enough times it will ev....
Need Help With Using Css
to format a SELECT list (11) I thought I had Cascading Style Sheets (CSS) pretty much under control, but this has me stumped.
What I want to do is format a SELECT drop-down list with a drop shadow as a background image,
similar to what I have done with the textarea shown below. As you can see, I can't it get to
work on the drop-down box. I can change the font color, font type, width and background color but
I can't seem to use a background image like I can for an INPUT box. I have tried various things
without success, can someone please show me a working example of where they have managed....
My Teacher Is Wrong
Complain about teachers here (12) Here is some background info: My english teacher is a german canadian christian. I am a russian jew
who immigrated here 10 years ago. So anyway, I am talking to my friend Drew about how I am gonna be
on vacation for winter break, right? Then my teacher interjects and says "i think it should be
called christmas break because we are breaking for christmas, not hanukkah (looks at me) or Kwaanza
(looks at some black kid in my class) because we are breaking for christmas which is the most
important holiday" What an >!!!! I just want to punch him in his fat u....
Is Homosexuality Right Or Wrong?
your views (221) I wondered what people feel about this? I personally believe that it's wrong and wouldn't
mind chatting to others who believe otherwise to see what they think.....
What Is Wrong With Being A Virgin
Yes this is to be taken seriously but be warned :) (44) OH yeah I brought this topic here now > To start off i would like to say i am not a virgin. I
havent been for some time, but i would like to see what your thoughts are on this. Society seems to
look down upon them. anyone who hasnt slept with others for sexual pleasures is seemingly put down
for some reason. that many are forced to lie about their situation just because they feel they need
to. how sad is this? The practicality of it is that some ppl want to save themselves for that
special person and i see nothing wrong with that. why is it that it for some reason matt....
What's Your Favorite Game System - Console
select one from each poll (180) i'm a computer game fan. it's expensive but more useful. it can be use for many purpose for
your study and entertainment. much easier to use and most common to more people.....
Looking for wrong, php, sql, select, statement
|
|
Searching Video's for wrong, php, sql, select, statement
|
advertisement
|
|