Jump to content

Recommended Posts

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

[code]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.";[/code]
Link to comment
https://forums.phpfreaks.com/topic/14859-inserting/
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/14859-inserting/#findComment-59496
Share on other sites

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.";

}
Link to comment
https://forums.phpfreaks.com/topic/14859-inserting/#findComment-59507
Share on other sites

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.
Link to comment
https://forums.phpfreaks.com/topic/14859-inserting/#findComment-59514
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.