|
|
|
บันทึกข้อมูลลงฐานข้อมูลไม่ได้ Error :: No database selected |
|
|
|
|
|
|
|
Code (PHP)
<?php
$host="localhost";
$user="root";
$pass="1234";
$db="kline";
mysql_connect($host,$user,$pass) or die ("can't connect db");
mysql_select_db($db) or die ("can't connect db");
mysql_query("SET NAMES 'UTF8'");
?>
Code (PHP)
<?php
include("connect.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>customer</title><style type="text/css">
<!--
body {
background-image: url(Image/12351.jpg);
background-color: #FFFFCC;
}
-->
</style>
<link href="SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" />
<link href="SpryAssets/SpryValidationRadio.css" rel="stylesheet" type="text/css" />
<link href="SpryAssets/SpryValidationSelect.css" rel="stylesheet" type="text/css" />
<link href="SpryAssets/SpryValidationTextarea.css" rel="stylesheet" type="text/css" />
<script src="Scripts/swfobject_modified.js" type="text/javascript"></script>
<script src="SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>
<script src="SpryAssets/SpryValidationRadio.js" type="text/javascript"></script>
<script src="SpryAssets/SpryValidationSelect.js" type="text/javascript"></script>
<script src="SpryAssets/SpryValidationTextarea.js" type="text/javascript"></script>
<script type="text/javascript">
<!--
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_nbGroup(event, grpName) { //v6.0
var i,img,nbArr,args=MM_nbGroup.arguments;
if (event == "init" && args.length > 2) {
if ((img = MM_findObj(args[2])) != null && !img.MM_init) {
img.MM_init = true; img.MM_up = args[3]; img.MM_dn = img.src;
if ((nbArr = document[grpName]) == null) nbArr = document[grpName] = new Array();
nbArr[nbArr.length] = img;
for (i=4; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
if (!img.MM_up) img.MM_up = img.src;
img.src = img.MM_dn = args[i+1];
nbArr[nbArr.length] = img;
} }
} else if (event == "over") {
document.MM_nbOver = nbArr = new Array();
for (i=1; i < args.length-1; i+=3) if ((img = MM_findObj(args[i])) != null) {
if (!img.MM_up) img.MM_up = img.src;
img.src = (img.MM_dn && args[i+2]) ? args[i+2] : ((args[i+1])? args[i+1] : img.MM_up);
nbArr[nbArr.length] = img;
}
} else if (event == "out" ) {
for (i=0; i < document.MM_nbOver.length; i++) {
img = document.MM_nbOver[i]; img.src = (img.MM_dn) ? img.MM_dn : img.MM_up; }
} else if (event == "down") {
nbArr = document[grpName];
if (nbArr)
for (i=0; i < nbArr.length; i++) { img=nbArr[i]; img.src = img.MM_up; img.MM_dn = 0; }
document[grpName] = nbArr = new Array();
for (i=2; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
if (!img.MM_up) img.MM_up = img.src;
img.src = img.MM_dn = (args[i+1])? args[i+1] : img.MM_up;
nbArr[nbArr.length] = img;
} }
}
//-->
</script>
</head>
<body onload="MM_preloadImages('Image/ab2.jpg','Image/bc2.jpg','Image/bh2.jpg','Image/bs2.jpg')">
<table width="769" height="748" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="180" colspan="2" bgcolor="#009900"><object id="FlashID" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="1000" height="180">
<param name="movie" value="flash/titlehead.swf" />
<param name="quality" value="high" />
<param name="wmode" value="opaque" />
<param name="swfversion" value="8.0.35.0" />
<!-- This param tag prompts users with Flash Player 6.0 r65 and higher to download the latest version of Flash Player. Delete it if you don’t want users to see the prompt. -->
<param name="expressinstall" value="Scripts/expressInstall.swf" />
<!-- Next object tag is for non-IE browsers. So hide it from IE using IECC. -->
<!--[if !IE]>-->
<object type="application/x-shockwave-flash" data="flash/titlehead.swf" width="1000" height="180">
<!--<![endif]-->
<param name="quality" value="high" />
<param name="wmode" value="opaque" />
<param name="swfversion" value="8.0.35.0" />
<param name="expressinstall" value="Scripts/expressInstall.swf" />
<!-- The browser displays the following alternative content for users with Flash Player 6.0 and older. -->
<div>
<h4>Content on this page requires a newer version of Adobe Flash Player.</h4>
<p><a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" width="112" height="33" /></a></p>
</div>
<!--[if !IE]>-->
</object>
<!--<![endif]-->
</object></td>
</tr>
<tr>
<td width="235" height="508" align="center" valign="bottom" bgcolor="#009900"><table width="235" border="0" cellpadding="0" cellspacing="0">
<tr>
<td valign="bottom"><img src="Image/mom.jpg" width="235" height="150" /></td>
</tr>
</table></td>
<td width="535" valign="top" bgcolor="#FFFFFF"><table width="530" border="0" cellpadding="0" cellspacing="3" bgcolor="#55BC50">
<tr>
<td width="130"><a href="page/home.html" target="_top" onclick="MM_nbGroup('down','group1','bh','',1)" onmouseover="MM_nbGroup('over','bh','../Image/bh2.jpg','',1)" onmouseout="MM_nbGroup('out')"><img src="Image/bh.jpg" alt="" name="bh" border="0" id="bh2" onload="" /></a></td>
<td width="130"><a href="page/aboutus.html" target="_top" onclick="MM_nbGroup('down','group1','ab','',1)" onmouseover="MM_nbGroup('over','ab','../Image/ab2.jpg','',1)" onmouseout="MM_nbGroup('out')"><img src="Image/ab.jpg" alt="" name="ab" border="0" id="ab2" onload="" /></a></td>
<td width="130"><a href="page/services.html" target="_top" onclick="MM_nbGroup('down','group1','bs','',1)" onmouseover="MM_nbGroup('over','bs','../Image/bs2.jpg','',1)" onmouseout="MM_nbGroup('out')"><img src="Image/bs.jpg" alt="" name="bs" border="0" id="bs2" onload="" /></a></td>
<td width="130"><a href="page/contacts.html" target="_top" onclick="MM_nbGroup('down','group1','bc','',1)" onmouseover="MM_nbGroup('over','bc','../Image/bc2.jpg','',1)" onmouseout="MM_nbGroup('out')"><img src="Image/bc.jpg" alt="" name="bc" border="0" id="bc2" onload="" /></a></td>
</tr>
</table>
<table width="532" height="75" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<th height="75" align="right" scope="col"><img src="Image/fontcustomer.png" width="370" height="65" /></th>
</tr>
</table>
<form action="customer_form_ins.php" method="POST" enctype="multipart/form-data" name="services_customer" id="services_customer">
<fieldset>
<legend>Services - Customer</legend>
<table width="528" align="center">
<tr>
<td width="181" align="right" valign="middle">Consinee_name :</td>
<td width="331"><span id="sprytextfield1">
<input name="consinee_name" type="text" id="consinee_name" size="50" maxlength="50" />
<span class="textfieldRequiredMsg">A value is required.</span></span></td>
</tr>
<tr>
<td align="right" valign="middle">Type of transport :</td>
<td><span id="spryradio1">
<label>
<input name="type" type="radio" id="type_0" value="import" />
Import</label>
<br />
<label>
<input type="radio" name="type" value="export" id="type_1" />
Export</label>
<br />
<span class="radioRequiredMsg">Please make a selection.</span></span></td>
</tr>
<tr>
<td align="right" valign="middle">By :</td>
<td><span id="spryselect1">
<select name="at" id="at">
<option value="air">AIR</option>
<option value="sea">SEA</option>
<option value="truck">TRUCK</option>
</select>
<span class="selectRequiredMsg">Please select an item.</span></span></td>
</tr>
<tr>
<td align="right" valign="middle">Vessel :</td>
<td><span id="sprytextfield2">
<input name="vessel" type="text" id="vessel" size="50" maxlength="50" />
<span class="textfieldRequiredMsg">A value is required.</span></span></td>
</tr>
<tr>
<td align="right" valign="middle">Port :</td>
<td><span id="sprytextfield3">
<input name="port" type="text" id="port" size="50" maxlength="50" />
<span class="textfieldRequiredMsg">A value is required.</span></span></td>
</tr>
<tr>
<td align="right" valign="middle">B/L No. :</td>
<td><span id="sprytextfield4">
<input name="bl_no" type="text" id="bl_no" size="50" maxlength="50" />
<span class="textfieldRequiredMsg">A value is required.</span></span></td>
</tr>
<tr>
<td align="right" valign="middle">Invoice No. :</td>
<td><label><span id="sprytextfield5">
<input name="inv_no" type="text" id="inv_no" size="50" maxlength="50" />
<span class="textfieldRequiredMsg">A value is required.</span></span></label>
</td>
</tr>
<tr>
<td rowspan="2" align="right" valign="middle">Container Volume :</td>
<td><span id="sprytextfield6">
<input name="cont20" type="text" id="cont20" maxlength="5" />
</span>x20 GP</td>
</tr>
<tr>
<td><span id="sprytextfield7">
<input name="cont40" type="text" id="cont40" maxlength="5" />
<span class="textfieldInvalidFormatMsg">Invalid format.</span></span>x40 GP</td>
</tr>
<tr>
<td align="right" valign="middle">Packages :</td>
<td><span id="sprytextfield8">
<input name="packages" type="text" id="packages" maxlength="10" />
<span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span>Bags</td>
</tr>
<tr>
<td align="right" valign="middle">Gross weight :</td>
<td><span id="sprytextfield9">
<input name="gross_weight" type="text" id="gross_weight" maxlength="15" />
<span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span>Kgs</td>
</tr>
<tr>
<td align="right" valign="middle">Description :</td>
<td><span id="sprytextarea1">
<textarea name="description" id="description" cols="50" rows="6"></textarea>
</span></td>
</tr>
<tr>
<td align="right" valign="middle">Attach B/L :</td>
<td><input type="file" name="file_bl" id="file_bl" /></td>
</tr>
<tr>
<td align="right" valign="middle">Attach Invoice :</td>
<td><input type="file" name="file_inv" id="file_inv" /></td>
</tr>
</table>
</fieldset>
<table width="200" align="center">
<tr>
<td align="center"><input name="submit" type="submit" id="submit" value="Submit" /></td>
<td align="center"><input type="reset" name="reset" id="reset" value="Reset" /></td>
</tr>
</table>
</form></td>
</tr>
<tr>
<td height="60" colspan="2" bgcolor="#FFFFFF"><img src="Image/foot1.jpg" width="1000" height="78" /></td>
</tr>
</table>
<script type="text/javascript">
swfobject.registerObject("FlashID");
var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1", "none", {validateOn:["blur", "change"]});
var spryradio1 = new Spry.Widget.ValidationRadio("spryradio1", {validateOn:["blur", "change"]});
var spryselect1 = new Spry.Widget.ValidationSelect("spryselect1", {validateOn:["change", "blur"]});
var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2", "none", {validateOn:["blur", "change"]});
var sprytextfield3 = new Spry.Widget.ValidationTextField("sprytextfield3", "none", {validateOn:["blur", "change"]});
var sprytextfield4 = new Spry.Widget.ValidationTextField("sprytextfield4", "none", {validateOn:["blur", "change"]});
var sprytextfield5 = new Spry.Widget.ValidationTextField("sprytextfield5", "none", {validateOn:["blur", "change"]});
var sprytextfield6 = new Spry.Widget.ValidationTextField("sprytextfield6", "none", {validateOn:["blur", "change"], isRequired:false});
var sprytextfield7 = new Spry.Widget.ValidationTextField("sprytextfield7", "integer", {validateOn:["blur", "change"], isRequired:false});
var sprytextfield8 = new Spry.Widget.ValidationTextField("sprytextfield8", "integer", {validateOn:["blur", "change"]});
var sprytextfield9 = new Spry.Widget.ValidationTextField("sprytextfield9", "currency", {validateOn:["blur", "change"]});
var sprytextarea1 = new Spry.Widget.ValidationTextarea("sprytextarea1", {validateOn:["blur", "change"], isRequired:false});
</script>
</body>
</html>
Code (PHP)
<?php
session_start();
?>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<?php
include("connect.php");
if(move_uploaded_file($_FILES["file_bl"]["tmp_name"],"upload/".$_FILES["file_bl"]["name"]))
{
echo "Copy/Upload Complete<br>";
}
if(move_uploaded_file($_FILES["file_inv"]["tmp_name"],"upload/".$_FILES["file_inv"]["name"]))
{
echo "Copy/Upload Complete<br>";
}
/*$strSQLref = "INSERT INTO refnumber(refnumberID,refnumberyear,refnumberno)
VALUES ('".$refid."','".date("Y")."','".$refno."')";
$objQueryref = mysql_query($strSQLref); */
$strSQL1 = "INSERT INTO services_customer(consinee_name,type,at,vessel,port,bl_no,inv_no,cont20,cont40,packages,gross_weight,description,file_bl,file_inv)
VALUES (
'".$_POST["consinee_name"]."',
'".$_POST["type"]."',
'".$_POST["at"]."',
'".$_POST["vessel"]."',
'".$_POST["port"]."',
'".$_POST["bl_no"]."',
'".$_POST["inv_no"]."',
'".$_POST["cont20"]."',
'".$_POST["cont40"]."',
'".$_POST["packages"]."',
'".$_POST["gross_weight"]."',
'".$_POST["description"]."',
'".$_FILES["file_bl"]["name"]."',
'".$_FILES["file_inv"]["name"]."',
";
$objQuery1 = mysql_query($strSQL1);
mysql_close();
mysql_query($strSQL1) or die(mysql_error())
?>
echo "<script>
alert('บันทึกข้อมูลเรียบร้อย');
</script>";
Tag : PHP
|
|
|
|
|
|
Date :
2012-12-22 22:47:12 |
By :
flintstone |
View :
1444 |
Reply :
3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
คุณบอกว่า Error :: No database selected ก็หมายถึงว่าหา db ตัวนั้นไม่เจอ ชื่อ db ผิดหรือเปล่าครับ หรือไม่งั้นก็โพสรูป database มาให้ดูด้วยครับ
|
|
|
|
|
Date :
2012-12-22 23:51:39 |
By :
kokiflam |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
$strSQL1 = "INSERT INTO services_customer(consinee_name,type,at,vessel,port,bl_no,inv_no,cont20,cont40,packages,gross_weight,description,file_bl,file_inv)
VALUES (
'".$_POST["consinee_name"]."',
'".$_POST["type"]."',
'".$_POST["at"]."',
'".$_POST["vessel"]."',
'".$_POST["port"]."',
'".$_POST["bl_no"]."',
'".$_POST["inv_no"]."',
'".$_POST["cont20"]."',
'".$_POST["cont40"]."',
'".$_POST["packages"]."',
'".$_POST["gross_weight"]."',
'".$_POST["description"]."',
'".$_FILES["file_bl"]["name"]."',
'".$_FILES["file_inv"]["name"]."',
";
$objQuery1 = mysql_query($strSQL1);
mysql_close();
mysql_query($strSQL1) or die(mysql_error());
ผมว่าน่าจะเกิดจาก บรรทัดที่ 43 ครับ mysql_query($strSQL1) or die(mysql_error())
เนื่องจากได้ปิดการเชื่อมต่อ mysql_close(); แต่ข้อมูลน่าจะเข้าไปแล้วน่ะครับ เพราะมีการ คิวรี่จากบรรทัดนี้แล้ว
$objQuery1 = mysql_query($strSQL1);
ผมอยากรู้ว่า บรรทัดนี้ใช้ทำอะไร mysql_query($strSQL1) or die(mysql_error()); ลบออกเลยก็ได้น่ะครับ
ผิดถูกลองดูครับ
|
|
|
|
|
Date :
2012-12-23 01:44:45 |
By :
chaynuwong |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ขอบคุณมากๆครับ ตอนนี้สามารถดึงลงฐานข้อมูลได้แล้วครับ
|
|
|
|
|
Date :
2012-12-23 05:09:38 |
By :
flintstone |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 05
|