Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    PHP




Retrieving Database Info Based On User


I'm still quite new to php and mysql but I have been unable to figure this out.  I'm attempting to display a specific row and column from a mysql database based on the user.

$result = mysql_query("SELECT fbleague FROM users WHERE username = $_SESSION[username]");
fbleague is the column
users is the table
username is the primary key column
$_SESSION[username] is the username variable

Then later I try to display it with

echo "You are in league $result ";

I know $_SESSION[username] is set correctly because I can display that with no problems. 




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Retrieving Info From A Database
I would like the code below to fetch and display in an html table the Ad_Id, Date, and Type_Job fields from the 1st 10 rows of a table called employment. I'd like the results to be sorted first by date and then by the Ad_Id #. I have replaced my username and password with "user" and "password". Currently, the script returns the error:

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource

Also, the script is ignoring the css info that I have supplied. Code:

User Info Not Posting To Database
I am trying to figure out why my script isn't updating the information of the user names stored in the database. Can anyone give me the solution?
Below is the script: Code:

Retrieving Flash Info In PHP
Does anyone know how to retrieve Flash info in PHP? Meaning, I need a script to extract the framerate of a SWF file. Is this possible? How to read flash file's headers, as framerate is probably in the header?

Problems Retrieving Info From The Session
I am trying to display the username and the time that a user logs in with... so, im already using sessions to ensure user has logged in.. PHP Code:

Retrieving Info From A Whois Query
Can some one give me a little step by step to put me onthe right way..
I'd like to use PHP with Postresql. I need to make many whois query on the domain names that we own, to store the information such as expiration date and so in our DB. I was thinking of :

using php to open the url of the query, retrieve the new web page with ftp
mode, parsing the page with some "expression régulieres" and then uploading the
found data in my DB...

Can you tell me what you think of that, is there any way to be quicker and
easier, and maybe some advice on how to retrieve and parse the file..
because I dont really know how to..

Retrieving Specific File Info...
Ive got a file which contains the following data:

<option value="13">African Nations Cup XXV</option>
<option value="16">asd</option>
<option value="7">Champions League</option>
<option value="1">English Premiership</option>

What Id like to do is get the maximum value, so 16. Ive used file_get_contents to bring the file into a string, but now Im stuck getting that max value out. Unless theres a function for this, I believe the direction I would need to take is collect all value numbers using some string manipulation function, throw them all into an array, and just get the max value of the array.

Is there an easier way?

Retrieving NT User ID
Does anyone know how to retrieve the NT user id that someone is logged in as?

System is running IIS. Have tried HTTP_AUTHENTICATION but that doesnt appear to work under MS - unless someone knows a works around.

Alternatively - how can I retrieve a UNC pathname for a specific drive mapping.

Sorting Color Swatches Based Off From RGB Info.
I am trying to figure out a way to sort a series of different color swatches into a color wheel type sequence (Reds, Oranges, Yellows, Greens, Blues, Violets...) based on their RGB color information.  I know how to get the information I need, and I know how to display the information I need...I just can figure out the best way to sort the individual RGB datasets without doing it manually (and with well over 400 of them, I would rather not do it that way).

I've checked through the gd library to see if I could find anything that might work, but unless I am missing something - that is a dead end...so I am thinking maybe there is an equation which applies to RGB color coding that would work, it is just not something I know of.

File Access Based On PayPal Info (IPN)?
I want to let a (registered) costumer download a file after paying through PayPal. Now PayPal have a system called IPN (Immediate Payment Notification), where your server gets notified whether the transaction was approved or not. Based on that notification I want the server to allow or deny access to the file.

Retrieving Database
User choose on ID and submit.

I use the URL query method to get the ID and rest of the profile like first_name, last_name,
I tried something like this

$query = "SELECT * FROM user where user_id= $ID";
echo $_get['first_name'];

but it doesnt show, how come?

Problems With Retrieving Url From Database
I am having problems with retreiving the url of the avatar that the user chose, which is stored in a database, and then diplaying it as an image. I have no prob's with the query:

Retrieving Values From The Database
I am retrieving a value from the database and I insert the value as a value of a field
The problem is that when the value has spaces then in the filed is viewed only the part of the value before the first space. If the value is not includes any spaces then the value appears in the field correct.

Dates In Database + Retrieving
What is the best way to store dates into database so the data can be retrieved later on.

For example: I use this to get the date and i store it.

<?php
$date = date('d/m/y');
?>

However, if i wanted it to say '20 March 2007' would this be easy or is there a better way to store them.

