Re: [PHP-DB] fetch array problems.
On Wed, Mar 28, 2001 at 01:08:35AM -0700, John Starkey wrote: table bgcolor="'.$color[color_1].'" class="nav" .. '; I can't get $color[color_1] to return a value. It's in the db and color_1 is a valid table containing a hex value. This is my first attempt at using assoc. arrays. I'm not sure right now, but try $color["color_1"] to access the assoz. array...(dunno, if it makes a difference) -fkr -- gpg-fingerprint: 076E 1E87 3E05 1C7F B1A0 8A48 0D31 9BD3 D9AC 74D0 |http://www.hazardous.org/ | whois -h whois.ripe.de FKR-RIPE | |all your base are belong to us | shame on me | fkr@IRCnet | PGP signature
Re: [PHP-DB] auto_increment in mysql
I may be semi-new to this MySQl lark but I'm sure auto_increment starts at 0. Russ #---# "Believe nothing - consider everything" Russ Michell Anglia Polytechnic University Webteam http://gertrude.sipu.anglia.ac.uk/webteam [EMAIL PROTECTED] +44 (0)1223 363271 ext 2331 www.theruss.com #---# -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] auto_increment in mysql
The version you use may be lower than 3.23 because auto_increment sequence number begin at 1 for MySQL version up to 3.23. "Russ Michell" [EMAIL PROTECTED] ? news:[EMAIL PROTECTED]... I may be semi-new to this MySQl lark but I'm sure auto_increment starts at 0. Russ #---# "Believe nothing - consider everything" Russ Michell Anglia Polytechnic University Webteam http://gertrude.sipu.anglia.ac.uk/webteam [EMAIL PROTECTED] +44 (0)1223 363271 ext 2331 www.theruss.com #---# -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP-DB] Re: Record Numbering - was SELECT MAX(ID) PLUS 1
Thanks Steve, I will go back to using separate tables - Thanks Lisa -Original Message- From: Steve Farmer [mailto:[EMAIL PROTECTED]] Sent: Wednesday, March 28, 2001 12:12 PM To: Rubanowicz, Lisa; [EMAIL PROTECTED] Subject: [PHP-DB] Re: Record Numbering - was SELECT MAX(ID) PLUS 1 Hi Lisa, At 4:40 AM -0600 28/3/01, Rubanowicz, Lisa wrote: Can anyone help me on this one Lisa [snip] Here is the story. I have a small web site running from mySQL. Initially I had it all in different tables then an ASP colleague said I should do it it one table and use SELECT MAX(sub_id) etc. Well although MYSql is not truly a relational database your ASP colleague does not seem to know a lot about database design !! If it was me I would use extra tables for the first few levels... You can use a self referencing table (which is what you are trying to do) but IMHO the extra tables approach provides more speed and flexibility. Otherwise I can't see a reason why the query you are trying should not work.. a better and (usually) faster approach is to use another table to store the record numbers eg.. Table - record_numbers RECNUM_PKEY (Primary Key) (this holds the Table ID or Key eg "L1", "L2" etc) RECNUM_VALUE (holds the next record number) you could easily write a php function to get the next record number for any table.. This may be overkill for your project but it is very flexible . HTH Steve -- --- "Minds are like parachutes, they work best when open" Support free speech; visit http://www.efa.org.au/ Heads Together Systems Pty Ltd http://www.hts.com.au Email: [EMAIL PROTECTED] Tel: 612 9982 6767 Fax: 612 9981 3081 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] managing large result sets
I have to deal with displaying result sets that could potentially be quite large. It would be bad form to drop 10,000 rows into a browser table so I need a strategy for dealing with this possibility. It's obviously not a big deal to limit the output but what is the typical strategy for handling next previous behavior? It seems terribly inefficient to requery for a subset each time. I suppose that I could dump the entire result set to a text file keyed to the session but that raises the problem of garbage collection with potentially large files. Anyone have experience with this problem? Thanks--Houston -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] global vars
nevermind, sorry it was a stupid comma in my sql query... what i have is very sool tho, so if you would like the script its great! i derived it, almost entirely from Dan LaFlamme's NOT working script at http://phpbuilder.com/columns/laflamme20001016.php3 olinux - Original Message - From: "olinux" [EMAIL PROTECTED] To: "PHP-DB" [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Wednesday, March 28, 2001 2:06 PM Subject: [PHP-DB] global vars I am working with global variables and functions, specifically calling a function inside another function. I checked the online docs and don't see any problems with what i have... i declare the table_name as global inall functions What I am trying to do is DELETE all entries for a uid before INSERTING the new skills my insert_skills() calls the function to DELETE entries and then the function that creates the INSERT query the lookup_skills table columns looks like this. | id | uid | skills_id | here are a couple excerpts from my code: table_name = "lookup_skills"; ... function insert_skills($uid, $skills) { global $table_name; purge_lookup($table_name, "1"); $query = create_checkbox_query($skills, $table_name, "1"); ... function purge_lookup($table, $uid) { global $table_name; $q = "DELETE FROM $table, WHERE uid = $uid"; mysql_query($q); } ... function create_checkbox_query($arr, $table, $uid) { global $table_name; $q = "INSERT INTO $table (uid, skill_id) VALUES"; foreach ($arr as $check) { $q .= " ( $uid , $check )" . ","; } return substr($q, 0, -1); } insert_skills("1", $skills); thanks much, olinux _ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] Copy data from one mysql table to another?
In article [EMAIL PROTECTED], [EMAIL PROTECTED] (Bob Stone) wrote: I cannot find any documentation on how to copy the data from one mysql table to another, i.e. table1, columnx to table2, columnx. See the mysql documentation of the "insert into" syntax for how to use a trailing "select" statement to get the values to be inserted. In a single statement you can select the data from one table and insert it into another. Example: "insert into table2 (p_key,data) select p_key,data from table1 where p_key 100 and data !='garbage'" (This also works for "replace into" and "create table" statements, BTW. Nifty, eh? g) -- CC -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP-DB] Copy data from one mysql table to another?
do something like - 1. make a third table indentical to table svt_members. lets call it svt_members_temp. 2. load the svt_members_temp table with the merged values. "Insert into svt_members_temp(key_svt_members, phone, etc,etc,etc) Select phone.key_svt_members, phone.phone, svt_members.etc, svt_members.etc, svt_members.etc From svt_members, phone Where svt_members.key_svt_members = phone.key_svt_members" 3. cross your fingers (or backup) 4. empty the contents of the original table. "delete from svt_members" 5. load the data back into the real table. "Insert into svt_members(key_svt_members, phone, etc,etc,etc) Select svt_members_temp(key_svt_members, phone, etc,etc,etc)" - brian hardwick -Original Message- From: Bob Stone [mailto:[EMAIL PROTECTED]] Sent: Wednesday, March 28, 2001 3:54 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] Copy data from one mysql table to another? Dear PHP Helpers, I cannot find any documentation on how to copy the data from one mysql table to another, i.e. table1, columnx to table2, columnx. Can you recommend a way? Here is the situation. I have one table called "phone" with two columns. The first column is called "key_svt_members," the second is called "phone." I have a second table called "svt_members." This table has 17 columns including "key_svt_members" and "phone." The phone column in this table is currently empty. I wish to copy the data that is in phone, phone into svt_members. Can you recommend a method? Thanks in advance, Bob Stone __ Do You Yahoo!? Get email at your own domain with Yahoo! Mail. http://personal.mail.yahoo.com/?.refer=text -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] how do I connect to MSSQL and mySQL with PHP4 and Linux?
I run Apache, PHP4, RH Linux, and mySQL currently. Everything is fine. What I need to do is get Microsoft SQL Server in there as well. I see this FreeTDS thing (www.freetds.org), but do I really need that? I don't even know what it is really? The 'FAQ' is not very informative for a 'novice'. It seems like some extra layer of minutiae that I don't want to deal with. Isn't there some way to compile PHP "--with-mssql" just like there is "--with-mysql"? And there are all these built in mssql_connect() etc functions in PHP already, how would FreeTDS effect that? on this page: http://www.php.net/manual/en/ref.mssql.php there is an example on how to compile everything, but it still shows freeTDS in there. I looked through the archives: http://marc.theaimsgroup.com/?l=php-dbw=2r=2s=mssql+mysqlq=b but didn't find anything remotely useful. I guess I was hoping this would be simple, like mySQL connectivity was... Thanks in advance, Daevid.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] Select Database number show it
Friends, Can you tell me how to select database between 1-5 and then show it to the web. ex : 1 xx 2 xx 3 xx 4 xx 5 xx 6 xx 7 xx 8 xx 9 xx 10 xx I think it's easy, but I'm a beginner here. so I don't know how to do that. Thanks Regards, Naga _ www.kaskus.com - FREE EMAIL SERVICE -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP-DB] Select Database number show it
I believe this is what you want: SELECT * FROM mydatabase LIMIT 0,5 --- David Balatero [EMAIL PROTECTED] --- -Original Message- From: Naga Sean [mailto:[EMAIL PROTECTED]] Sent: Wednesday, March 28, 2001 5:06 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] Select Database number show it Friends, Can you tell me how to select database between 1-5 and then show it to the web. ex : 1 xx 2 xx 3 xx 4 xx 5 xx 6 xx 7 xx 8 xx 9 xx 10 xx I think it's easy, but I'm a beginner here. so I don't know how to do that. Thanks Regards, Naga _ www.kaskus.com - FREE EMAIL SERVICE -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] managing large result sets
Addressed to: "houston" [EMAIL PROTECTED] [EMAIL PROTECTED] ** Reply to note from "houston" [EMAIL PROTECTED] Wed, 28 Mar 2001 12:14:51 -0600 I have to deal with displaying result sets that could potentially be quite large. It would be bad form to drop 10,000 rows into a browser table so I need a strategy for dealing with this possibility. It's obviously not a big deal to limit the output but what is the typical strategy for handling next previous behavior? It seems terribly inefficient to requery for a subset each time. I suppose that I could dump the entire result set to a text file keyed to the session but that raises the problem of garbage collection with potentially large files. Anyone have experience with this problem? It may seen inefficient, but a new query each time is the way to handle it. If you are using MySQL look at the LIMIT clause. SELECT whatever FROM someTable LIMIT start, count Start is the record number of the first entry to return. Count is how many to return. I believe you will find this is not as inefficient as it may seem as it is a common thing to do and the people who wrote MySQL know it. I believe you can count on the database to cache the result set for you, and handle garbage collection if you don't hit it often enough. Rick Widmer Internet Marketing Specialists http://www.developersdesk.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] how do I connect to MSSQL and mySQL with PHP4 and Linux?
I see this FreeTDS thing (www.freetds.org), but do I really need that? I don't even know what it is really? The 'FAQ' is not very informative for a 'novice'. It seems like some extra layer of minutiae that I don't want to deal with. Isn't there some way to compile PHP "--with-mssql" just like there is "--with-mysql"? No. And there are all these built in mssql_connect() etc functions in PHP already, how would FreeTDS effect that? It lets you use them. There are two ways to talk to an SQL server, ODBC (in which case you'd use the odbc_* functions) or TDS (using the sybase_* or mssql_* functions). You'll need support installed on your linux box for at least one of these protocols. All the unix based ODBC stuff I've seen also _requires_ software to be installed on your SQL server. TDS does not; think of it as the 'native' protocol spoken by the MS SQL server (and Sybase servers actually). It's _way_ easier than ODBC (I never could get ODBC support installed and working on our Digital Unix machines). FreeTDS is a free, open source implementation of the TDS protocol. I guess I was hoping this would be simple, like mySQL connectivity was... It's no more work than MySQL. In order to compile PHP with MySQL support, you first had to install MySQL. In order to talk to a Sybase or MS SQL server, you need to install TDS. FreeTDS is very easy to install. You should be able to install FreeTDS and recompile PHP in under an hour. The only tricky part is knowing what port the SQL server listens on (the default is 1433). Feel free to email me if you need more help. By the way, I understand there are major issues with SQL2000 server. In that case, ODBC might be a better choice. - Darryl -- Darryl Friesen, B.Sc., Programmer/Analyst[EMAIL PROTECTED] Education Research Technology Services, http://gollum.usask.ca/ Department of Computing Services, University of Saskatchewan -- "Go not to the Elves for counsel, for they will say both no and yes" -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] help with a parse error
Petra wrote: I just subsribed to this list with the hope you can help me. We can try snip echo("P Here are all the products in our database: /P:); add a " before the ; here // Request the text of all the products $result = mysql_query( "select * from products"); !this is line 52!! Your problem is the previous line, you are missing a " on the end of it Cheers Tim -- | Disclaimer:| Timothy Aslat [EMAIL PROTECTED] | | The sender of this email is a figment | http://www.goodiesruleok.com | | of a deranged imagination and leaves it| Spyderweb Consulting | | to your own devices to decide whose... | P: 82270800M: 0401088479 | -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] help with a parse error
You didn't mention if the parse error was coming from PHP or from MySQL. The PHP syntax looks okay to me at first glance (that is, a quick look through indicates that there appears to be appropriate numbers of semicolons and closing braces). So perhaps the thing issuing the parse error is MySQL? In that case, I'd hazard a guess that you don't have a table named products. Check the spelling, capitalization, whether it's the plural "products" or the singular "product." What helps me say this is that the INSERT statement above your line 52 inserts into a table called "JShistbau" and your SELECT statement appears to pull data from a table called "products." I'm not saying that that's necessarily wrong, because it could very well be perfectly valid. But without knowing more about your database layout, that's all I can think of. By the way, (and it shouldn't matter...) but have you also tried removing the space in the "end if;" (part of your larger if:-else:-endif; statement)? I personally don't use that alternative syntax, so I don't know if the space matters. Doug At 01:22 PM 3/29/01 +1000, Petra wrote: hi I just subsribed to this list with the hope you can help me. I am working on this code and I get a parse error in line 52 which is ... I been going through it over and over and can't find a glue. Has anyone out there a solution for me please? I am a beginner in PHP and like to hear about anything I need to know. Kindest Regards Petra [EMAIL PROTECTED] ? else: // Connect to the database server $dbcnx = @mysql_connect("localhost", "root", ""); if (!$dbcnx) { echo( "PUnable to connect to the " . "database server at this time./P" ); exit(); } //Select the products database if (! @mysql_select_db("JShistbau") ) { echo ( "PUnable to locate the Product " . "database at this time./P" ); exit(); } // If a Product has been submitted, // add it to the database. if ("SUBMIT" == $submitproduct) { $sql = "INSERT INTO JShistbau SET " . "cdescription='$productdescription', " . "cdateavailable=CURDATE()"; if (mysql_query($sql)) { echo("PYour Product has been added./P"); } else { echo("PError adding submitted product: " . mysql_error(). "/P"); } } echo("P Here are all the products in our database: /P:); // Request the text of all the products $result = mysql_query( "select * from products"); !this is line 52!! if (!$result) { echo("PError performing query: " . mysql_error() . "/P"); exit(); } // Display the text of each product in a paragraph while ( $row = mysql_fetch_array($result) ) { echo("P" . $row["cdescription"] . "/P"); } //When clicked, this link will load this page //with the product submission form displayed. echo("PAHREF='$PHP_SELF?addproduct=1'" . "Add a Product!/A/P"); end if; ? /BODY /HTML -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] help with a parse error
Gee...all I looked at were the semicolons and the braces (those are what I mess up on the most). I guess it's a good thing I mentioned the space in the endif! It turns out that if you use that syntax, you cannot have a space there. Doug At 01:19 PM 3/29/01 +0930, Timothy Aslat wrote: Petra wrote: I just subsribed to this list with the hope you can help me. We can try snip echo("P Here are all the products in our database: /P:); add a " before the ; here // Request the text of all the products $result = mysql_query( "select * from products"); !this is line 52!! Your problem is the previous line, you are missing a " on the end of it Cheers Tim -- | Disclaimer:| Timothy Aslat [EMAIL PROTECTED] | | The sender of this email is a figment | http://www.goodiesruleok.com | | of a deranged imagination and leaves it| Spyderweb Consulting | | to your own devices to decide whose... | P: 82270800M: 0401088479 | -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] Take out one Data and show it in page
Hi, hte first part after WHERE is the column name of your db. if you want to search with name as a criteria you write: selelct name, nickname from table where name=$name; johannes "Naga Sean" [EMAIL PROTECTED] schrieb im Newsbeitrag [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... I had a question here. How to pull up one database, and then view that row what I mean here is NO NAME AGE 1 JOHN 12 2 RYAN 23 3 JIM42 I want to take JOHN out from database using URL www.example.com/template.php?name=JOHN here is my coding so far, and I know it's wrong, But will make you guys had the idea what I want to do. Thanks --- ?php $db = mysql_connect("localhost", "user","pass"); mysql_select_db("media",$db); $result = mysql_query("SELECT nickname,name FROM database WHERE $myrow[2]=$name",$db); $myrow = mysql_fetch_row($result); ? Your name $myrow[name], $myrow[age] _ www.kaskus.com - FREE EMAIL SERVICE -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] functions and using vars outside of them
I am wondering how to use a variable that is generated by a function ($query) If you would please look at: http://phpbuilder.net/columns/laflamme20001016.php3?page=5 for an example of what i am trying to do. the function will generate the query... but how do i make use of this? i see that i will need to call the function skill_search($skills); but this does not make the variables inside the function available. thanks much, olinux
[PHP-DB] php db performance, db clusters
We are looking for PHP-database performance comparisons. Can someone point out links? Who has experience with high-traffic sites using - MySQL - MS-SQL, especially in a clustered environment? kind regards, Jens Fisch ([EMAIL PROTECTED]) -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]