Rhawn Posted January 22, 2007 Share Posted January 22, 2007 I am creating an outlink .php file. Users are linked to my .php file, which sends them to another link.I am trying to pull some data into a database I made. The database is created, the table is name kw_track. It has 3 columns: Site, Timestamp, Keyword.Here is some code I copied and altered, but does not work. It is not inserting any data into the table.[code]<php>header("Location: http://www.outsidelink.com/");?>$now=time();$dbh=mysql_connect ("localhost", "username", "password") or die ('I cannot connect to the database because: ' . mysql_error());mysql_select_db ("database name");$res = mysql_query("INSERT INTO `kw_track` (`Website`, `Time_Stamp`, `Keyword`)VALUES ('$site', '$now', '$keywordvar')",$dbh);[/code]The values $site and $keywordvar are hopefully passed from the original link.Any help is appreciated Link to comment https://forums.phpfreaks.com/topic/35148-newbie-question-populating-sql-data/ Share on other sites More sharing options...
printf Posted January 22, 2007 Share Posted January 22, 2007 If there past by a query string, then they are $_GET type variables, so you need to assign them using $_GET[code]$now = time ();mysql_connect ( 'localhost', 'username', 'password' ) or die ( 'I cannot connect to the database because: ' . mysql_error () );mysql_select_db ( 'database' );mysql_query ( "INSERT INTO kw_track VALUES ( '" . mysql_real_escape_string ( $_GET['site'] ) . "', '" . $now . "', '" . mysql_real_escape_string ( $_GET['keywordvar'] ) . "' );" );[/code]printf Link to comment https://forums.phpfreaks.com/topic/35148-newbie-question-populating-sql-data/#findComment-165988 Share on other sites More sharing options...
Rhawn Posted January 22, 2007 Author Share Posted January 22, 2007 No, its being passed in a link. Link to comment https://forums.phpfreaks.com/topic/35148-newbie-question-populating-sql-data/#findComment-166097 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.