Jump to content
xisto Community
lonebyrd

MySQL Output Database Question

Recommended Posts

I am new to MySql and have just created a database after using a script. My problem is not the script, but what it says about putting it into the output file. I cant figure out the right terms to put it in, I keep getting errors. I try using; SELECT*FROM 'database name' WHERE 'location' but it isnt working. I'm lost with this stuff, I really am. Can someone please help me out?

Share this post


Link to post
Share on other sites

I am assuming that you are using a GUI like maybe phpMyAdmin so you want to select all rows from a database name then you have a where clause but nothing for the WHERE clause to work with

SELECT*FROM 'database name' WHERE 'location'

Where location equls whatdo not put quotes around the database name or the field name you do put them around values like so
SELECT * FROM testdatabase WHERE location = '$somevariable'
if you are using php you would use
$query="SELECT * FROM testdatabase WHERE location = '$somevariable'";// or location ='My Home Town'$result=mysql_query($query) or die("Could not execute query".mysql_error());
Does that help any?

Share this post


Link to post
Share on other sites

I did what you said and this is what it came up with, no error message, so I'm not sure if I did it right:MySQL returned an empty result set (i.e. zero rows). (Query took 0.0005 sec) SQL query: SELECT * FROM cscp_mojt_prefsWHERE 'admin.php'LIMIT 0 , 30 The cscp... is the database I made and admin.php is where I wanted it to go. Does this look correct to you?

Share this post


Link to post
Share on other sites

I am new to MySql and have just created a database after using a script. My problem is not the script, but what it says about putting it into the output file. I cant figure out the right terms to put it in, I keep getting errors. I try using; SELECT*FROM 'database name' WHERE 'location' but it isnt working. I'm lost with this stuff, I really am. Can someone please help me out?


when i look at your post it seems like, you are very very new to mysql right? no offense intended, iam quite new to it too :P

i thin when you said SELECT*FROM 'database name' WHERE 'location', you are try ing to access the database? correct? because 'database name' is not a parameter of SELECT CLAUSE so is 'location'

if you are trying to access the database use there command
in mysql console command

use your_database_name;Select * from your_table_name WHERE link = '$your_search_parameter';

in php
		$host				=	"your_hostname";		$user				=	"your_userid";		$pass				=	"your_password";		$db					=	"your_Database_name";		$connection = mysql_connect($host, $user, $pass) or die ("Unable to connect 1!");				mysql_select_db($db) or die ("Unable to select database!");		$query	= "Select * from your_table_name WHERE link = '$your_search_parameter'"; 

there you go ^^

Regards
Coffeemug

Share this post


Link to post
Share on other sites

No, actually I'm trying to get the typed in answers given to the database to go to 'admin.php'. I'm not looking to access the database with that script. And yes I am VERY new to this, no offence taken. What this is, is a login script that I downloaded, so the results from the database need to go to an admin file. But thanks for that info.

Share this post


Link to post
Share on other sites

SELECT *FROM cscp_mojt_prefsWHERE 'admin.php'LIMIT 0 , 30 like i said SELECT clause do not use database name as parameter... and why do you need admin.php in where clause?are you at all familiar with SQL ? or is this your first time using SQL?may i ask what do you wish to accomplish with those commands?

Share this post


Link to post
Share on other sites

O.K. you caught me, this is my first time using SQL. Anyway, what I was trying to do was make sure the info input into the database named 'csps....' went to the 'admin.php' file. As I said, this is a login script I got, so what it is essentially doing is getting the users name, email, etc..., and that info would go to my admin file to keep track of. Hope that helps.

Share this post


Link to post
Share on other sites

If you are connected to your database then all you need to do to see all the tables that are in that database,

SHOW TABLES
If you do have tables that have been created then to see all the rows that are in those tables just do

SELECT * FROM tableName

Share this post


Link to post
Share on other sites

I don't understand why you are telling me to show the database. I'm using a script that has a specific data form that goes with the database I just made that is in the admin.php folder. That is why I want the data in the database to go to the admin.php folder when it is calculated.

Share this post


Link to post
Share on other sites

I read all of your problems and still don't really understand what you're trying to do, others I think does not understand too. So I assume You have a database with a table and all the infos for your login script, so you want that people could login by using admin.php ? If so when write a script into it and when you fetch all the stuff, check the pass and user-name and let him login or else show some other page. ??? and admin.php is a file or a folder/directory ? :P