User Info
How can i be able to show a users profile after they have logged in of course? But i dont want a user to edit another users profile. I am using sessions.

Problem Retrieving Results From Database
I'm trying to retrieve fields from my database with following mysql
statement:

$query = SELECT g_games.Title FROM g_collections, g_personal_reviews,
g_games WHERE (g_games.ID=g_personal_reviews.G_ID AND
g_collections.U_ID = '" . $data1['ID'] . "' AND g_personal_reviews.C_ID
= '" . $data2['ID'] . "' ) ";
$resultset = mysql_query($query);
$data = mysql_fetch_array($resultset);

3 Rows in my database comply with the above statement... though I only
get 1 to show up on my php page? How can I show all of them?

This is the php code I'm using to write the results:

while ($data= mysql_fetch_array($resultset))
{
echo $data[Title]." ";
}

My tables are as followed:
g_games
g_collections
g_personal_reviews > this table connects all others with G_ID ("game
ID"), C_ID ("Collection_ID"), U_ID ("User ID)...
users

Retrieving PDF/MSWord Files From Database
I am able to upload .pdf and .doc files into the MySQL database (using Medium
Blob) but I can't retrieve or download them back. Can you help me download them?

What I did was the following pages (downloadpage.php and downloader.php):

Retrieving (Data + Fieldnames) From Database To Array?
I'd like to poll a database and get the table contents, as well as the field
names from that table. I've been to php.net but this time I cannot find
something helpful.

I can get the data, and retrieve it into an array noproblem. [1]

I can get the data+fieldnames and put it into a list. [2]

But I cannot seem to be able to fill an array with the data *and* the
fieldnames. If you check both chunks of code, you will se what I'm doing....

Add To Date Based On User Selection
I have a form with Radio buttons that when selected should add "$howMuch" amount of hours to the current date and time and put the output into a field called "ExpireTime". The code I'm using for the hour adding: PHP Code:

Query User Info From A Session Variable
When a user logs in, a session variable is passed. The variable is the users ID. If the variable is passed successfully, they are logged in and I want to query the users information based on the session variable. Code:

Get User Info From Myspace/facebook/bebo Using CURL
I'm making a social networking site and I'm looking into an easy way for people to get signed up.

Was just wondering if this was possible:

Could a user put in their Myspace/facebook/bebo username and password then a script would remotely connect to the site and grab their user info and avatar etc?

We're thinking that this would make it very easy and simple for people to join up, as they don't have to enter all that information again.

I presume I'd be using cURL for this. Would their be any obstacles in my way?

Dynamically Creating URLS Based On User Input !
I am looking to create pages on the fly or dynamically based on user input. For example if i have www.example.com and they visit this and enter 'bob' in a textfield and press submit they create www.example.com/bob.html . How would I go about this ? I am guessing I need to create a folder when submit is pressed in my website directory ?

Use Cookies To Save Info On What The User Enter Last Time In A Input?
I am having some trouble looking for a good tutorial on cookies and how to have them save what you last time entered in the form. So how can I do this so users don't have to renter everything the next time they try to post something on my site?

Php/sql Question - How To Build A Dynamic Query Statement Based On User Input
I need to build a query based on what the user checks in the form. For
example, if the user does not check certain fields, I don' tneed to use
those in the query statement.

Recall Database Info
Hi, I want to create a page where users can put in certain information like you normialy would in a form but when they click submit another page will load that will look like the original form the signed up with and everything they filed in that time will be there and they can make changes to that and then click submit and the changes are made to databse automaticialy.

How To Send Info To Database
im wondering how to submit info into a database.

i know the code goes something lie
$sql = "UPDATE <tablename> set $var = "var"

but i know that is wrong
and i want to put it in form so on submit it posts it in the database.

Info Deleted Itself From Database?
I got some info (news system) in a SQL database but after some days it deletes by itself it happened to me once but i thought i didnt remembered that i deleted it but today it happened again...it deleted by itself! lol

I have other tables in the same database so its a table problem...

How can i fix this? Did i miss something at the table configuration?

Get And Insert Info Into Database
I have one table (form) that has multiple fields. Here are few fields we need to know: ID, NAME, CITY, STATE, PROFESSION, x, y, z (x, y, z means more than 50 fields that give me more information about each name).

The ID and NAME are unique and they don't change (each name has it's own ID). A NAME and its ID can be in any CITY, STATE or PROFESSION but this is fixed. That means if ID# 123 for Mr JOHN is Austin, TX, that will stay in Austin, TX for ever. I have more than 5000 NAME and it's ID, 9 professions, all US States and all Cities in my database.

