简体   繁体   中英

Mysql query working in phpmyadmin but not in a php script

I've written this mysql query, but for some weird reason it's working in phpmyadmin. When I run this query in php it doesn't work.

mysql

$sql = "INSERT INTO msw_posts (user_id, user_name, title, vak, richting, type, post_date, points, views, likes, dislikes, year, keywords, discription)
VALUES ('1', 'test user', 'test', 'bio', 'aso', 'cursus', '2016-05-04', '0', '0', '0', '0', '3', 'test', 'discr')";

PHP

                    if (mysqli_query($dbConn, $sql)) {
                        echo "New record created successfully";
                        //uploaden en checken of upload in orde is
                        if(move_uploaded_file($_FILES['bestand']['tmp_name'], $dir.$file)){
                            header("Location: uploaden.php?type=ok");
                        }else{
                            header("Location: uploaden.php?type=failed_uploading");
                        }
                    } else {
                        echo "Error: " . $sql . "<br>" . mysqli_error($conn);
                    }

Thanks for your advice or help!!

在字段名称上使用back-quotes(“`”),因为您在字段名称中使用了许多mysql reserve关键字

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM