Jump to content

Database problems


daniel.hegarty

Recommended Posts

Hi there

 

I have been pulling my hair all day about this problem. i am trying to connect to an access db and retrieve the records using the following. I have had to change the code from using mysql to odbc (don’t ask why) but I keep getting the following error.

 

 

Fatal error: Call to undefined function mysql_query() in E:\kunden\homepages\11\d374587144\www\bigjigsrail.com\demo\phpsqlsearch_genxml.php on line 46

 

below is my code

 

I know this is because it is trying to use mysql_query but I can’t find an alternative.

 

Any help would be great.

 

Thanks

 

Daniel

 


# INIT
    #################

    // Absolute path of our mdb file
    $cur_dir = addslashes(dirname(__FILE__));
    $db_file = $cur_dir . "\\Datastore\\cat.mdb";
            
    $provider = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" . $db_file;
            
    // Establish the connection
    $conn = new COM("ADODB.Connection") or die("Cannot start ADO" . odbc_errormsg()); 
    $conn->Open($provider);

// Search the rows in the markers table
$query = sprintf("SELECT ShopName, Latitude, Longitude, ( 3959 * acos( cos( radians('%s') ) * cos( radians( Latitude ) ) * cos( radians( Longitude ) - radians('%s') ) + sin( radians('%s') ) * sin( radians( Latitude ) ) ) ) AS distance FROM Markers HAVING distance < '%s' ORDER BY distance LIMIT 0 , 5",
  addslashes($center_lat),
  addslashes($center_lng),
addslashes($center_lat),
	addslashes($radius));
$result = mysql_query($query);

$result = mysql_query($query);
if (!$result) {
  die("Invalid query: " . odbc_error());
}

Link to comment
https://forums.phpfreaks.com/topic/243462-database-problems/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.