Jump to content
php.lv forumi

No PHP uz MySQL, un no MySQL ārā uz failu


hujambo

Recommended Posts

Situācija ir tāda, ka lapā ar MySQL un php palīdzību izveidoju tabulu ar ko attēlot šo to, viss jau bija jauki līdz brīdim, kad radās nepieciešamība datus datubāzē ievietot nevis caur phpmyadmin, bet gan caur atsevišķu lapu. Iznākums ir tāds, ka dati kurus ievietoju caur phpmyadmin uzrādas ar visām garumzīmēm un mīkstinājuma zīmēm (datubāzes collation utf8_latvian_ci), bet dati kurus ievietoju no faila ir kroploti un nerāda to ko vajadzētu rādīt.

 

php fails ar visu funkciju

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-13" />
</head>
<body>
<?php
$host="localhost"; // Host name
$username="**********"; // Mysql username
$password="*********"; // Mysql password
$db_name="***********"; // Database name
$tbl_name="***********"; // Table name

// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
// Get values from form
$nosauk=$_POST['nosauk'];
$sacen=$_POST['sacen'];
$links=$_POST['links'];
$citainfo=$_POST['citainfo'];


// Insert data into mysql
$sql="INSERT INTO $tbl_name(npk, sacen, links, nosauk, citainfo)VALUES('', '$sacen', '$links', '$nosauk', '$citainfo')";
$result=mysql_query($sql);

// if successfully insert data into database, displays message "Successful".
if($result){
echo "Pievienots";
echo "<BR>";
echo "<a href='http://www.tsk-spriditis.lv/'>Atgriezties uz Sākumlapu</a>";
}

else {
echo "ERROR";
}
?>
</body>
</html>

 

html fails ar tabulu

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-13" />
</head>
<body>
<table width="300" border="0" align="center" cellpadding="0" cellspacing="1">
<tr>
<td><form name="form1" method="post" action="piev_orient.php">
<table width="100%" border="0" cellspacing="1" cellpadding="3">
<tr>
<td colspan="3"><strong>Pievienot Orientešanās rezultātus </strong></td>
</tr>
<tr>
<td width="71">Sacensības</td>
<td width="6">:</td>
<td width="301"><input name="sacen" type="text" id="sacen"></td>
</tr>
<tr>
<td>Links</td>
<td>:</td>
<td><input name="links" type="text" id="links"></td>
</tr>
<tr>
<td>Linka nosaukums</td>
<td>:</td>
<td><input name="nosauk" type="text" id="nosauk"></td>
</tr>
<tr>
<td>Cita informācija</td>
<td>:</td>
<td><input name="citainfo" type="text" id="citainfo"></td>
</tr>
<tr>
<td colspan="3" align="center"><input type="submit" name="Pievienot" value="Pievienot"></td>
</tr>
</table>
</form>
</td>
</tr>
</table>
</body>
</html>

Kādi ieteikumi kā to novērst?

Edited by hujambo
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...