Im trying to insert the userid into my table in a php file upload system.Every other value is properly getting inserted except the userid.Heres the code:
<?php
session_start();
$userid = $_SESSION['id'];
$id1 = $_GET['id'];
include_once "connect_to_mysql.php";
function savedata(){
global $_FILES, $_POST, $putItAt;
$sql = "INSERT INTO files (
ID ,
userid ,
Time ,
FileLocation ,
IP ,
Title
)
VALUES (
NULL ,'$id1' , UNIX_TIMESTAMP( ) , '".mysql_real_escape_string($putItAt)."', '".$_SERVER['REMOTE_ADDR']."', '".mysql_real_escape_string($_POST['title'])."'
);";
mysql_query($sql);
}
any way around this?
According to comments, i think the trouble is that
$id1isn’t accessable insavedata()function. So you need to declate$id1global inside function or use$_GET['id']in you sql-query, likeVALUES (NULL , " . $_GET['id'] . " , UNIX_TIMESTAMP( ).