Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more  

Go Back   Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more > Web Programming > Databases - MySQL, SQL, Oracle, Access and others
User Name
Password

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 04-01-2008, 12:44 AM   #1 (permalink)
gncreditcards
Junior Member
 
Join Date: Jan 2008
Posts: 3
Default PHP and MySQL

Hi, I have this form in html . When it fills the information and send it fails to database information entry.

Why my php form fails to entry the information en the SQL

Thanks



<form method="post" action="/mailinglist/sender.php">
<table border="0" cellpadding="5" ><tr >
<td colspan="2">Unete ay recibe por email de noticias y actividades </td></tr>

<tr><td >E-mail:</td>
<td><input type="text" name="email" size="25"></td>
</tr><tr>
<td>Nombre:</td><td><input type="text" name="fname" size="25"></td></tr>
<tr><td>Apellido:</td>
<td><input type="text" name="lname" size="25"></td>
</tr><tr>
<td>Pais:</td>
<td><input type="text" name="country" size="25"></td>
</tr><tr>
<td colspan="2"align="center"><input type="submit" value="Enviar"></td>
</tr></table></form>



AND A SEND PHP FORM
$conn = mysql_connect("$localhost", "$usernam", "$pass") or die("Invalid server or user."); // Connects to MySQL Database
mysql_select_db("$db", $conn);

//function insert_mail() {

$fname = $_POST['fname'];
$lname = $_POST['lname'];
$email = $_POST['email'];
//}

$sql2="SELECT * FROM mail";
$result2=mysql_query($sql2) or die("select fails");
$no=mysql_num_rows($result2);

if ($no==0) {


$sql = mysql_query("insert into mail(id,fname,lname,email) values(NULL,'$fname','$lname','$email')");
$result = mysql_query($sql);
}
gncreditcards is offline   Reply With Quote
Sponsored Links
Old 04-08-2008, 10:45 AM   #2 (permalink)
awatson
Junior Member
 
Join Date: Mar 2008
Posts: 11
Default Re: PHP and MySQL

What error are you getting? Try adding:

Quote:
echo "<!-- $sql -->\n";

Before the "$result=..." and then view source on the page and copy the query. Then run the query on your database via phpmyadmin or command line and see what error you get.
__________________
awatson is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Points Per Thread View: 1.00
Points Per Thread: 11.00
Points Per Reply: 5.00



» Sponsors

» Links

» Affiliates
Web Hosting
Marketing Find
Merchant Select
SiteMap Builder
Host Compare
Dedicated Servers

» Links

» Sports Network
Paintball Forum
Football Forum
Hockey Forum
Golf Forum
Boxing Forum
Lacrosse Forum
Baseball Forum
SnowBoarding Forum
Soccer Forum
MMA Forum


All times are GMT -4. The time now is 04:36 AM.



LinkBacks Enabled by vBSEO 3.0.0 RC8
Webmaster Forums