PHP Help, Just Some Small Stuff.

Status
Not open for further replies.

JoshuaLuke

Posting Freak
Jan 29, 2012
529
51
Hey,

I'm testing my PHP skills with some MySQL stuff. I have a variable which is:
Code:
$mysql_error_handler = '<center><font face="Arial">MySQL Error:' . mysql_error();

Then I have a little or die script on my mysql_connect:
Code:
or die ($mysql_error_handler);

BUT. When I input something wrong, the output to the page is only: MySQL Error: When it should show something like MySQL Error: ERROR HERE FROM mysql_error();, but it doesn't, so why not?
 

Adil

DevBest CEO
May 28, 2011
1,278
716
PHP:
$mysql_error_handler = "<center><font face='Arial'>MySQL Error:" . mysql_error();
That may work, not too sure though. Also, where are you declaring this variable?
 

JoshuaLuke

Posting Freak
Jan 29, 2012
529
51
PHP:
$mysql_error_handler = "<center><font face='Arial'>MySQL Error:" . mysql_error();
That may work, not too sure though. Also, where are you declaring this variable?
Still doesn't work, what do you mean 'declaring'? It's to use multiple times for MySQL connections, i've done all my requiring etc. This is the only thing that i'm confused with
 

Adil

DevBest CEO
May 28, 2011
1,278
716
Still doesn't work, what do you mean 'declaring'? It's to use multiple times for MySQL connections, i've done all my requiring etc. This is the only thing that i'm confused with
E.g where are you instantiating the variable?
What file are you declaring it in?
 

Frenchies

Member
Mar 18, 2012
32
4
Try just doing die(mysql_error());
If that works, maybe just create a function.

PHP:
final public function myError($thingy) {
        // $thingy = the variable you set to connect to the database.
       return die("MySQL Error: " . mysql_error($thingy) . "has occurred.");
}

I just coded that on my phone, so I am not sure if it will work.
 
Status
Not open for further replies.

Users who are viewing this thread

Top