PDA

View Full Version : اصلاح کد خواندن اطلاعات از اکسس و ثبت در Mysql



rash44
پنج شنبه 02 آذر 1391, 07:49 صبح
با سلام

لطفا این کد را اصلاح کنید . به تعداد رکوردهای موجود در جدول اکسس ، در my sql رکورد ایجاد می شود ولی مقادیر فیلدها خالی است .


<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<?php
// Connect To Access
$conn=odbc_connect('con','','');
$sql="SELECT * FROM `Honarjoo_info`";
$rs=odbc_do($conn,$sql);
// Connect To Mysql
$link = mysql_connect('localhost', 'root', '');
if (!$link) {
die('Not connected : ' . mysql_error());
}

// make foo the current db
$db_selected = mysql_select_db('convert2', $link);
if (!$db_selected) {
die ('Can\'t use DataBase : ' . mysql_error());
}
while($res = odbc_fetch_row($rs))
{
//
$name = $res['نام'];
$family = $res['نام خانوادگی'];
$sex = $res['جنسیت'];
$father = $res['نام پدر'];
$shsh = $res['shsh'];
$meli = $res['کد ملی'];
$bdate = $res['تاریخ تولد'];
$bmahal = $res['محل تولد'];
$sadereh = $res['sadereh'];
$grade = $res['مدرک تحصیلی'];
$nezam = $res['وضعیت نظام'];
$address = $res['آدرس'];
$tel = $res['تلفن'];
$mobile = $res['تلفن همراه'];
$cardex_no= $res['cardex_no'];
$cardex_date = $res['cardex_date'];
$cardex_sader = $res['cardex_sader'];
$reg_date = $res['reg_date'];
$doctor = $res['doctor'];
$registered_by = $res['registered_by'];
$image= $res['image'];
$enseraf= $res['enseraf'];
$gavahi_date = $res['gavahi_date'];
$statusmali = $res['status'];
//
$q="insert into `Honarjoo_info` (`name`,`family`,`sex`,`father`,`shsh`,`meli`,`bda te`,`bmahal`,`sadereh`,`grade`,`nezam`,`address`,` tel`,`mobile`,`cardex_no`,`cardex_date`,`cardex_sa der`,`reg_date`,`doctor`,`registered_by`,`image`,` enseraf`,`gavahi_date`,`statusmali`) VALUES ('$name','$family','$sex','$father','$shsh','$meli ','$bdate','$bmahal','$sadereh','$grade','$nezam', '$address','$tel','$mobile','$cardex_no','$cardex_ date','$cardex_sader','$reg_date','$doctor','$regi stered_by','$image','$enseraf','$gavahi_date','$st atusmali')";
$result = mysql_query($q);
}
?>

MRmoon
پنج شنبه 02 آذر 1391, 08:45 صبح
نگا شما value ندادی و فقط خالی میسازه!

باید زیرش این رو بذاری :


VALUES('$user','$pw','$first','$last','$em') ")

به جای متغییر های من متغییر های خودت بذار.

rash44
پنج شنبه 02 آذر 1391, 09:34 صبح
کوئری به این صورت نوشتم :


$q="insert into `Honarjoo_info` (`name`,`family`,`sex`,`father`,`shsh`,`meli`,`bda te`,`bmahal`,`sadereh`,`grade`,`nezam`,`address`,` tel`,`mobile`,`cardex_no`,`cardex_date`,`cardex_sa der`,`reg_date`,`doctor`,`registered_by`,`image`,` enseraf`,`gavahi_date`,`statusmali`) VALUES ('$name','$family','$sex','$father','$shsh','$meli ','$bdate','$bmahal','$sadereh','$grade','$nezam', '$address','$tel','$mobile','$cardex_no','$cardex_ date','$cardex_sader','$reg_date','$doctor','$regi stered_by','$image','$enseraf','$gavahi_date','$st atusmali')";


کوئری هم درسته فقط مقادیر متغیرها تهی هست