[مساعدة] بخصوص كود php لإضافة مشاركة / تدوينة

السلام عليكم

لأ أعلم ما المشكلة في هذا الكود فعندما أحاول أن أضيف تدوينة تظهر هذه الرسالة :

faildYou have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'xscd','scd',now(),'','','','4','')' at line 1

وهذا هو كوذ الـ Php

    $query = " INSERT INTO `posts` ( post_category_id, post_title, post_author, post_date, post_image, post_content, post_tags, post_comment_count, post_status )";
    $query .= "VALUES ($post_category_id','{$post_title}','{$post_author}',now(),'{$post_image}','{$post_content}','{$post_tags}','{$post_comment_count}','{$post_status}')";

    $create_post_query= mysqli_query($connection, $query);
    if (!$create_post_query) {
        die("faild" . mysqli_error($connection));
    }
يرجى الدخول لحسابك أو تسجيل حساب لتستطيع إضافة تعليق
حساب جديد دخول

التعليقات

RezkiAmara أضف ردا

جربه هاكذا يا أخي و قلي ان لم يعمل

$query = " INSERT INTO `posts` ( post_category_id, post_title, post_author, post_date, post_image, post_content, post_tags, post_comment_count, post_status )";
$query .= "VALUES ('".$post_category_id."','".$post_title."','".$post_author."',".now().",'."$post_image".','".$post_content."','".$post_tags."','".$post_comment_count."','".$post_status."')";

$create_post_query= mysqli_query($connection, $query);
if (!$create_post_query) {
    die("faild" . mysqli_error($connection));
}

@راشد المري @RezkiAmara

لقد قمت بتجريب الكود أخي رزقي :

فتظهر هذه الرسالة :

Fatal error: Call to undefined function NOW() in C:\AppServ\www\cms\admin\includes\add_post.php on line 23

وعندما حذفت NOW() اشتغل الكود وتم ارسال الموضوع الى قاعدة البيانات.

ضع مكان now()

("date("Y/m/d من اجل الوقت

راشد المري أضف ردا
    $query = " INSERT INTO `posts` ( post_category_id, post_title, post_author, post_date, post_image, post_content, post_tags, post_comment_count, post_status )";
    $query .= " VALUES ($post_category_id ,'{$post_title}' , '{$post_author}', NOW(), '{$post_image}', '{$post_content}', '{$post_tags}' ,'{$post_comment_count}' ,'{$post_status}')";

    $create_post_query= mysqli_query($connection, $query);
    if (!$create_post_query) {
        die("faild" . mysqli_error($connection));
    }

أخي @راشد المري

نفس المشكلة :

faildYou have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''electric and hybrid cars' , 'elmelali', NOW(), '', '', '' ,'4' ,'')' at line 1

قد تكون الحقول

post_image

post_content

post_tags

post_status

في قاعدة البيانات حقول اجبارية (NOT NULL)

بينما القيم المُدخلة وهم المتغيرات

$post_image

$post_content

$post_tags

$post_status

خالية من القيم. تأكد من ذلك، أن لم تعمل ارسل لي الملف كاملاً.

RezkiAmara أضف ردا

اخي هل id هو auto increment ؟