DW_
DW_

Reputation: 104

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!!

Upvotes: 0

Views: 123

Answers (1)

Dipanwita Kundu
Dipanwita Kundu

Reputation: 1667

use back-quotes("`") on your field name as you have used many of the mysql reserve keyword in your field name

Upvotes: 1

Related Questions