我得到錯誤「數組到字符串轉換」在mysql(「插入」)行,我有var_dump
ed每個正在使用的變量。這裏是完整的錯誤:我沒有陣列,但我得到「陣列到字符串轉換」在PHP
Array to string conversion in C:\xampp\htdocs\newresident.php on line 33
但是,我沒有看到任何數組,只看到字符串。這可能是電子郵件變量中有@的問題嗎?
<?php
include 'dbinfo.php';
include 'updateinsert.php';
$escapedPost = array_map('mysql_real_escape_string', $_POST);
$firstname = $escapedPost['fName'];
$lastname = $escapedPost['lName'];
$password1 = sha1($escapedPost['password1']);
$gender = $escapedPost['gender'];
$address1 = $escapedPost['address1'];
$address2 = $escapedPost['address2'];
$city = $escapedPost['city'];
$state = $escapedPost['state'];
$zip = $escapedPost['zip'];
$hPhone = $escapedPost['hPhone'];
$cPhone = $escapedPost['cPhone'];
$wPhone = $escapedPost['wPhone'];
$email = $escapedPost['email'];
$pEmail = $escapedPost['pEmail'];
echo $password1;
var_dump($firstname);
var_dump($lastname);
var_dump($password1);
var_dump($gender);
var_dump($address1);
var_dump($address2);
var_dump($city);
var_dump($state);
var_dump($zip);
var_dump($hPhone);
var_dump($cPhone);
var_dump($wPhone);
var_dump($email);
var_dump($pEmail);
mysql_query("CALL sp_User('$email', '$pEmail','$password1', 'Resident')");
//uiUser($hospitalemail,$personalemail,$password,"Resident");
$userid = getUserByEmail($_POST['email']);
mysql_query("INSERT INTO ResidentInfo(UserId, NameFirst, NameLast, NameMiddle, Gender, Photo, Address1, Address2, City, State, ZipCode, PhoneNumberHome, PhoneNumberWork, PhoneNumberCell) VALUES ('$userid', '$firstname', '$lastname', NULL,'$gender', NULL, '$address1','$address2','$city','$state','$zip','$hPhone','$wPhone','$cPhone')");
?>
輸出:
string(6) "Fname"
string(4) "Lname"
string(40) "cd889c90136db988312a7953bbbbac980de23b03"
string(1) "M"
string(14) "24 Olive Ln."
string(0) ""
string(10) "Kearny"
string(10) "New Jersey"
string(10) "0710907109"
string(15) "e73879728812345"
string(15) "e73879728812345"
string(15) "e73879728812345"
string(15) "[email protected]"
string(12) "[email protected]"
什麼是html元素的性別? –
你'var_dumped'除'$ userid'之外的所有東西... – deceze
哇,你是對的,$ userid是一個內部有另一個數組的數組。上次時間我相信我的朋友的功能在面值。 – Garvin