Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/256.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 伪造库和准备好的语句不工作,未显示错误_Php_Mysql_Arrays_Faker - Fatal编程技术网

Php 伪造库和准备好的语句不工作,未显示错误

Php 伪造库和准备好的语句不工作,未显示错误,php,mysql,arrays,faker,Php,Mysql,Arrays,Faker,您好,我正在使用Faker库生成随机数据,以填充我正在处理的项目的表,您可以看到,我正在准备语句,然后在数组中设置语句的所有变量。最后,我执行了这个声明,但我不知道为什么它让我感到非常困惑 <?php require('/vendor/autoload.php'); //Create New Instance Of Faker $faker = Faker\Factory::create(); //Connect to Database $conn = connect(); for (

您好,我正在使用Faker库生成随机数据,以填充我正在处理的项目的表,您可以看到,我正在准备语句,然后在数组中设置语句的所有变量。最后,我执行了这个声明,但我不知道为什么它让我感到非常困惑

<?php 
require('/vendor/autoload.php');
//Create New Instance Of Faker
$faker = Faker\Factory::create();
//Connect to Database
$conn = connect();

for ($i=1; $i < 10; $i++){
    $query = "INSERT INTO nightsout_venues (name, type, descripton , username)
     VALUES(:name, :type, :descripton, :username)";
    $stmt = $conn->prepare($query);
    $Type = array("restaurant","pub","club","cafe");
    $randomtype = array_rand($Type);
    //Creating Array Of values
    // For Prepared Statement
    $arg = 
        array(
            ':name'       => $faker -> company,
            ':type'       => $Type[$randomtype],
            ':descripton' => $faker -> paragraph(5),
            ':username'   => $faker -> freeemail,
        );

    //Executing the statement
    $stmt->execute($arg);   
}
?>

非常感谢Matt根据OP的愿望

如果您的列被称为“description”,请确保您的“description”没有输入错误

据我所知,你的代码对我来说很好

另外,在错误例外方面引用Ghost:


“确保PHP的错误报告已打开,并在$conn之后添加
$conn->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_WARNING);

确保PHP的错误报告已打开,并添加
$conn->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_WARNING)
$conn
之后。如果你的专栏名为“description”,也要确保你的“descripton”没有输入错误。非常感谢你,我是一个如此愚蠢的木偶小错误,我真的应该停止在深夜编写代码了。如果你回答了,我会为你接受的非常感谢@Fred ii-@Mattyboi1670不客气,已经完成了,干杯。