Page 3 of 5

Posted: Wed Jan 17, 2007 5:35 pm
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.

Posted: Wed Jan 17, 2007 5:43 pm
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?

Posted: Thu Jan 18, 2007 6:00 pm
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)

Posted: Thu Jan 18, 2007 6:04 pm
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: >_<

Posted: Thu Jan 18, 2007 6:05 pm
by aaronhall
This isn't a sessions problem

Posted: Thu Jan 18, 2007 6:13 pm
by Mightywayne
Editted out in case some folks try to hax0r me. Seriously. o_O;;

Posted: Thu Jan 18, 2007 6:16 pm
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

Posted: Thu Jan 18, 2007 6:20 pm
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...

Posted: Thu Jan 18, 2007 6:20 pm
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.

Posted: Thu Jan 18, 2007 6:33 pm
by Mightywayne
Editted out in case some folks try to hax0r me. Seriously. o_O;;

Posted: Thu Jan 18, 2007 6:38 pm
by aaronhall
Were the notices any more descriptive? It's probably an undefined array key

Posted: Thu Jan 18, 2007 6:41 pm
by Mightywayne
No, I just copy pasta'd what I saw.

"Undefined array key". Would that mean something in my MySQL DB?

Posted: Thu Jan 18, 2007 6:44 pm
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

Posted: Thu Jan 18, 2007 7:02 pm
by Mightywayne
Hmm, I've never used array() in my coding. So I guess it's not that, or...? Could it be?

Posted: Thu Jan 18, 2007 7:07 pm
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());