Here is what I need to do:
I want to have a form on my site that my visitor finds his name first and then enters more information about him/her that will complete my database fields of x,y,z. What I'm thinking to do is to create a drop down list that the visitor first selects the profession. Based on the profession the second list shows the states that has that profession. Then by selecting the state, all the available cities will show up in the third list, and by selecting the city all the names related to that profession in that city, state will show up and he can select the name from the forth list. Then he enters other required information about him that will be send and saved in the database.

Here is what I have done and I know to do so far:
I have created the database with all the information in one table. I also know how to send data to database to be saved. But my problem at this point is how to create this list selection that narrows the search to find the right person.

Populating A Form Wth Database Info
I've coded a piece of code which populates a form with data read from the database:

$connection=mysql_connec ("localhost", "f2821842", "f2821842");
$result=mysql_select_db("QUERIES");
$query=mysql_query("Select * from Emp_Details where emp_num = '$employnum'");
while($row=mysql_fetch_array($query))
{$empname=$row['emp_name'];}

<form name="webregform" action="webadmin2.php" method="post">
<input name="requiredname" type="text" size="30" value="<?php echo "$empname"; ?>">
</form>

When I echo the $requiredname, I get spaces and no data, and I know that $empname is not a space-it does read a value in a database. 1. How can I get $requiredname to print a value?

Ordering Info Returned From Database
I have a PHP page on my site which pulls back info from my MySQL database and displays it in a table under appropriate headings. Is there code that I could add to these headings so that

a) the same page could be redisplayed with the information sorted by the third column instead of the first
b) information in the columns could be displayed in reverse order (maybe Z to A or highest figure to lowest figure)

Session Variable Info To Database
I have a 2 page form. The first page page of the form POSTS to the 2nd page which, after being filled out, should send all the information (from pages 1 and 2) to the database. I have created a session variable and have placed it at the top of the 2nd page. For brevity´s sake I have placed only one of the variables in this example:

<?php
session_start();
$_SESSION["sessanimals"] = $_POST["animals"];
?>

After filling out the remaining variables on page 2, I want all the information (the info from page 1 brought over in the session variable and the info from page 2) sent to the database. I tried creating an INSERT RECORD on page 2 but only the variables on page 2 are subsequently sent upon submission. How do I get all the info into my database??

Here are a list of my questions:

1. Is there any way of creating one session variable for all my page 1 form variables (I have 20+ variables)?
2. is there a way to denote ALL the variables in = $_POST[]; or do they have to be listed separately?
3. How do I post all the data from page 1 and 2 into my database at once?

Insert Form Info Into Database
i am trying to enter info from a form into a mysql database. when i submit the form, a new row is created, but the information isn't contained in it? any thoughts? PHP Code:

Filling Form With Database Info
I have a table with 5 fields for a tour business activity list
: (1) id -table key (2) name (3)description (4)picture -text link not
binary(5) country. I would like to create a form that takes all the
activitys an puts it neatly down on site in checkboxes so user can
select activtys.this will be linked to form mail.i would like the
activitys to be seperated by the country they r in?

Update Database Info Using Forms
i have a page uses select and cases. i already have setup and working, auth/login to the page, create a new row in the table. i am now trying to have the user alter the information that the just put into the table.

this is the code where i have setup to modify the info, $id is passed over. this puts the correct information into the form field. when i hit submit, the information, $name, $content, $id are not passed over. echo-ing results blank. PHP Code:

Hiding Database Connection Info
In a php script, I have to connect to a remote mysql database. I'm a bit
worried that some user might be bale to retrieve the source of the page and
see the user name and password to connect to the db.

Is this resonable? What's the best way to avoid it?

Obtaining Info From Database Table
How do you obtain fields from a table and assign each field to a variable to be used as needed.
An example:

Say i had:

table name : user

Field 1 : User name
Field 2: Password

then i wanted:

$username = field 1
$password = field 2.

How To Obscure Database Info In PHP Pages
I'm moving from Cold Fusion to PHP and I have a question that none of
the books I have answers adequately:
In Cold Fusion, database connection parameters like the table, username
and password are configured on the server. Since they are at the
backend, nothing is exposed on the page except the queries themselves.
In PHP, from what I see, the database info is on the page. Is this not a
security risk? How can one be sure that this info is not on the page
sent to the user?

Database Or Flat File Based?
I'm writing a news script, where I can write articles and have them outputted on my homepage. What I'm wondering before I start is; does anyone have any advice whether something like this would be better of stored in a database or flat files?

