Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 09-25-2008, 04:18 PM   PM User | #1
Arsench
New to the CF scene

 
Join Date: Sep 2007
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Arsench is an unknown quantity at this point
Question Data insert

Hello, the next code is in the reg_index.php and ind_index.php.

when Im clicking to insert data, its returns empty in db. even doesnt show on the page after clicking submit.Please is there any error?All the rest of code is work only this cant understand the problem.
The code is.

reg_index.php
///////////////////////////
<form action="ind_insert.php" >
.Nombre del Curso
<input name="name" type="text" id="name" >
<br>
Numero_indice
<input name="number" type="text" id="number">
<br>
Numero_programa
<input name="chapter" type="text" id="chapter" >
<br>
<input type="submit" name="Submit" value="ENVIAR">

</form>
/////////////////////////////// end of reg_insert.php
-----------------------------------------------------------------------------
the ind_insert.php
<?php
include'db.php'; //connection to DB

$name=$_POST['name'];
$number=$_POST['number'];
$chapter=$_POST['chapter'];

$q = "INSERT INTO prog VALUES ('','$name','$number','$chapter')";
if(!mysql_query($q))
{
die(' Error: ' .mysql_error());
}
else
{
echo"Data Inserted was:";
echo"<br>";
echo"<br>";
echo"$name";
echo"<br>";
echo"$number";
echo"<br>";
echo"$chapter";

}
/////// RETURNS EMPTY AFTER CLICKING ENVIAR //////////

?>
////////////// end of ind_insert.php

thank you very very much
__________________
Arsen Khachatryan
---------------------------------
Do you think making money is hard?If so,You haven't clicked yet!!!
http://www.khaarsen.com/Paid_to_click.php
Arsench is offline   Reply With Quote
Old 09-25-2008, 04:43 PM   PM User | #2
masterofollies
Senior Coder

 
Join Date: May 2005
Posts: 2,137
Thanks: 96
Thanked 72 Times in 72 Posts
masterofollies can only hope to improve
Instead of this

Code:
$q = "INSERT INTO prog VALUES ('','$name','$number','$chapter')";
Try this

Code:
$q = "INSERT INTO prog VALUES (''name='$name',number='$number',chapter='$chapter')";
masterofollies is offline   Reply With Quote
Old 09-25-2008, 05:07 PM   PM User | #3
CFMaBiSmAd
Senior Coder

 
CFMaBiSmAd's Avatar
 
Join Date: Oct 2006
Location: Denver, Colorado USA
Posts: 2,712
Thanks: 2
Thanked 251 Times in 243 Posts
CFMaBiSmAd is a jewel in the roughCFMaBiSmAd is a jewel in the roughCFMaBiSmAd is a jewel in the roughCFMaBiSmAd is a jewel in the rough
Your <form tag is missing a method="post" parameter, so it is using the GET mode by default and the $_POST variables are not being set.
__________________
If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.
CFMaBiSmAd is online now   Reply With Quote
Old 09-25-2008, 05:39 PM   PM User | #4
Fumigator
UE Antagonizer


 
Fumigator's Avatar
 
Join Date: Dec 2005
Location: Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
Posts: 7,686
Thanks: 42
Thanked 637 Times in 625 Posts
Fumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of light
You need method="post" on your form tag.

(edit aww shoot I took too long to respond and CFMaBiSmAd beat me to it -- stupid job-related distractions)
__________________
Fumigator is offline   Reply With Quote
Old 09-25-2008, 05:47 PM   PM User | #5
_Aerospace_Eng_
Supreme Master coder!


 
_Aerospace_Eng_'s Avatar
 
Join Date: Dec 2004
Location: In a place far, far away...
Posts: 19,293
Thanks: 2
Thanked 1,044 Times in 1,020 Posts
_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light
Quote:
Originally Posted by masterofollies View Post
Instead of this

Code:
$q = "INSERT INTO prog VALUES ('','$name','$number','$chapter')";
Try this

Code:
$q = "INSERT INTO prog VALUES (''name='$name',number='$number',chapter='$chapter')";
And don't use that as it will error out. You also have an unneeded comma.
PHP Code:
$q "INSERT INTO prog VALUES ('$name','$number','$chapter')"
__________________
||||If you are getting paid to do a job, don't ask for help on it!||||
_Aerospace_Eng_ is offline   Reply With Quote
Old 09-25-2008, 07:27 PM   PM User | #6
masterofollies
Senior Coder

 
Join Date: May 2005
Posts: 2,137
Thanks: 96
Thanked 72 Times in 72 Posts
masterofollies can only hope to improve
Well it works on my website just fine.
masterofollies is offline   Reply With Quote
Reply

Bookmarks

Tags
data, error, insert, mysql

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
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 On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:14 PM.


Advertisement
Log in to turn off these ads.