Login pages... (quickie)

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Mightywayne
Forum Contributor
Posts: 237
Joined: Sat Dec 09, 2006 6:46 am

Post by Mightywayne »

Right see okay, I just said I have no idea how to use it. >_____> Every time I use it, including errno(), it just gives me that error. That apparently means something is wrong with connecting, so I'm going to start from a scratch, a form, using cookies. Also apparently, this is not as hard as it seems to be for me. Quoth my friends.
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Post by Ollie Saunders »

This is how you use it.

Code: Select all

$result = mysql_query('some query');
if (!$result) {
    trigger_error(mysql_error());
}
>_____>
What does that mean?
Mightywayne
Forum Contributor
Posts: 237
Joined: Sat Dec 09, 2006 6:46 am

Post by Mightywayne »

Image
It's a face. It's meant to show, like, difficulty or frustration with something.
Small edit: Plox.. it doesn't work in this forum?

I'm going to try to mess around with that mysql_error thing now that you've showed me, and let's see if I can figure it out. (I'll edit my post if so... if not, this is the end, I do believe, of sessions for mii)
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Post by Ollie Saunders »

if not, this is the end, I do believe, of sessions for mii
How are sessions responsible for your problems with failing queries? Sessions are cool but I fail to see how they are relevent
It's a face. It's meant to show, like, difficulty or frustration with something.
Right OK, I prefer: >_<
Last edited by Ollie Saunders on Thu Jan 18, 2007 6:05 pm, edited 1 time in total.
User avatar
aaronhall
DevNet Resident
Posts: 1040
Joined: Tue Aug 13, 2002 5:10 pm
Location: Back in Phoenix, missing the microbrews
Contact:

Post by aaronhall »

This isn't a sessions problem
Mightywayne
Forum Contributor
Posts: 237
Joined: Sat Dec 09, 2006 6:46 am

Post by Mightywayne »

Editted out in case some folks try to hax0r me. Seriously. o_O;;
Last edited by Mightywayne on Fri Apr 06, 2007 2:21 pm, edited 1 time in total.
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Post by Ollie Saunders »

You still aren't using mysql_error() correctly. You have to use it immediately after each query but we are getting somewhere because now we know the user table does not have a field called password
Mightywayne
Forum Contributor
Posts: 237
Joined: Sat Dec 09, 2006 6:46 am

Post by Mightywayne »

OMG SLAY ME NOW.

WHY. Omfg. Wow. Wow. Wow.

You're right. There isn't. I for some reason called it "pword". WHY WOULD I DO THAT.

Let me check that out right now. It's likely also that username was "name". Both are changing NOW. What was I thinking...
User avatar
aaronhall
DevNet Resident
Posts: 1040
Joined: Tue Aug 13, 2002 5:10 pm
Location: Back in Phoenix, missing the microbrews
Contact:

Post by aaronhall »

Are you sure that there aren't any misspellings? Remember that table and column names are case-sensitive on unix systems. It also wouldn't hurt to enclose the column name in back-ticks (`).

Anyway, it doesn't sound like your friend knows a whole lot about sessions either -- they'll save you a lot of time in the long run. To each his own, I guess.
Mightywayne
Forum Contributor
Posts: 237
Joined: Sat Dec 09, 2006 6:46 am

Post by Mightywayne »

Editted out in case some folks try to hax0r me. Seriously. o_O;;
Last edited by Mightywayne on Fri Apr 06, 2007 2:22 pm, edited 1 time in total.
User avatar
aaronhall
DevNet Resident
Posts: 1040
Joined: Tue Aug 13, 2002 5:10 pm
Location: Back in Phoenix, missing the microbrews
Contact:

Post by aaronhall »

Were the notices any more descriptive? It's probably an undefined array key
Mightywayne
Forum Contributor
Posts: 237
Joined: Sat Dec 09, 2006 6:46 am

Post by Mightywayne »

No, I just copy pasta'd what I saw.

"Undefined array key". Would that mean something in my MySQL DB?
User avatar
aaronhall
DevNet Resident
Posts: 1040
Joined: Tue Aug 13, 2002 5:10 pm
Location: Back in Phoenix, missing the microbrews
Contact:

Post by aaronhall »

If you make reference to an array key that's not set, e.g. $myArray['thisWasNeverSet'], then you'll get a notice. You need to check it with isset() before referencing it.

Code: Select all

$array = array('hello' => '1');

echo $array['hello']; // no notice
echo $array['world']; // notice is issued

if(isset($array['world'])) { echo $array['world']; } // no notice
Mightywayne
Forum Contributor
Posts: 237
Joined: Sat Dec 09, 2006 6:46 am

Post by Mightywayne »

Hmm, I've never used array() in my coding. So I guess it's not that, or...? Could it be?
User avatar
aaronhall
DevNet Resident
Posts: 1040
Joined: Tue Aug 13, 2002 5:10 pm
Location: Back in Phoenix, missing the microbrews
Contact:

Post by aaronhall »

I'm sorry -- it's actually any variable or array key. Anyway, what are the lines that the notices are referring to?

Here's how to use mysql_error() for future reference:

Code: Select all

$res = mysql_query('SELECT ...') or die('MySQL Error: ' . mysql_error());
Post Reply