簡體   English   中英

我沒有數組,但我在 PHP 中得到“數組到字符串的轉換”

[英]I have no arrays but I get "Array to string conversion" in PHP

我在 mysql("INSERT") 行上收到錯誤“數組到字符串轉換”,並且我對每個正在使用的變量進行了var_dump 這是完整的錯誤:

C:\\xampp\\htdocs\\newresident.php 中第 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) "worki@yahoo.com"
string(12) "wo@yahoo.com"
$firstname       = (string)$escapedPost['fName'];
$lastname        = (string)$escapedPost['lName'];
...
...

使用字符串解析器來確保您正在傳遞字符串。 還可以使用is_string()進行檢查。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM