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?
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Database Connection ?
I am very new to PHP...Can i get the starting code for connecting to database....how to open the connection...what is the connectionstring ?
Database Connection
<?php I have a question about 2 connection strings to a ms sql database. # TEST DATABASE $connecttest = MSSQL_CONNECT("TEST", "sa", "123456") or exit("Unable to connect to MS SQL Server at 10.0.10.58"); $select = mssql_select_db ("database1",$connecttest) or exit("Unable to select database TEST"); # PRODUCTION DATABASE $connectprod = MSSQL_CONNECT("PROD", "sa", "654321") or exit("Unable to connect to database at 10.0.10.59"); $select = mssql_select_db ("database2",$connectprod) or exit("Unable to select database PROD"); $SQL = "SELECT * FROM table1"; $RESULT = mssql_query($SQL); // What data will i find here? Is it data from the TEST or from PROD and will it be data from database1 or from database 2? ?>
Connection To Database
Running RH8 and have installed mysql, apache, php. I have pypmyadmin working fine, adding and editing databases.. but when I try to get a form (to enter data) its does not connect or just sumbits as if all was ok but nothing happend.
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.
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:
Database Connection Limits?
I am in big confusion right now plz tell me one thing with explaination. Situation is: I have a script in that i am using database connection and some database operation. 10 users are accessing this script same time. what happen is there 10 connection to database sever or there will be only one connection?? if there would be 10 connections then what is the max limit of mysql.
Class For Database Connection
Can anyone tell How to write class for database connection in PHP . Class must provide a general function for executing queries.
Closing A Database Connection
for my php site, i open a mysql connection for each page cause most of my pages uses some data from the database. however, i did not close the mysql connection - will this have any bad effect to my database? or is it better to have all connection closed once my php script is finished?
Database Connection Problems?
I am all new to php/mysql and was wondering if someone might help me out on a little problem that I am having. It must be something very simple that I am missing, it seems that I am having trouble connecting to the database, yet all of my information seems to be correct - the error is as follows: Parse error: parse error in /data/members/free/tripod/uk/t/h/e/theresearcher/htdocs/scripts/conf.inc.php on line 6 the error repeats twice. Line 6 in my conf.inc.php states: $mysql_database='theresearcher_uk_db' I have enabled both php and mysql twice just to be sure. Hostname localhost is correct. Double checked the database name. No password is required so i left it blank. (should I take the line out alltogether?) I dont know what to do about the port..lycos didnt say anything about it so I left it blank. The table prefix I am not sure of either. Here is the surrounding code: $mysql_hostname='localhost' $mysql_port='' $mysql_user='theresearcher' $mysql_password='' $mysql_database='theresearcher_uk_db' $mysql_table_prefix='' $mysql_pconnect="NO"; $pages_dir='/data/members/free/tripod/uk/t/h/e/theresearcher/htdocs/' $pages_url='http://members.lycos.co.uk/theresearcher/pages/' $scripts_dir='/data/members/free/tripod/uk/t/h/e/theresearcher/htdocs/; $scripts_url='http://members.lycos.co.uk/theresearcher/scripts/'
Connection To Database Or Die Message
When connection to the database fails I would like to include an email link in the response message, but I need help with how it can be done. Below is my code and I want the error message text to include a Report This email html link. Code:
Php Mysql Database Connection
i want to add my form details to the mysql database. i had done it with mysql_connect('localhost','root',''); but the error was localhost connection failed. Code:
PHP MySQL Database Connection
I'm involved in a project where I have to create a web application with PHP and MySQL. My question is, usually we use one user name and password to connect to the database for the whole application, in which case all the users will connect to the database with that username we set in PHP script. If we want to have different users with various access rights on the database this strategy will not work, because we give one username and give maximum access rights for that username. Is there any way where you can define the access rights of a user in the database(MySQL) and use the same username and password when the user connects to database through PHP application? If so, we will have hundreds of users connecting through the PHP application with different usernames and password, will this have any impact on the web server or DB server? Is it secure? Is there any other way this can be done?
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:
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.
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:
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?
PHP/MySQL Database Connection Problem
when I'm doing an insert (using mysql database) it produces the following two error messages : Warning: MySQL: Unable to save result set in [file]. Lost connection to MySQL server during query These errors occur after the number of conncections increases, before this there is'nt any problem. I am using PHP 4 with Apache on Redhat Linux 6.2.
What Is Going Wrong In The Database Connection With PHP MYSql
I am setting up a site for a client that requires signup and login. I have written most fo the code but, for some reason am have trouble with the database connection. The problem is with the connection. I believe I have the right server but, have had trouble getting the correct iser and password. Is there a way to determine what is going wrong in the connection because setting up die with a message doesn't tell me anything other than the connection failed. I going back to client and getting the support # from yahoo who set up the server and database. Hopefully I can talk to the person who set up the server for him and get the proper server, user and password. It would be nice to know how to troubleshoot the connection in a more meaningful way.
No Luck Making A Database Connection
I've included db.php into my script, and this is all it contains: $host = 'localhost' $username = '***' $password = '***' $database = '***' $connection = mysql_pconnect($host, $username, $password); $mysql_select_db($database, $connection); obviously with the other fields filled out. My webhost tells me to use this script: $dbh=mysql_connect ("localhost", "<USERNAME HERE>", "<PASSWORD HERE>") or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db ("<TABLE NAME>"); neither one of these methods work, actually - I get this error: [the contents of my db.php file here, in plain text!]No Database Selected
Database Class: Closing Connection
I am just learning OOP in PHP and I decided making a DB class would be a good start for my first real type of OOP class. Everything is working fine but I am having problem's closing the connection. I was wondering if anyone can see what the problem might be if it is in the coding. database.class.php PHP Code:
ADODB Multiple Database Connection
I'm using ADODB for a PHP project and am having problems with multiple (MySQL) databases. I've looked through all the docs and am stumped. I know how to use PHP and MySQL and I still haven't got a clue why this isn't working. Code:
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:
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.
Using Global Variables In The Database Connection String
I'm sure this has been asked a million times but I can't seem to formulate a google search that returns what i'm looking for. I've go a dev and live environment. Currently the DB connect string is hard coded into each php file which means i'm going to have to change every page - Arrgh!! If i put the DBonnect into a function and store it in an include file, it doesn't seem to work, Also the connetion works with inline PHP statements, but I have to repeat it in every function even if they are in the main php file??? which doesn't seem right to me.. I need to either :- Store the connection variables in an include file and retrieve them as global values OR Store the connection string in a function in an include file which can be accessed by all functions. also do I really have to call the dbconnect inside every function. Please note, if it makes any difference, I still havn't got my head round OO programming in PHP so it is still pretty much procedural. I am using PEAR but dont really understand (or care at the moment) about what it is doing.
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.
Errors - Putty.exe (telent Connection To Mysql Database)
The following code produces an error when I try to run it under putty.exe (telent connection to mysql database). Can anyone identify the error in the code? The server is running PHP5. DELIMITER ;; /*!50003 DROP PROCEDURE IF EXISTS `aaa` */;; /*!50003 SET SESSION SQL_MODE="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER"*/;; /*!50003 CREATE PROCEDURE `aaa`() begin declare iTest int; set iTest = 5; end */;;
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:
Database Connection Problem In Included File On Root Directory
I have a file called tophtml.php that connects to the database. It's in the root directory of the site. It works perfect in the root directory. But if I call it in a sub directory. (e.g. require("../tophtml.php") or require("C:websitesdogrealm ophtml.php")) I get errors saying it can't connect to the database.
Putting Info Into A DB / Passing Info Between Pages
I have run into an issue...I have posted previously, but my scenario has changed. Here is the situation... If a user clicks on a link ('abc123' for example) I want to insert into my database some predefined information about 'abc123' - I have assigned a value that is echoed in future pages for 'abc123'. So, what I need is some mechanism to, when a user clicks 'abc123', have a pre-defined username and password be entered into the database. I need this so future pages can utilize the session values.
How Do I Hide Database Connection Files Using PHP Include Files?
I have the following at the beginning of the PHP page: <?php require_once('Connections/conn.php'); ?> I want to hide the connection file, "conn.php", so it's out of the web accessible file structure. I understand putting them in the php include directory shoudl do this. For example, let's say the directory I put them in is /www/phpIN/, and /www/ht/ is the root web directory. So I put "conn.php" in the inlcude directory (/www/phpIN/conn.php) and removed it form CONNECTIONS directory.
How Do I Hide Database Connection Files Using PHP Include Files?
I have the following at the beginning of the PHP page: <?php require_once('Connections/conn.php'); ?> I want to hide the connection file, "conn.php", so it's out of the web accessible file structure. I understand putting them in the php include directory shoudl do this. For example, let's say the directory I put them in is /www/phpIN/, and /www/ht/ is the root web directory. So I put "conn.php" in the inlcude directory (/www/phpIN/conn.php) and removed it form CONNECTIONS directory. Now it doesn't work. What do I need to change?
URL Hiding
Does anyone know how to hide the explicit URL addresses by exposing only the root URL? Ideally, I want something small and simple to add to my PHP or HTML script.
Hiding A URL Value
Can anyone tell me of way to hide a url value. For example, i have a link, on this link is the value for the url(which is a value from the database). When this link is rolled over and/or clicked i want a default value to show, not the actual url.
Hiding PHP
I want to hide the php files from my urls. My only idea is to have each file in its own directory as a default.php file. So instead of this ... xxx.com/about.php .... rename about.php to default.php and put in a directory /about ... xxx.com/about/ This way I dont need to reference any php files explicitly. Is this the best idea in regards to this issue?
|