Re: [PHP-DB] Passwords
I have created a user login/registration page. As of now I am using a MySQL database to store the info of the user. To validate the user I also have the password stored in the same DB. I was wondering if there is a way that I can store the password in the DB so that it is encrypted or something. Just so it is not in plain text. Of course. Check out any of MySQL's encryption functions. Make sure that you use the same function and parameters for both the registration and the login or else the login will never work. Larry -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Connecting to two MySQL databases
I had this problem a while ago, when you try to create the second connection to the database with the same login credentials, i.e username and password. If mysql / php detect there is a connection already established with those details it will return that specfic resouce and not create an new connection. The only way around this is to create a new username + password for this database and use those details to generate the second connection. Actually, the mysql_connect() function takes an optional fourth argument indicating whether or not a new connection should be made. If omitted, then PHP will do exactly what you are describing. If set, then PHP will create a new connection, even if the same username/ password/host combination is being used. Larry -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Connecting to two MySQL databases
I am working on an application that requires me to connect to two MySQL databases both hosted on the same server. I have an existing set of class files I created to handle the db connection to the main database. To connect to the second database, I duplicated my db class files and renamed them, and also renamed the functions etc. but what is happening, is that the calls made to the second database connection seem to get made against the first database. So that I get errors like: dbname.tablename was not found (or something like that). What is the best practice for this? I need to have two open db connections for just two little things in my application. In my opinion, rather than making two different classes that do the same thing, I would make one class and then create two instances of that class in your script. For this to work, you'll need to make the db host, username, password, and database name be values that are passed to the constructor when the object is created. Assuming you have that, then your code would be something like... $dbc1 = new dbconn('localhost', 'test', 'test', 'mydb'); $dbc2 = new dbconn('localhost', 'test', 'test', 'otherdb'); Then invocations of $dbc1-retrieveData() would to go the one database whereas $dbc2-retrieveData() would go to the other. I could be missing something, of course, but that's my first thought. Also, just to be safe, you could use the new link argument in mysql_connect() (the 4th argument) to insure a new, separate connection. Hope that helps, Larry -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] oracle complex type and oci_new_collection
Seriously, how many times are you going to send this email to the list? I've seen it at least 5 times now in the past day, all the same email under slightly different FROM and subjects. Send an email once. If someone can answer, they will. On Sep 28, 2005, at 10:18 AM, Hal McFarlane wrote: Is it possible to use a complex collection in PHP as shown below? Oci_new_collection is successful, but the OCI-Collection-getElem(i) returns false for each record returned. If we change from a complex type to a simple type, the data returns as expected. -- --- -- COMPLEX TYPE -- --- create or replace type aud_cl_clu_row as object ( channel_line_up varchar2(50), audit_status varchar2(20) ); create or replace type aud_cl_clu_tbl is table of aud_cl_clu_row; -- --- -- SIMPLE TYPE -- --- create or replace type aud_cl_clu_tbl is table of varchar2(50); -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] URL Forwarding in PHP...
How can I automatically forward to an external URL using PHP? header('Location: http://espn.go.com'); exit; Larry -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] what is the value of session_register
Is there any values to this function? I'm looking over some code where this is a done a bunch of time and I don't see any value to it. Maybe I'm naive about the internals but... I'm not certain as to what exactly you are asking, but prior to PHP 4.1, I believe (possibly 4.2), session_register() is how one added elements to the session. This is before the $_SESSION variable existed. So the value of the function is storing session data, although that method is deprecated. Larry -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Batch queries in the same mysql_query()
I'm trying to execute multiple queries using mysql_query() function and I'm getting an error to check SQL syntax. My PHP code looks like: You cannot execute multiple queries at once using mysql_query(). If you are using PHP 5.x and MySQL 4.1.x, there are new functions, one of which does allow for multiple queries to be executed in one function call. Maybe the problem resides on the character ;, but this queries run without problems when typed on mysql command-line tool. So, if it works on mysql command line, why it doesn't work using mysql_query() ? Because the mysql client and PHP's mysql_query() functions are two different things that behave somewhat differently. Larry -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Why not ?
Why does this NOT work? UPDATE tipping SET score = 3 WHERE round1.game1 = H AND tipping.username = jerry; For starters, you should quote strings in a query. There may also be a problem with the round1 reference. Larry -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] MySQL - Query within a query
I am looking to do the following w/ MySQL and PHP. Have 1 query that gets results, then use those results in another query: $l = 2; $result1 = (SELECT * FROM Drivers WHERE League = $l); $result2 = mysql_query(SELECT DriverID, Driver, CarNbr FROM Drivers LEFT JOIN $LeagueList ON Drivers.DriverID = $Result1.DriverID WHERE $Result1.DriverID) Is Null ORDER BY Drivers.DriverID); If you're using MySQL 4.1, which supports subqueries, you might be able to write this all up as one nice query (using a sub-select). Larry -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] '
When I submit my forms, if any textfield contains a ' the result comes back with /' Is there anyway of stopping this? Yes, either: - turn off Magic Quotes GPC or - use stripslashes() Larry -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] auto_increment
I have the auto_increment on one of my variables. During the past few days I have been doing testing on a live database and created several test records which I now have deleted from my table. Is there any way of setting the auto_increment value to match the last correct number? Ron You don't say what database application you're using, but if it's MySQL, you can change the auto increment value using: ALTER TABLE tablename AUTO_INCREMENT = 1 That being said, you actually don't have to do this (and often shouldn't, really). Having gaps in your auto increment sequence shouldn't be a problem. Larry -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] mac and mysql
Mac users, please forgive such a Windows-centric question, but I need your help. And you can educate me in the process. I am helping a student of mine set up a development environment with php, mysql, and a webserver, and she uses a Mac. Are there any installation issues unique to mac that I should warn her about? It makes a HUGE difference whether we're talking about OS 9 or OS X (10). I don't know if MySQL even runs on OS 9 and PHP does, but by purchasing the $500 WebTen. They both run on Mac OS X easily and installers are freely available (www.mysql.com, www.entropy.ch, www.serverlogistics.com). Can you recommend a simple web server - she is brand new to server-side work and I am trying to make this as painless as possible. Usually I recommend that students use Xitami, but I don't believe it comes in a Mac flavor. Does the Mac OS come with a server, such as IIS on Windows? Does Apache work well with Mac? Is there anything simpler? Mac OS X has Apache built in. The PHP installer available at www.entropy.ch works with that installation. Again, for OS 9, WebTen is the only solution I know of that can handle PHP. And here's a question I've never thought about. If she installs MySQL on a Mac, and she wants to admin the server through a command line --- does Mac have a command line tool to work with? Typically, when you think command line you think of the old dos prompt. What does the Mac have that will give us command line access? OS 9 does NOT have a command prompt but OS X does, accessible through Applications Utilities Terminal. Hope that helps, Larry -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] What's wrong with this QUERY??
$thing = [EMAIL PROTECTED]; $query = SELECT id, email, familyname FROM members WHERE email=$thing; You need to quote non-numeric values in SQL. It should be $query = SELECT id, email, familyname FROM members WHERE email=''$thing'; Also, you don't really need to select the email value since you should already have it. Larry -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] howto get PK id after INSERT??
I have a form to insert customer data into a table. The form goes to php page to input data to db hen uses header to go to a final page displaying customer's information. Is there a way to get the ID (custid PK UNIQUE AUTO_INCREMENT) from mysql after INSERT then pass to final page using urlencode to pull cust record? Use the appropriately named mysql_insert_id() function. Larry -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] PHP use in Federal Govt
My division at State is trying to get PHP 5.0 approved for use by developers in the Department, and the Powers That Be are requesting evidence that other Federal agencies/military are using PHP, and the extent of it's use. Anybody have a clue about this? I sure would appreciate some help! I've taught a number of courses on PHP to members of the National Forest service (under the USDA). They use it to interact with Oracle databases for both Internet and Intranet pages. Hope that helps, Larry -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Random select -- Where am I going wrong?
Here is my code I keep on getting a Resource id #2 ..whatever that meansany help would be appreciated! $music = mysql_query (Select * from $db_table ORDER BY RAND() Limit 1); if(!$music) die(Query Failed.); while($row = mysql_fetch_row($music)) print $music; } This is because you're printing $music--which is the resource ID--when you should be working with $row. Also, you're going to need to actually print $row[0] or $row['column'], not just $row. Larry -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] mysql_fetch_object
I'm using $row = mysql_fetch_object and I can reference column names by $row-name but how do I reference a pseudo column (that I make, like substring( name from 1 ))? Use an alias in your query: SELECT column, DATE_FORMAT('%m', date_column) AS d FROM table ... $row-d Larry -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Auto increament
Can any of you guide me how to do auto increament in a field? I think there is one datatype for auto increament. But I dont know how to do it ? I'd start by reading the manual and documentation for the database application being used. But, generally, auto incremented fields are primary keys, unsigned, not null integers. For MySQL, in particular, you define a field as auto increment by using AUTO_INCREMENT. Again, you can see the manual for more. Larry -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Call to undefined function mysql_connect()
But i received Call to undefined function mysql_connect() on line 5 Can anyone help me? Your PHP installation apparently does not support MySQL. You can confirm this by running a phpinfo() script. You may need to reinstall/recompile PHP. Larry -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Mysql not receiving the data
Online I could see everything, and the pages gave the appearance of working, however when I went into the DB using PHPMYADMIN to check the status of the new data entered, all I found was blank rows ( for the new data since the rebuild, all the old data was there) There were the correct number of new rows for the amount of records that I had entered, which tells me (unless I am nistaken) that the PHP is talking to the DB, and is atleast sending a insert command, but the rest of the data is not getting in. - Without seeing any code whatsoever and since this worked before but no longer works on a new install, I can only assume that your code was written with the assumption that register_globals was turned on and it's not on in your current configuration. If that is the case, see the PHP manual or search the Web for the solution ($_POST, $_GET, etc.). Larry -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] password () function.
Is this function, password() available at PHP Ander Windows? I get an undefinied function error message! There is no PASSWORD() function in PHP. There is, however, a PASSWORD() function in MySQL and other database applications. Larry PS It looks like you hijacked someone else's thread, which you shouldn't do. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] SQL question!
I have these tables. Users ( id,name,etc ) Coments : ( id , comment ) How do I do this kind of query: I thought in one thing like this but I cant figure it out. Example: Select * from users order by id desc in (select count (id) from comments) Expected result: List of users: * User1 See comments ( 32 comment in database ) * User2 See coments (13 comments in database ) You need to add a user_id column to comments, which records what user entered each comment. Then you can do SELECT u.name, COUNT(c.id) FROM users u, comments c WHERE u.id=c.user_id GROUP BY (c.user_id) The syntax may not be exactly right but that's the basic idea. Adding a user ID foreign key to the comments table is the important part. Hope that helps, Larry -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] How to redirect after a valid login
Is there a way that after a execution of a Login script and validation of login from a MySql database to automatically redirected to run another script ? Use PHP's header() function. See the manual for syntax. Larry -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] anyone trickier than 'LIKE' ?
I have this data (eg.) ..big fat buddy... on the database . If a person enter big buddy in the search form , the ...big fat buddy. data will not be found . Any suggestion ? select * from table where data like %keywords%; You can break up the search terms into words and do ...data LIKE '%$keyword[0]%' OR data LIKE '%$keyword[1]%'... This will be slow though. You could also do full text searches if you are using MySQL. Have good indexes for whichever route you go. Larry -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] date function
This might not be the best place for this but here goes. You are correct. At the very least, you should probably be using the general PHP list, not the database one. I want to create a dropdown list with a date range of Not to be obstinate, but it looks like you already have. But, assuming that you mean that you want to create this dynamically in PHP starting with today's date, then you need to establish some guidelines or rules for what dates make up the list. I can't really see a pattern in your list (every day for two weeks, then every week for five weeks, then two weeks once, then monthly going back a year) so I can't offer specifics. The answer will probably be found using a for loop and the date function. Larry -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] removing space ?
When I select data from my data base I have spaces on the lead side for example the data that is stored is 33.jpg. Spaces included, exclude the quotes, quotes are example only to show the spaces. I would like to remove these spaces. Is there a way to do this? You can definitely do this and should do this in the query. Most database applications have a TRIM() function or something like it. You don't mention what database application you're using so I can't be more specific but just check the manual for your database. Larry -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: [PHP] php|cruise - do unto others...
To make a donation, simply login to PayPal and click the Send Money tab at the top of your screen. Once there, put [EMAIL PROTECTED] in the Recipient's Email field and fill out the remaining fields to your liking. :) Even though this thread is much more PHP-related than many of the topics discussed here (sadly), could it be taken off list, please? Cpt Holmes is certainly a valuable asset to these lists but the time everyone spends reading two emails (PHP General and PHP-DB) every time someone does or does not donate to the cause is time better spent earning money for the cause, no? Not trying to be cranky, just worried that the 16 emails I've already seen in the past hour may not be the end of it! Larry -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] full text search in mysql
As of Version 4.0.1, MySQL can also perform boolean full-text searches I am running Mysql 3.x . This sounds like a simple task to me. Is it not implemented in 3.x? It does not have to be OR, NOR or anything, just AND I've never tried it, but you might be able to get away with SELECT columns FROM table WHERE MATCH (column) AGAINST ('caribbean') AND MATCH (column) AGAINST ('island'); I don't know if it'll work and it will probably be slow but... For more information, try reading http://www.mysql.com/doc/en/Fulltext_Search.html Larry -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] full text search in mysql
I do get results for islands in greece as well. How can I specify in my statement, that both words have to be present? From the MySQL manual: As of Version 4.0.1, MySQL can also perform boolean full-text searches using the IN BOOLEAN MODE modifier. mysql SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('+MySQL -YourSQL' IN BOOLEAN MODE); Use + to indicate required words. Larry -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] ODBC Database
Im looking at venturing into working with PHP's ODBC extention. Does anyone have any recommendations as to a Database, that is easy to understand/get into from a novice point of view, that installs on windows 2k, and is free? MySQL is kind of free, installs on W2K and is easy to use but it doesn't require PHP's ODBC extension since PHP already has a good MySQL extension. If you really want to use ODBC and you have MS Office, you could try Access. Larry -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] MySQL
I just need to know how to enter the data submitted by an html form into a MySQL DB. I have already created the form, and the variables in that form - just need to know the query use to insert that data. The query will be something like INSERT INTO tablename (column1, column2, column3, ...) VALUES ('$var1', '$var2', '$var3', ...) But you'll need to connect to MySQL first, then select the database. Check out the PHP and MySQL manuals for more information. Larry -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] mysl_connect question
First, please don't cross-post. The PHP-DB list is the proper one for this question. If you can connect via the mysql monitor but not with PHP, I expect the problem has to do with your host. Larry -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Right-click
First, this should probably be sent to the PHP general mailing list, not the PHP-DB one. Does anyone know if there is a function in PHP that allows you to right-click on an item, and from there a drop down menu pops up and you can go to another screen, preserving that value that was clicked on? No. PHP is server-side and what you are describing would be client-side. You might be able to do something like that in JavaScript but I have no idea myself. If there is no function for right-clicking, then is there a way that when you are selecting something, not on a form, but in a tree, that you can get the value of what you clicked on into the PHP file? If you make any element on a Web page a url, and make the url something like page.php?clickedon=this, then the PHP page that the user goes to would have a $clickedon ($_GET['clickedon']) variable. Larry -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] What about MySQL
I am a fresh man in MySQL,Can anyone tell me how i begin to learn it? www.mysql.com is a really good place to start. and what are the different between MySQL and other commerce relative database?As what I known,My SQL is free,but other commerce RDB is very expensive! Why MySQL not in the top? Is MySQL not strong or easy to used than the commerce products? MySQL is free for many--but not all--uses (check the license at www.mysql.com). MySQL has most of the features you'll need but is still missing some biggies (sub-queries, triggers, etc.). Some of these features will be implemented in forthcoming versions of the software. Read more about this at www.mysql.com. MySQL is pretty easy to use. Read the tutorial that comes with the manual at www.mysql.com. MySQL can help me do what or not? Well, you haven't said what you want to do but I suspect MySQL can help. Why don't you head over to www.mysql.com to get a better feel for it? Best wishes, Larry PS There are many books on MySQL available, should you be interested, as well as numerous mailing lists dedicated to MySQL. You can find out more about these at (you guessed it) www.mysql.com. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] elseif with header
if ($category = 2 and $subcategory = 52) { header(Location: http://www.vanderbilt.edu/register/ca/vacation_rentals.php;); } elseif ($category = 2 and $subcategory = 50) { header(Location: http://www.vanderbilt.edu/register/ca/rentals.php;); } , etc. for some reason all the elseifs are going to the if header. any input as to how i can correct this is greatly appreciated. You are using the assignment operator (=) instead of the equals comparison operator (==) which makes your if condition always true. Larry -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] SELECT problem
Hello PHP world!!! i've just finisched installing Apache 1.3.27 with PHP4 and 1.4 in Windows 2000. I've installed all off the scripts that function all right in Linux Red Hat in Windows 2000, but when it comes to do a simple select to a table that does exist and the select is all right there appears a message as if the query weren't all right at all: Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in g:\apache\apache\htdocs\digimedia\adm_central\index.php on line 18 What could it be? I really appreciate the great help you have been giving to me these days. Thank you very much!!! Could you show us what code you're using? That'd be more helpful. Also do consider using the mysql_error() function to see what MySQL thinks the problem is. Larry PS Could you turn off the HTML formatting in your email? The purple prose is jarring. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] db connect probs
do you have any idea why the following(line 106)would return the following error message ? the login.php has an included form to create an account and that is what will not connect. $connection = mysql_connect($host, $user,$password) //this is line 106 Warning: Access denied for user: 'x,@host' (Using password: YES) in /users/infoserv/web/register/login.php on line 106 Warning: MySQL Connection Failed: Access denied for user: 'x,@host' (Using password: YES) in /users/infoserv/web/register/login.php on line 106 Couldn't connect to server. You can take this one at face value: that combination of username, password, and host does not have permission from MySQL to access the database. First, verify what information is being used to connect. Then, if you can, confirm these values by logging into MySQL another way (e.g., through the mysql client). If you just added these permissions, be sure to reload the permissions before logging in. Larry -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] php-mysql connect
I've setup a form to submit data into my MySQL database and it appears to connect properly and whatnot but when I check to see that the data has been inserted properly using phpMyAdmin, the table refelcts a new row entry but the fields are empty. ??? I suspect this is a register_globals problem (the values from the form which are to be inserted into the database aren't being passed to the script as you'd expected). I'd echo the generated SQL to the browser to see what PHP thinks the query is. Then, if necessary, change which variables you use accordingly. Larry -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php