Jump to content

Recommended Posts

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

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

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());

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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