Some articles could be quite long and I just thought they may be better suited stored in a .txt file for instance, but then again it might not make any difference.

How To Check A Checkbox Based On Database Value
I have saved a "Y" or "N" in the database field, based on a Checkbox setting in the "Add Contact" screen.

Now, in the Edit screen, I want to show the same checkbox, but it should be checked or unchecked, based on the value from the database.

How do I check the checkbox based on the edit screen, based on the database value, in PHP?

Validating Form Info Before Inserting It Into Database
I have been trying to create a PHP application where you can add customer contacts to a MySQL database.

Now, my problem began when I created a form where the user can add in a customer's name and info to the database. In an effort to alert the user that they may be adding a customer that is already setup in the database, knowing that some of the customers may have the same names, e.g. there is more than one Bobby Ray Brown, I decided to add a script that queries the "customers" table in the database and searches for all results that match the input from the user. Code:

Entering/checking Info Into Mysql Database
I have set up a client database where one can view, add, edit and delete entries. I ran into a problem setting up the add page. On this page i have set up forms to add info into the DB, and it works fine, but i dont want duplicate clients. Is there a way to set it up so that when you submit the form with the info it checks for duplicates and if there is one returns "sorry this record exists?"

Retrieve An Image In Folder From Info Out Of Database
i am having problems displaying an image once i have uploaded
it. i upload it to a folder and store its name in a database. below is
the code to display the image. I have figured out the the code is not
grabbing the name from the database but i can not figure out why. can
anyone help?

//Retrieves data from MySQL
$data = mysql_query("SELECT IMAGE_NAME FROM item") or
die(mysql_error());

//Puts it into an array
while($info = mysql_fetch_array( $data ))
{
//Outputs the image and other data
Echo "<img src=http://www.abcxyz.com/pics/".$info['photo'] ."<br>";
}

Sends SMTP Mail From Database Info
I've got this script that I want to use to send SMTP mail from a form that allows the user to select recipients from a dropdown list that is created using database info and send a message.  Two of the selections in the dropdown list are groups.  My script works fine when the user selects only one recipient.  I run into trouble when the user selects one of the two groups.

The message ends up getting sent numerous times to the people in the group. I received the message 9 times.  I think the script is looping more times than it should.  Does this make sense so far?  Here's the script that receives the form data and connects to the DB to get the recipient email addresses and then sends the message: Code:

Print Output Based On Database Result
What I am trying to do is print out an existing text file based on what is in my database.

I want to show/print the contents of text1.inc (which is located in my includes directory) if the database contains query shows it contains "yes" and I want to show/print the contents of text2.inc (which is located in my includes directory) if the database contains query shows it contains "no". Code:

Uploading Info From A Text File Into A MySQL Database
what would the PHP and SQL code be to say basically: make a new row and put this in the field, what comes after each comma goes in a new field, and each new line should be a new row.

I have a huge text file that i don't have a way to upload directly into a MySQL database because my webhost isn't allowing it for some reason.

Dynamic Photo Gallery Based On Mysql Database
I would like to turn my attention to using PHP to organize hundreds of images on my site. I would appreciate some direction. I have in mind putting the image names in a database and will use those names to create links, likely output as a table or drop down menus in a form.

I specifically wonder if there is any way to "dynamically" create thumbnails in PHP from the full image? Alternately, are there any programs out there for "batch creation" of thumbnails?

Upload & Query MySQL Info Database With Image Files
I want a database I can enter information and upload a photo from a web form. Then I want to query that database for the text info with its related photo and display it (formatted) in a browser (html).

Summary:

1. upload photo's and text information to database with my add article form.
2. Query the database and page the results with the text and related photo.

It comes in three parts:

1. add_article.php [Text / Photo Upload Form]
2. insert_article.php [Inserts into database]
3. articles.php [View Output]

Here is what I have this far:

Querying Mysql Database Based On Values From Html Form
I want to build a simple form for querying database having business organization info. The form has four fields name, category, city and state. Users should be able to search based on any of these fields. Code:

Checking A Database For A User Name
How can you check a database for something. I have a database with several fields and a page for creating new rows. I'd like to make it able to search the database for one of the fields, the user name, and add a new row it the name is not present and update the row if the user name is present.

Any good ideas?

Update Database When User Logs Out
When a user logs into my site, I store that date and time in a session variable. e.g.
PHP Code:


Copyright © 2005-08 www.BigResource.com, All rights reserved