co mam na nasledujicim kodu spatne? ma zapsat data do databaze mysql ale nefeunguje to..
-----formular.html--------
<form action="obsluha.php" method="POST">
<input type="text" name="jmeno">
<input type="submit">
</form>
---------obsluha.php--------------
<?
if(isset($_POST['jmeno'])){
$dbuser="root";
$dbpass="root";
$dbname="rs";
$chandle = mysql_connect("localhost", $dbuser, $dbpass)
or die("Connection Failure to Database");
mysql_select_db($dbname, $chandle) or die ($dbname . " Database not found." . $dbuser);
mysql_query("INSERT INTO rs (text) VALUES '$jmeno' ");
}
?>
<?php
include ("mysql_spojit.php");
$query = "SELECT * FROM rs ORDER BY id";
$result = mysql_query($query, $link) or die ("SQL dotaz nešlo provést.");
while ($row=mysql_fetch_array($result))
echo "".$row["text"]."";
mysql_free_result($result);
mysql_close();
?>
Fórum › PHP
Zapis dat do mysql

zdravim,
prvni pohled, v podmince pouzivas $_POST['jmeno'], ale v dotazu potom uz jen $jmeno, pokud je register_globals na off($_POST['jmeno'] neni $jmeno), tak je v promenne $jmeno prazdna hodnota - NULL, zjistis jednoduse, kdyz si das
echo "INSERT INTO rs (text) VALUES '$jmeno' ";
tim uvidis, co je v dotazu, pokud je dotaz spravne, tkaze misto jmena se opravdu doplnilo to co ches, tak muzes zkusit dat
echo mysql_error();
, vypise to pripadnou chybu mysql ...
Přidej příspěvek
Toto téma je starší jak čtvrt roku – přidej svůj příspěvek jen tehdy, máš-li k tématu opravdu co říct!
Ano, opravdu chci reagovat → zobrazí formulář pro přidání příspěvku
×Vložení zdrojáku
×Vložení obrázku
×Vložení videa
Aktuálně jsou podporována videa ze serverů YouTube, Vimeo a Dailymotion.
×






























































Uživatelé prohlížející si toto vlákno
Uživatelé on-line: 0 registrovaných, 42 hostů
Podobná vlákna
Mysql list pridanie policka input zapis do mysql — založil Rastislav
Zápis dat do CSV z UDP — založil Michal
Obecné čtení(zápis) dat — založil lojza
Zápis do mysql — založil FanatiK
MySQL Zapis — založil zelenac1
Moderátoři diskuze