For Programmers: Free Programming Magazines  


Home > Archive > PHP DB > October 2005 > problem with mysql_error()









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author problem with mysql_error()
Jason Gerfen

2005-10-27, 6:56 pm

I am not sure why this is not returning any values but it should be.

The database structure

CREATE TABLE `hosts` (
`id` int(11) NOT NULL auto_increment,
`hostname` varchar(100) NOT NULL default '',
`mac` varchar(100) NOT NULL default '',
`ip` varchar(100) NOT NULL default '',
`vlan` varchar(100) NOT NULL default '',
PRIMARY KEY (`id`),
UNIQUE KEY `mac` (`mac`),
UNIQUE KEY `ip` (`ip`),
UNIQUE KEY `hostname` (`hostname`),
UNIQUE KEY `id` (`id`)
) TYPE=MyISAM AUTO_INCREMENT=4705 ;

And the code:

$update = @mysql_query( "UPDATE hosts SET hostname=\"$host\",
mac=\"$mac\", ip=\"$ip\", vlan=\"$vlan\" WHERE id=\"$id\"", $db )or die(
"<img src=\"images/error.jpg\">  <b>Error: </b>Problem occured
while updating host records for $host.</b><br>Error Message: " .
@mysql_error( $update ) . "<br>" . "Error Number: " . @mysql_errno(
$update ) . "<br>Email Administrator: <a
href=\"mailto:$defined[mail]\">$defined[mail]</a>" );

Because I have set a couple of the fields to unique I should be recieving an error of 'duplicate entry' but i am getting an empty result for mysql_error(). Any help is appreciated.

--
Jason Gerfen
Student Computing Labs, University Of Utah
jason.gerfen@scl.utah.edu

J. Willard Marriott Library
295 S 1500 E, Salt Lake City, UT 84112-0860
801-585-9810

"My girlfriend threated to
leave me if I went boarding...
I will miss her."
~ DIATRIBE aka FBITKK
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com