Jump to content

Inserting session variables into a table


182x

Recommended Posts

Hey guys, I am using the following code to try to insert a record into a table but its not working and I was just wondering why and also it has to work with an older version of PHP 4.x so i was just wondering is this possible?

Thanks for any help.


[code]

<?php
session_start();
include('db.php');
$link_id = db_connect('');

$query="INSERT INTO c (cur) VALUES('$HTTP_SESSION_VARS['curr']')";

mysql_query($query, $link_id);

header("location:de.php");

?>

[/code]
Link to comment
https://forums.phpfreaks.com/topic/27537-inserting-session-variables-into-a-table/
Share on other sites

here is an example of how to insert into a mysql database
[code]
<?php
session_start();
$_SESSION['favcolor'] = "green"; // green
$_SESSION['animal'] = "cat";  // cat

$query="INSERT INTO c (`favcolor`,`animal`) VALUES('$_SESSION[favcolor]','$_SESSION[animal]')";

mysql_query($query, $link_id);
header("location:de.php");
?>
[/code]

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.