[pmapper-users] Nothing happens while trying to connect to MYSQL database
Brought to you by:
arminburger
From: Chris B. <be...@xs...> - 2006-12-03 15:23:24
|
I'm using the script below. However while trying to connect to the MYSQL database nothing happens (also no PHP error). What could be wrong? Thank, Chris Beaart. ------------------ <?php require_once ("C:/ms4w/Apache/php/PEAR/DB.php"); session_start(); require_once("common.php"); function DB_addPoint($imgxy, $soort, $waarneming, $datum) { $db_host = "localhost"; $db_type = "MYSQL"; $db_name = "database"; $db_user = "root"; $db_pwd = "password"; $dsn = "$db_type://$db_user:$db_pwd@$db_host/$db_name"; error_log ($dsn); #MYSQL://root:password@localhost/database // CONVERT PIXEL X/Y TO MAP UNITS $imgxy_arr = explode(" ", $imgxy); $x_pix = $imgxy_arr[0]; $y_pix = $imgxy_arr[1]; $GEOEXT = $_SESSION["GEOEXT"]; $geoDeltaX = $GEOEXT["maxx"] - $GEOEXT["minx"]; $geoDeltaY = $GEOEXT["maxy"] - $GEOEXT["miny"]; $mapW = $_SESSION["mapwidth"]; $mapH = $_SESSION["mapheight"]; $x_geo = round($GEOEXT["minx"] + (($x_pix/$mapW)*$geoDeltaX)); $y_geo = round($GEOEXT["maxy"] - (($y_pix/$mapH)*$geoDeltaY)); // CONNECT TO DB AND RUN QUERY //$geometry = "GeomFromText('POINT($x_geo $y_geo)',26591)"; $sql = "INSERT INTO waarnemingen(x,y,soort,waarneming) VALUES($x_geo,$y_geo,'$soort','$waarneming')"; #error_log ($sql); # SOMEWHERE HERE GOES SOMETHING WRONG $dbh = dbConnect($dsn); $result = $dbh->query($sql); // Check that $result is not an error if (DB::isError($result)) { $dbh->disconnect(); return ($result->getMessage()); } else { $dbh->disconnect(); return 1; } } function dbConnect($dsn) { $dbh = DB::connect($dsn); if (DB::isError($dbh)) { die ($dbh->getMessage()); return NULL; } else { return $dbh; } } ?> |