Phorum.ro
Your Avatar Welcome to Phorum.ro!
If you haven't registered yet, click here!
Attention Visitor:
You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.
Du-te înapoi   Phorum.ro > Web Design & Web Development > Programare > PHP > PHP DB

PHP DB Discutii despre lucrul cu baze de date in PHP.

Răspunde
 
Thread Tools Moduri de afișare
Vechi 28.02.2009   #1
ale_april
8-Bit Member
 
Data înregistrării: 28.02.2009
Mesaje: 3
Rep Power: 3
ale_april is on a distinguished road
Implicit adaugarea unei inregistrari

Buna!Am si eu o problema.Nu pot adauga inregistrari intr-o baza de date dintr-o pagina de html.Iata cum am lucrat:

pagina de html

<html>
<form action="ale2.php" method="POST">
Nume: <input type="text" name="nume"><br>
Intrebare: <input type="text" name="intrebare"><br>
<input type="hidden" name="raspuns" value="raspunde"></input>
<input type="Submit" value="Trimite datele">
</form>
</html>


ale2.php

<?php
$nume = $_POST['nume'];
$intrebare = $_POST['intrebare'];
$raspuns = $_POST['raspuns'];
$host = "localhost";
$user = "root";
$password = "";
$database = "atestat";
mysql_connect($host, $user, $password);
@mysql_select_db($database) or die( 'Nu se poate deschide BD' );
print "Connected to MySQL <br />";
$query = "INSERT INTO sfaturi VALUES($nume, $intrebare,$raspuns)";
mysql_query($query);
mysql_close();
echo 'Datele au fost inserate in tabel!';
?>
ale_april is offline   Reply With Quote
Sponsored Links
Vechi 28.02.2009   #2
Agkelos
LAMPist
 
Agkelos's Avatar
 
Data înregistrării: 15.01.2009
Locație: Cluj
Vârsta: 28
Mesaje: 95
Rep Power: 4
Agkelos is on a distinguished road
Implicit

Pare sa fie in regula. Ce eroare iti da?

Daca nu iti da nici o eroare, fa urmatoarea modificare:

Cod:
mysql_query($query) or die(mysql_error());
Agkelos is offline   Reply With Quote
Vechi 28.02.2009   #3
ale_april
8-Bit Member
 
Data înregistrării: 28.02.2009
Mesaje: 3
Rep Power: 3
ale_april is on a distinguished road
Implicit

Nu aparea nici o eroare.Am modificat si acum imi apare asha :

"; $query = "INSERT INTO sfaturi VALUES($nume, $intrebare,$raspuns)"; mysql_query($query) or die(mysql_error()); mysql_close(); echo 'Datele au fost inserate in tabel!'; ?>
ale_april is offline   Reply With Quote
Vechi 29.12.2009   #4
drops
32-Bit Member
 
drops's Avatar
 
Data înregistrării: 26.01.2007
Locație: Galati
Mesaje: 67
Rep Power: 6
drops is on a distinguished road
Implicit

Citat:
În prealabil postat de ale_april Vezi mesajul
Nu aparea nici o eroare.Am modificat si acum imi apare asha :

"; $query = "INSERT INTO sfaturi VALUES($nume, $intrebare,$raspuns)"; mysql_query($query) or die(mysql_error()); mysql_close(); echo 'Datele au fost inserate in tabel!'; ?>
Vezi ca nu ai inchis o " (ghilimea) unde trebuia si iti iese din query. Si vezi pune '$nume', '$intrebare', '$camp' daca ai campuri text sau varchar.
__________________
The best from the best

Last edited by drops; 29.12.2009 at 12:54:41.
drops is offline   Reply With Quote
Răspunde


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Moduri de afișare

Reguli de postare
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is Pornit
emoticoanele sunt Pornit
Codul [IMG] este Pornit
Codul HTML este Oprit



Ora este GMT +3. Ora este acum 17:29:07.


Rulează cu: vBulletin Version 3.8.4
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Forum SEO by Zoints

XXXXXXXXXXXXXXXXXXX
Inactive Reminders By Icora Web Design