Jump to content


Photo

Inserting


  • Please log in to reply
7 replies to this topic

#1 supanoob

supanoob
  • Members
  • PipPipPip
  • Advanced Member
  • 342 posts

Posted 17 July 2006 - 04:37 PM

well, i have the following code and for some reason it doesnt insert into the DB nothing happens nothing gets inserted

session_start();
require_once('dbconnect2.php');

$ip=($_SERVER['REMOTE_ADDR']);
$T1=$_POST['T1'];
$D1=$_POST['D1'];
$D2=$_POST['D2'];
$D3=$_POST['D3'];
$D4=$_POST['D4'];
$D5=$_POST['D5'];
$D6=$_POST['D6'];
$D7=$_POST['D7'];
$D8=$_POST['D8'];
$D9=$_POST['D9'];
$D10=$_POST['D10'];

$T1=trim($T1);
$D1=trim($D1);
$D2=trim($D2);
$D3=trim($D3);
$D4=trim($D4);
$D5=trim($D5);
$D6=trim($D6);
$D7=trim($D7);
$D8=trim($D8);
$D9=trim($D9);
$D10=trim($D10);



$query="insert into `match` (name, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10) values ('$T1', '$D1', '$D2', '$D3', '$D4', '$D5', '$D6', '$D7', '$D8', '$D9', '$D10')";
$result=mysql_query($query);

echo "You have added your name and answers to our Database. We will be in touch within the week.";


#2 Kurt

Kurt
  • Members
  • PipPipPip
  • Advanced Member
  • 42 posts
  • LocationNew York

Posted 17 July 2006 - 04:41 PM

Try changing:

$result=mysql_query($query);

to:

$result=mysql_query($query) or die(mysql_error());

to see what the error is.

#3 supanoob

supanoob
  • Members
  • PipPipPip
  • Advanced Member
  • 342 posts

Posted 17 July 2006 - 04:56 PM

i dont get an error it says it has submitted ok :S

#4 SammyP

SammyP
  • Members
  • PipPipPip
  • Advanced Member
  • 58 posts
  • LocationLondon

Posted 17 July 2006 - 05:03 PM

Have you checked mysql_affected_rows to see if it thinks a record has been inserted? If there is no error then it probably does. Which I'd suggest might mean the record is being inserted. I assume you've checked the number of records to ensure it isn't actually going in.

If all of that is fruitless then you have a ponderer in my opinion.

Sam.


If this has solved your problem, a quick 'Thanks' is appreciated, but marking the thread as 'Solved' is better - it saves a lot of time.

Sam.

#5 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 17 July 2006 - 05:29 PM

session_start();
require_once('dbconnect2.php');

$ip=($_SERVER['REMOTE_ADDR']);
$T1=$_POST['T1'];
$D1=$_POST['D1'];
$D2=$_POST['D2'];
$D3=$_POST['D3'];
$D4=$_POST['D4'];
$D5=$_POST['D5'];
$D6=$_POST['D6'];
$D7=$_POST['D7'];
$D8=$_POST['D8'];
$D9=$_POST['D9'];
$D10=$_POST['D10'];

$T1=trim($T1);
$D1=trim($D1);
$D2=trim($D2);
$D3=trim($D3);
$D4=trim($D4);
$D5=trim($D5);
$D6=trim($D6);
$D7=trim($D7);
$D8=trim($D8);
$D9=trim($D9);
$D10=trim($D10);


if($_POST['submit']){
$query="insert into `match` (name, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10) values ('$T1', '$D1', '$D2', '$D3', '$D4', '$D5', '$D6', '$D7', '$D8', '$D9', '$D10')";
$result=mysql_query($query);

echo "You have added your name and answers to our Database. We will be in touch within the week.";

}
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#6 SammyP

SammyP
  • Members
  • PipPipPip
  • Advanced Member
  • 58 posts
  • LocationLondon

Posted 17 July 2006 - 05:38 PM

I can't see what the previous post is on about (maybe it isn't finished) but I also should have mentioned that it is always worth echoing the SQL statement to yourself if it doesn't work, and then try applying it directly to the database rather than through PHP. Might get you some more clues.

Sam.
If this has solved your problem, a quick 'Thanks' is appreciated, but marking the thread as 'Solved' is better - it saves a lot of time.

Sam.

#7 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 17 July 2006 - 05:43 PM

give the insert a condition

what ever you have named the form ok.

if($POST['submit']){

insert

}
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#8 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 17 July 2006 - 05:47 PM

Post your database information so we can have a proper look ok.
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users