mysql_query不成功。数据库不接收任何数据

时间:2015-02-17 16:07:52

标签: php mysql database

我正在处理这个应用程序,该应用程序应该从表单收集数据并将其发送到数据库但由于某种原因,数据库没有接收任何数据。我尝试使用mysql_errno()并收到“Query is empty”

$name = mysql_real_escape_string($_POST['name']);
            $qualification = mysql_real_escape_string($_POST['qualification']);
            $position = mysql_real_escape_string($_POST['position']);
            $direct = mysql_real_escape_string($_POST['direct']);
            $telephone = mysql_real_escape_string($_POST['telephone']);
            $cell = mysql_real_escape_string($_POST['cell']);
            $fax = mysql_real_escape_string($_POST['fax']);
            $email = $r['email'];
            $address = mysql_real_escape_string($_POST['address']);
            $cityProvince = mysql_real_escape_string($_POST['cityProvince']);
            $postalCode = mysql_real_escape_string($_POST['postalCode']);
            $website = mysql_real_escape_string($_POST['website']);

            $q = mysql_query("INSERT INTO `mmg_business_card_logs` (`id`, `name`, `qualification`, `position`, `direct`, `telephone`, `cell`, `fax`, `email`, `address`, `cityProvince`, `postalCode`, `website`) 
                                                                VALUES ('', '{$name}', '{$qualification}', '{$direct}', '{$position}', '{$telephone}', '{$cell}', '{$fax}', '{$email}', '{$address}', '{$cityProvince}', '{$postalCode}', '{$website}')");

1 个答案:

答案 0 :(得分:0)

$q = mysql_query("INSERT INTO `mmg_business_card_logs` ( `name`, `qualification`, `position`, `direct`, `telephone`, `cell`, `fax`, `email`, `address`, `cityProvince`, `postalCode`, `website`) 
                                                                VALUES ('$name', '$qualification', '$direct', '$position', '$telephone', '$cell', '$fax', '$email', '$address', '$cityProvince', '$postalCode', '$website')");

OR

$q = mysql_query("INSERT INTO `mmg_business_card_logs` (`id`, `name`, `qualification`, `position`, `direct`, `telephone`, `cell`, `fax`, `email`, `address`, `cityProvince`, `postalCode`, `website`) 
                                                                    VALUES ('121', '$name', '$qualification', '$direct', '$position', '$telephone', '$cell', '$fax', '$email', '$address', '$cityProvince', '$postalCode', '$website')");

试试这个。如果这不起作用,请尝试echo $ q并显示输出或尝试在MySql中执行该查询