开发者

Error or not and insert to database mysql

Why wont this work?

<?php include "top.php"; 
include "connect.php";
if(isset($_POST["submit"])) {
$error = "";
    if(empty($_POST["name"])) {
        $error .= "Du glömde märket!<br>";
        if(empty($_POST["rating"])){
        $error .= "Du glömde att bedömma märket!<br>";
                if(empty($_POST["worth"])){
        $error .= "Du glömde att välja vilken klass den hör till!<br>";
                if(empty($_POST["username"])){
        $error .= "Du glömde att skriva ditt namn!<br>";
                if(empty($_POST["rating"])){
        $error .= "Du glömde att skriva någonting?!!<br>";
        }}}}}
    if(!empty($error)){
    echo $error;
    }else{
$name = $_POST["name"];
$rating = $_POST["rating"];
$worth = $_POST["worth"];
$favorite = $_POST["favorite"];
$username = $_POST["username"];
$description = $_POS开发者_运维知识库T["description"];
mysql_query("INSERT INTO brands (name, rating, worth, favorite, username, description) VALUES ('$name', '$rating', '$worth', '$favorite', '$username', '$description')");
echo "<span style='color: green'>Yir yir, <a href='brand.php'>klicka här för att gå till Märken.</a></span>";
    }
    }

It doesnt come with errors it just say the succeed message like it has inserted to database


.We can't help you unless you at least try to get some debug information.

For instance, replace

mysql_query("INSERT INTO brands (name, rating, worth, favorite, username, description) VALUES ('$name', '$rating', '$worth', '$favorite', '$username', '$description')");

With

$query = "INSERT INTO brands (name, rating, worth, favorite, username, description) VALUES ('$name', '$rating', '$worth', '$favorite', '$username', '$description')";

echo "Query: " . $query;

mysql_query($query);

It echoes the query to the screen before executing it, perhaps it provides some more information.


echo the query u have created and see what is displayed and execute that query for testing in phpmyadmin

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