PDA

View Full Version : مشکل عجیب در ذخیره اطلاعات در mysql



ali586
پنج شنبه 17 مهر 1399, 16:52 عصر
سلام به تمام اعضای فروم
من یه چند روزی هست با مشکل عجب بر خوردم و کلی سرچ کردم و کلی هم با کد کار کردم ولی باز مشکل حل نشده .
مشکل این هست که نام و نام خانوادگی درست ذخیره میشه ولی آدرس و ایمیل و نوع پرداخت 0 ذخیره میشه با اینکه نوع فیلد رو هم varchar قرار دادم. utf-8 در دیتابیس و کد رعایت کردم.
کد های بخش php را براتون میذارم اگه متوجه مشکل شدین لطفا راهنمایی کنید




کد های php

if ($_SERVER["REQUEST_METHOD"] == "POST"){
$malicode = test_input($_POST["malicode"]);
$sabtenam = "1";
$noez = test_input($_POST["noez"]);
$shsh = test_input($_POST["shsh"]);
$comtyear = test_input($_POST["comtyear"]);
$comtmonth = test_input($_POST["comtmonth"]);
$comtday = test_input($_POST["comtday"]);
$fname = test_input($_POST["fname"]);
$lname = test_input($_POST["lname"]);
$faname = test_input($_POST["faname"]);
$statee = test_input($_POST["statee"]);
$sarbaz = test_input($_POST["sarbaz"]);
$comayear = test_input($_POST["comayear"]);
$comamonth = test_input($_POST["comamonth"]);
$comaday = test_input($_POST["comaday"]);
$isar = test_input($_POST["isar"]);
$adres = test_input($_POST["adres"]);
$state = test_input($_POST["state"]);
$city = test_input($_POST["city"]);
$codepost = test_input($_POST["codepost"]);
$malifcode = test_input($_POST["malifcode"]);
$tell = test_input($_POST["tell"]);
$mobi = test_input($_POST["mobi"]);
$email = test_input($_POST["email"]);
$pay = test_input($_POST["pay"]);
$bank1 = test_input($_POST["bank1"]);
$bank2 = test_input($_POST["bank2"]);
$bank3 = test_input($_POST["bank3"]);
$bank4 = test_input($_POST["bank4"]);
$bank5 = test_input($_POST["bank5"]);
$shobe1 = test_input($_POST["shobe1"]);
$shobe2 = test_input($_POST["shobe2"]);
$shobe3 = test_input($_POST["shobe3"]);
$shobe4 = test_input($_POST["shobe4"]);
$shobe5 = test_input($_POST["shobe5"]);
$tpay = test_input($_POST["tpay"]);
$mpay = test_input($_POST["mpay"]);
$dpay = test_input($_POST["dpay"]);
$TTpayy = test_input($_POST["TTpayy"]);
$ddpayy = test_input($_POST["ddpayy"]);
$shkart = test_input($_POST["shkart"]);
if(empty($malicode) || empty($shsh) || empty($comtyear) || empty($comtmonth) || empty($comtday) || empty($fname) || empty($lname) || empty($faname) || empty($comayear) || empty($comamonth) || empty($comaday) || empty($adres) || empty($state) || empty($city) || empty($mobi)){
$msg = "لطفا گزینه های الزامی را پر کنید";

} else {
if(!empty($_POST["pay"])){
try{
if($_POST["pay"] == "پرداخت آنلاین"){
$stmt=$conn->prepare("INSERT INTO tbl_register (malicode,sabtenam,noez,shsh,comtyear,comtmonth,co mtday,fname,lname,faname,statee,sarbaz,comayear,co mamonth,comaday,isar,adres,state,city,codepost,mal ifcode,tell,mobi,email,pay) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
$stmt->bind_param('ssssssssssssiiiiiiiiiiiii',$malicode,$ sabtenam,$noez,$shsh,$comtyear,$comtmonth,$comtday ,$fname,$lname,$faname,$statee,$sarbaz,$comayear,$ comamonth,$comaday,$isar,$adres,$state,$city,$code post,$malifcode,$tell,$mobi,$email,$pay);

if ($stmt->execute()){
echo $pay;
echo $adres;
echo $email;
echo "sabt shod";
}else{
echo "nooooooo";
}
$stmt->close();
//header("location:/Panel/pay-ir/send.php");
} else {
echo "کارت به کارت";
}
} catch (Exception $ex) {
print_r($ex);
}

}
}
}
عکس از دیتابیس


152306

plague
پنج شنبه 17 مهر 1399, 21:46 عصر
کدات رو درست تو تگ مناسب بزار که بشه خوندشون الان توی یک خط شدن که نمیشه چیزی دید
ترتیبشون رو اشتباه نوشتی داری noez رو میریز توی shsh

ali586
یک شنبه 20 مهر 1399, 10:19 صبح
کدات رو درست تو تگ مناسب بزار که بشه خوندشون الان توی یک خط شدن که نمیشه چیزی دید
ترتیبشون رو اشتباه نوشتی داری noez رو میریز توی shsh


درود
کد ها را صحیح گذاشتم و اتوماتیک در یک خط قرار میگیرن در هر صورت 2 فایل html و php را ضمیمه کردم . سپاسگذارم

ROSTAM2
یک شنبه 20 مهر 1399, 11:00 صبح
با سلام - والا زمان ما از nvarchar برای همه نوع متنی استفاده میشد.

ali586
یک شنبه 20 مهر 1399, 11:04 صبح
با سلام - والا زمان ما از nvarchar برای همه نوع متنی استفاده میشد.

سلام و درود
nvarchar در sql server هست و در my sql فقط varchar هست

ROSTAM2
یک شنبه 20 مهر 1399, 11:14 صبح
سلام و درود
nvarchar در sql server هست و در my sql فقط varchar هست

یعنی برا محتوای متنی نوع دیگه ای جر varchar نداره آیا تست کنی؟

https://dev.mysql.com/doc/refman/8.0/en/data-types.html

https://dev.mysql.com/doc/refman/8.0/en/string-type-syntax.html

ali586
یک شنبه 20 مهر 1399, 14:22 عصر
یعنی برا محتوای متنی نوع دیگه ای جر varchar نداره آیا تست کنی؟

https://dev.mysql.com/doc/refman/8.0/en/data-types.html

https://dev.mysql.com/doc/refman/8.0/en/string-type-syntax.html


بله وجود دارد ولی nvarchar وجود ندارد

ali586
یک شنبه 20 مهر 1399, 14:28 عصر
مشکل کد خودم رو بالاخره پیدا کردم و اینجا برای دوستان میذارم که اگه کسی با این مشکل روبرو شد بتونه حلش کنه.
مشکل در خط زیر بود که باید نوع دیتا را در param مشخص میکردم که به اشتباه یه تعدادی رو رشته ای زده بودم و یه تعدادی رو عددی زده بود که باید با توجه به دیتابیس نوع دیتا رو مشخص میکردم و مشکل حل شد.


$stmt->bind_param('siisiiissssiiiiisssssisss',$malicode,$ sabtenam,$noez,$shsh,$comtyear,$comtmonth,$comtday ,$fname,$lname,$faname,$statee,$sarbaz,$comayear,$ comamonth,$comaday,$isar,$adres,$state,$city,$code post,$malifcode,$tell,$mobi,$email,$pay);


انواع نوع دیتا رو هم میذارم که دوستان بتونن استفاده کنند

typesA string that contains one or more characters which specify the types for the corresponding bind variables:


Character
Description


i
corresponding variable has type integer


d
corresponding variable has type double


s
corresponding variable has type string


b
corresponding variable is a blob and will be sent in packets

mohammadasadi1
شنبه 01 آذر 1399, 09:42 صبح
فک کنم کداتو اشتباهی نوشتی کدتم پیچوندی میشه ساده هم نوشت