我有兩個php文件。數據不在mysql數據庫中寫入
這裏是一個與代碼:
<?php
require_once('../includes/php.config.db.php');
//here i have a script (xpath) for exctracting data (work 100%)
$naslov = $data['naslov'];
$latitude = $data['lat'];
$longitude = $data['lng'];
$latitude = (float) $latitude;
$lin = $data['link'];
$vreme = $data['vreme'];
$popust = str_replace ('POPUST','',$data['popust']);
$firma = $data['firma'];
$telefon = $data['telefon'];
$email = $data['email'];
$sajt = $data['sajt'];
$type = 'bar';
$latitude = (float) $latitude;
$longitude = (float) $longitude;
//end
?>
第二個文件是php.config.db.php我在上面稱之爲:
<?php
$link = mysql_connect('localhost', 'user', 'pass') or die('<p>Nije moguce uspostaviti konekciju sa database serverom!</p>');
mysql_select_db('tablename', $link);
mysql_query("SET NAMES utf8");
mysql_query("SET CHARACTER SET utf8");
mysql_query("SET COLLATION_CONNECTION='utf8_general_ci'");
function insertNewMarker($name='', $lat='', $lng='', $slika='', $link='', $type='', $popust='', $vaziDo='') {
if(!empty($name) and !empty($lat) and !empty($lng) and !empty($link)) {
$name = mysql_real_escape_string(trim($name));
$sql = "INSERT INTO `markers` (`name`, `lat`, `lng`, `address`, `totolink`, `type`, `popust`, `vaziDo`) <br />
VALUES ('$name', '$lat', '$lng', '$slika', '$link', '$type', '$popust', '$vaziDo')";
mysql_query($sql) or print "<p>Error in SQL Statement ($sql):<br />". mysql_error() .'</p>';
}
else {
print "<p>Polja 'name', 'lat' i 'lng' ne smiju biti prazna!<br />Vi ste uneli <br />Name:$name<br />Lat:$lat<br />Lng:$lng</p>";
}
}
?>
但是當我開始的PHP文件只我得到一個沒有錯誤的白色屏幕,我的數據庫是空的。爲什麼? (對不起,我的英語)
設定的display_errors的值,顯示錯誤,也使用error_reporting功能。 – Dev
基本調試說什麼?你在哪裏調用'insertNewMarker()'? –
是的它看起來像你永遠不會說insertnewmarker –