aditt787 Posted June 10, 2007 Share Posted June 10, 2007 can someone please help me out for one variable Quote Link to comment https://forums.phpfreaks.com/topic/54946-how-to-get-a-variable-into-database/ Share on other sites More sharing options...
chigley Posted June 10, 2007 Share Posted June 10, 2007 <?php // Connect to database here // Select database $var = "foobar"; $query = mysql_query("INSERT INTO table VALUES ('{$var}');") or die(mysql_error()); ?> Quote Link to comment https://forums.phpfreaks.com/topic/54946-how-to-get-a-variable-into-database/#findComment-271729 Share on other sites More sharing options...
aditt787 Posted June 10, 2007 Author Share Posted June 10, 2007 sorry but i am really new to php so dont know everything abt it, i wanted to track the visitor's url and keep its record in a database, now i think u may be able to help me nicely, Thanks Quote Link to comment https://forums.phpfreaks.com/topic/54946-how-to-get-a-variable-into-database/#findComment-271730 Share on other sites More sharing options...
aditt787 Posted June 10, 2007 Author Share Posted June 10, 2007 pls someone Quote Link to comment https://forums.phpfreaks.com/topic/54946-how-to-get-a-variable-into-database/#findComment-271732 Share on other sites More sharing options...
r-it Posted June 10, 2007 Share Posted June 10, 2007 $var = "foobar"; $query = mysql_query("INSERT INTO table VALUES ('".$var."')"); i'm sure tht'll work Quote Link to comment https://forums.phpfreaks.com/topic/54946-how-to-get-a-variable-into-database/#findComment-271734 Share on other sites More sharing options...
aditt787 Posted June 10, 2007 Author Share Posted June 10, 2007 i cannot understand how to use it in the codes, can u give me d complete code as per my req... thanks in advace Quote Link to comment https://forums.phpfreaks.com/topic/54946-how-to-get-a-variable-into-database/#findComment-271737 Share on other sites More sharing options...
chigley Posted June 10, 2007 Share Posted June 10, 2007 If we do it for you, how can you ever expect to learn? Â http://www.php.net/docs Quote Link to comment https://forums.phpfreaks.com/topic/54946-how-to-get-a-variable-into-database/#findComment-271739 Share on other sites More sharing options...
aditt787 Posted June 10, 2007 Author Share Posted June 10, 2007 I am currently trying to learn but dont know from where to, can u give me links on it, and also, I am requiring that urgently, orelse i would never have asked for it in the first place. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/54946-how-to-get-a-variable-into-database/#findComment-271743 Share on other sites More sharing options...
r-it Posted June 10, 2007 Share Posted June 10, 2007 <?php $var = "foobar"; $var2 = "barfoo"; $query = mysql_query("INSERT INTO table VALUES ('".$var."', '".$var2."')"); ?> thats the way i do it, and it works. You have single quotes then double quotes then fullstops, i dont know how i would explain it Quote Link to comment https://forums.phpfreaks.com/topic/54946-how-to-get-a-variable-into-database/#findComment-271747 Share on other sites More sharing options...
wildteen88 Posted June 10, 2007 Share Posted June 10, 2007 aditt787 if you are new to PHP and MySQL then I highly recommend you to have read of the tutorials on this site. There you will learn the basics of both PHP and MySQL and how to use PHP with MySQL. Quote Link to comment https://forums.phpfreaks.com/topic/54946-how-to-get-a-variable-into-database/#findComment-271946 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.