Share this post


Link to post
Share on other sites

I read all of your problems and still don't really understand what you're trying to do

@Quatrux : You don't understand because you could not figure how really he is beginning.@lonebyrd : you don't select from a database. A database contains several tables. And the "select" instruction is the way of seing what is inside a table.
So, you must first know what tables are in your database, and then "select" to see what is inside a given table.
To see the names of the tables already created in your database, you type "show tables", exactly as Houdini told you. when you know the names of the tables inside your database, you type "select * from " in order to list the whole content of a table inside your database.
You cannot directly see the whole content of your database, you must first see the names of all the tables inside your database, and then you can look the full content of each table using the "select" syntax.
Hope this helped.
Don't hesitate to come back is it's still not clear.
Regards
Yordan

Share this post


Link to post
Share on other sites

O.K. Let me see. If you have a registration/login script where users sign-up with certain info, that info needs to be stored somewhere, right. Well, when I downloaded this registration/login script it came with all sorts of folders/files, and one of the files was called admin.php. Admin.php is where, according to the script I downloaded, all of the input info was to be stored.So essentially, what I was trying to do, was make sure all the info that was input into my registration/login area of my site, which has a database name 'cscp...' table 'prefrences', would be stored in the admin.php file to be retrieved when I need it.If that doesn't help then I don't know what to do. I don't know how to make registration/login pages. If someone knows a better way to store the database info for user info, let me know.

Share this post


Link to post
Share on other sites

OK I think I kind of have a handle on what is going on here. Your script admin.php will present a form with a couple of fields in it like a username field and a passowrd field and then a submit button of some sort. This form will have an action attribute that will tell the script what page to go to next (possibly even itself). It will also have a method of either POST or GET (normally POST) but that doesn't matter. The script either within the admin.php or the page that it goes to will look to see if the user has pressed the submit button and will then take the POST or get values and then check with the database to see if that person already exists. If they do exist and the password is correct the user will be sent to a new page where member are allowed, other wise the form will be re-presented with an explaination that either the username and'or password is wrong and to correct it or to register.

 

To perform this the script would have to connect to the database server, then the script must select the database that contains the information desired. This is done with PHP and MySQL queries kind of like below;

$host="localhost"; //or whatever on Xisto this will work$user="yourUserName"; // Your username here$pass="YourPassword": // Your password here$connect = mysql_connect($host,$user,$pass)  or die("Could not connect to server".mysql_error());// Connect to the server or quit on fail with a message$db = mysql_select_db('cscp',$connect)  or die("Could not select the cscp database".mysql_error());// Select the Database cscp$query = "SELECT username, password FROM preferences WHERE username = '$username'";//$username from form$result = mysql_query($query,$connect) //execute the query  or die("Query failed MySQL said '.mysql_error();$rows=mysql_num_fields($result);if($rows == 2){//do something because the query found someones username and password (2 fields), send them to the members area with a header  header("Location: member.php");}else{//make them leave or become a member send them there with a header  header("Location: registration.php");}
Edited by Houdini (see edit history)

Share this post


Link to post
Share on other sites

Admin.php is where, according to the script I downloaded, all of the input info was to be stored.

I'm afraid you are confusing two things.The info is not stored inside admin.php
the info is stored in a table.
admin.php is the program that puts or retrieves the data from the table.
And the table is in the database.
So, lonebyrd, you have to first understands that you have a database, inside the database you have tables, the date are inside the tables, and the php files are programs allowing to add, remove, display or delete the data which are inside the tables.

Share this post


Link to post
Share on other sites

lonebyrd,can u please give us link to the script that you downloaded?guys, i believe admin.php is NOT the input form, but the administrative panel from where you can see who all have registered, logged in.. etc. Lonebyrd gets confused because may be the Readme.txt tells that the stored values can be accessed from admin.php

 

See lonebyrd, its not 'practical' to access stored records from an SQL statement directly. The script you downloaded may be having the admin.php file as the "access point" of the stored information.Now what you need to do is, type the following into your browser: site/your_web_path/admin.php

 

where <your_web_path> is the location of the uploaded php scripts. Once the admin.php script executes, it might ask you for some admin user name and password (that you must be knowing :-). Once you log in, you can click your way around for accessing Registration data.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | 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.