Log in

View Full Version : values not inserting



solarcom
03-28-2008, 07:39 AM
:confused: :mad: This worked in php4 ,but it doesn't work in Php5, the 'id' and 'active' are inserted but the variable values aren't. i get empty fields
I tried without the
$na=$_POST[$name];
$em=$_POST[$email];
lines and got the same result, using (NULL,'$name','$email','active')"; instead of (NULL,'$na','$em','active')";

Also get the same result with no "`" around the column names. I also tried single quotes after the = sign and at the end instead of double and got a T_varible error message. This is part of a larger script and everything else works, just this rather neccessary part, there are no repeated varible names, and I've tried exactly as shown in its own little script and keep getting no data inserted in the varible fields

before everything was inserted
id name email status
20 Debbie notrealemail@com.ca active

now I get
id name email status
21 blankspace blankspace active

<?php
include("connect.php");
include("header.php");
?>
<FORM METHOD="post" ACTION="insertdatav.php">
<p>Name <INPUT TYPE="text" NAME="name" SIZE="30"><br><br>
<p>Email <INPUT TYPE="text" NAME="email" SIZE="30"><br><br>
<INPUT TYPE="submit" NAME="submit" VALUE="Join"></FORM>
<?php
include("footer.php");
?>


insertdatav.php :
<?php
include("connect.php");
$na=$_POST[$name];
$em=$_POST[$email];
$sql="INSERT INTO list (`id`,`name`,`email`,`status`) VALUES (NULL,'$na','$em','active')";
mysql_query($sql);
include("test.php");
?>

And is there a way around the VERY ANNOYING fact that you can't use a full path name with include? Seriously, if the decision was mine that alone would be enough reason roll back to php 4. I got 15 folders for some websites, more being added, and copying the header, footer and connect files in every folder is RIDICULOUS

codeexploiter
03-28-2008, 08:34 AM
Make the highlighted changes in the following your code



<?php
include("connect.php");
$na=$_POST["name"];
$em=$_POST["email"];
$sql="INSERT INTO list (`id`,`name`,`email`,`status`) VALUES (NULL,'$na','$em','active')";
mysql_query($sql);
include("test.php");
?>

solarcom
03-28-2008, 01:56 PM
Thanks but it didn't work

neither did

$na=$_GET["$name"];
$em=$_GET["$email"];

or

$na=$_GET['$name'];
$em=$_GET['$email'];

or

$_GET["$name"];
$_GET["$email"];

putting everything in one script

<?php
include("connect.php");
include("header.php");
?>
<FORM METHOD="post" ACTION="">
<p>Name <INPUT TYPE="text" NAME="name" SIZE="30"><br><br>
<p>Email <INPUT TYPE="text" NAME="email" SIZE="30"><br><br>
<INPUT TYPE="submit" NAME="submit" VALUE="Join"></FORM>
<?php
if(isset( $submit ))
{
$sql="INSERT INTO list (`id`,`name`,`email`,`status`) VALUES (NULL,'$name','$email','active')";
mysql_query($sql);
}
include("footer.php");
?>

and nothing at all gets inserted, nothing happens, no blank spaces, no 'active',
nothing

so I try

if(isset( $submit ))
{
$sql="INSERT INTO list (`id`,`name`,`email`,`status`) VALUES (NULL,'$name','$email','active')";
mysql_query($sql) or die(mysql_error());
}

nothing inserted and no error message

ditto with

if(isset( $submit ))
{
$sql="INSERT INTO list (`id`,`name`,`email`,`status`) VALUES (NULL,'$name','$email','active')";
mysql_query($sql);
}
if (!$sql)
{
die(mysql_error());
}

thetestingsite
03-28-2008, 09:03 PM
insertdatav.php :


<?php
include("connect.php");
$na=$_POST['name'];
$em=$_POST['email'];
$sql="INSERT INTO list (`id`,`name`,`email`,`status`) VALUES (NULL,'$na','$em','active')";
mysql_query($sql);
include("test.php");
?>


That should do it. Hope this helps.

solarcom
03-29-2008, 05:08 AM
It works thank you all. And I got a solution to uploading to multiple folders. A little script that does just that

<form method="POST" action="upload" enctype="multipart/form-data">
<input type="file" name="header" size="59">
<INPUT TYPE="submit" NAME="submit" VALUE="Upload"></FORM>

if( $_FILES['header']['size'] >0)
{
copy ($_FILES['header']['tmp_name'], "/home/username/public_html/newsletter/images/".$_FILES['header']['name']) or die ("Could not copy.....");
$header=$_FILES['header']['name'];
copy ($_FILES['header']['tmp_name'], "/home/username/public_html/tru2life/".$_FILES['header']['name']) or die ("Could not copy.....");
$header=$_FILES['header']['name'];
copy ($_FILES['header']['tmp_name'], "/home/username/public_html/10seconds/".$_FILES['header']['name']) or die ("Could not copy.....");
$header=$_FILES['header']['name'];
}

I just expand it for every folder I want to copy to and do the same thing for footer and connect. I get all the bonuses of php5 and still get one click upload to multiple folders. Takes up a little extra space on the server but with these small scripts and the price of memory these days, big deal