makka Posted May 13, 2007 Share Posted May 13, 2007 hello i would like to know 2 things 1st is how can i get something out of the db using an other part of the table eg i have 2 rows one called username and one called word i want it so i can say get the word out of the db when the username = admin eg SELECT word FROM `users` WHERE username=admin; what is wrong with that? also i would like to make a file in a file and call it the members name eg i im making a new account and one part of it is that i get a file when i make a new account i want all of the files to be saved in /userfiles/ and the file name to be called the users name ... any help Quote Link to comment https://forums.phpfreaks.com/topic/51214-a-mysql-query-and-making-a-file-on-the-site/ Share on other sites More sharing options...
Psycho Posted May 13, 2007 Share Posted May 13, 2007 For the query, you need to put single quotes around the value you are searching for - otherwise I see nothing inherently wrong with the query. Assuming you are using the corrected table and field names. Although I did notice you put a semicolon at the end of the line. A query is run against the database - it is not PHP code. So, in the case of a mysql database you would first use: $result = mysql_query("SELECT word FROM `users` WHERE username='admin'"); To create a file you just open a file for writing. See the tutorial here: http://www.tizag.com/phpT/filewrite.php Quote Link to comment https://forums.phpfreaks.com/topic/51214-a-mysql-query-and-making-a-file-on-the-site/#findComment-252202 Share on other sites More sharing options...
chigley Posted May 13, 2007 Share Posted May 13, 2007 Are you sure you want to physically create the file? Why not do what I just explained in this thread? It saves server space and is cleaner coding Quote Link to comment https://forums.phpfreaks.com/topic/51214-a-mysql-query-and-making-a-file-on-the-site/#findComment-252206 Share on other sites More sharing options...
makka Posted May 13, 2007 Author Share Posted May 13, 2007 thanks i want the php to make the file not me also with that tutorial aint it making a .txt i want it to make just a file so it then would be /userfiles/username/whatever.html Quote Link to comment https://forums.phpfreaks.com/topic/51214-a-mysql-query-and-making-a-file-on-the-site/#findComment-252222 Share on other sites More sharing options...
chigley Posted May 13, 2007 Share Posted May 13, 2007 Yes but when PHP creates the file what will be going in it? Quote Link to comment https://forums.phpfreaks.com/topic/51214-a-mysql-query-and-making-a-file-on-the-site/#findComment-252223 Share on other sites More sharing options...
makka Posted May 13, 2007 Author Share Posted May 13, 2007 Yes but when PHP creates the file what will be going in it? photos and a php page Quote Link to comment https://forums.phpfreaks.com/topic/51214-a-mysql-query-and-making-a-file-on-the-site/#findComment-252232 Share on other sites More sharing options...
chigley Posted May 13, 2007 Share Posted May 13, 2007 Where will the photos and PHP be found? Will the user write the file themselves? Quote Link to comment https://forums.phpfreaks.com/topic/51214-a-mysql-query-and-making-a-file-on-the-site/#findComment-252236 Share on other sites More sharing options...
makka Posted May 13, 2007 Author Share Posted May 13, 2007 basically it would be like a photo gallery they up pictures and then its stored in there folder they can use direct link to the photo from our site or they can just give the name like myname.domain.com and it will be paged showing there photos Quote Link to comment https://forums.phpfreaks.com/topic/51214-a-mysql-query-and-making-a-file-on-the-site/#findComment-252243 Share on other sites More sharing options...
makka Posted May 13, 2007 Author Share Posted May 13, 2007 crap also i just had a dumb fase now that i got the query how can i show it eg save it to a variable code: function userfile() { global $con; $username = $_SESSION['username']; $queryfile = "SELECT file FROM `users` WHERE username='$username'"; $result=mysql_query($queryfile) or die(mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/51214-a-mysql-query-and-making-a-file-on-the-site/#findComment-252260 Share on other sites More sharing options...
Psycho Posted May 14, 2007 Share Posted May 14, 2007 crap also i just had a dumb fase now that i got the query how can i show it eg save it to a variable code: function userfile() { global $con; $username = $_SESSION['username']; $queryfile = "SELECT file FROM `users` WHERE username='$username'"; $result=mysql_query($queryfile) or die(mysql_error()); Not sure what you mean. Are you wanting to know how to extract the data from the query? If so, I think you should be following chigley's advice and just put the user's profile data in the database. That's what it's there for - storing data. Quote Link to comment https://forums.phpfreaks.com/topic/51214-a-mysql-query-and-making-a-file-on-the-site/#findComment-252496 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.