hi, i tried to execute following query in php script. $db_selected = mysql_select_db("lumiinc1_sndemo1", $con); if ($db_selected) { echo "database connected"; } else { die ("Can\'t use db : " . mysql_error()); } $sql = "INSERT INTO `markers` ( `name`, `address`, `lat`, `lng`, `id` ) SELECT `name`, `street`, `latitude`, `longitude`, `lid` FROM `location` WHERE NOT EXISTS ( SELECT * FROM `markers` WHERE `location`.`lid` = `markers`.`id` )"; $result = mysql_query($sql); if ($result) { echo "Query executed OK"; } else { die("Invalid query: " . mysql_error()); } PHP: script does not show any error.also query executed.but i didn't get my expected result.at the same i try this query in phpmyAdmin i got my expected result. i dont know the cause of this problem. plz any one find the problem . thanks
i think its on the mysql_error(), im not sure but why dont you try. mysql_query(your query) or die(mysql_error()); instead of putting it to condition statement if
INSERT INTO `markers` ( `name`, `address`, `lat`, `lng`, `id` ) SELECT `name` I am not sure if it is correct.
yes the sql is incorrect it should be something like INSERT INTO `markers` ( `name`, `address`, `lat`, `lng`, `id` ) VALUES (SELECT `name` ... )