RE: [PHP-DB] How to solve T_STRING error?
I'd have to see all of your code, but I'm guessing you've left open a paren or a quotation mark, or a block or forgot a semi-colon...probably in a file included before this code is called. Also, you may want to look into how PHP handles null values (I'm pretty sure they evaluate to false, but look into it), and try to verify that $user2->permissionCheck("tech"); is returning a true/false/0/1 sort of result. -- Josh > -Original Message- > From: Martin S [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, December 25, 2002 8:44 AM > To: [EMAIL PROTECTED] > Subject: [PHP-DB] How to solve T_STRING error? > > Just one page still to do. And I'm stuck. > I keep getting: > > Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or > `T_NUM_STRING' in /www/htdocs/dev/users/tracking-update.php on line 43 > > ON this code: > > AuthCheck("post-only"); > commonHeader("IRM Tracking - Update Information"); > PRINT "Go Back"; > $datenow = date("Y-m-d H:i:s"); > $user2 = new User($IRMName); > $type = $user2->getType(); > $permissions = $user2->permissionCheck("tech"); > $track = new Tracking($tID); > $isStat = $track->isStatus($status); > $isAssign = $track->isAssign($user); > $query = "select dev_group from tracking where (ID=$tID)"; > $sth = $adb->prepare($query); > if($sth) > { > $res = $sth->execute(); > $result = $sth->fetchrow_hash(); > $dev_group = $result["dev_group"]; > } > if($permissions)// This is line 43 > { > if(!$isStat) > { > > > and I can't see what ever is wrong! Probably have been looking too much at > it. Anyone who can see an error in here somewhere? > > /Martin S. > > -- > 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] Argh!!!! Help with something o-f-f-t-o-p-i-c
Check out www.devguru.com, they have a great javascript refrence Otherwise I have no idea :) -- Josh -Original Message- From: Aaron Wolski [mailto:aaronjw@;martekbiz.com] Sent: Thursday, November 07, 2002 4:23 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] Argh Help with something o-f-f-t-o-p-i-c Sorry for the OT post y'all.. but I can't find this answer - well not without major major code information that I can't figure out! Basic? I have a series of checkbox arrays like: These are for different records in my DB. Now... I want to check (javascript - this is the off topic part :P) if one of them checkboxes HAS been selected and if so display a confirm message. This is what I have: function checkform(f) { var el, e = 0, firstBox, msg = 'You are about to delete something'; while (el = f.elements[e++]) if (el.type == 'checkbox' && el.checked) { return confirm(msg); return false; } return true; } Now... this DOES work but with one problem.. I have another checkbox within the form that does something different but the confirm() will display if EITHER checkboxes are selected and it SHOULD ONLY be on the delete[] checkbox. I know.. waaay off topic but I don't know how to reference the names that are arrays in javascript :( Sorry again all. Aaron -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] sort by date
It's also a matter of time, I think a lot of people try to be the first to answer something, or are answering from work on a busy day... they just don't have time to write explanations, or to RTFM themselves to verify (I'm guilty of this one), but they want to help. This is especially frustrating when sometimes people are asking for things that aren't obvious, and it takes 2 or 3 posts of them saying "no that won't work because..." before what they're *really* trying to do comes out. You write a long, descriptive post and they really are just trying to do something that won't work the way they want it to. :) I try to be polite, and apologize when I've been proven wrong. I think people get too easily frustrated answering the same question over and over, especially when it's something they've known for a long time. I learned almost everything I know (especially in regards to php) from experience and lots of reading, as I'm sure most of us on this list have, and it's just natural to quote a manual page or point someone there to give them a chance to learn on their own. An then sometimes a question is so obvious and has been asked so many times (by people in the list, by most people as they're learning) that the answer is very simple, and automatic. It's easier to say "try [this code]" than to risk insulting someone by saying "hey you should know better that's all wrong, look here and here and here and find the answer". Like I said, I try to be polite, and I'm very patient with people, but honestly, if they're writing a php script and using a database to back it, they're not newbies, or at the very least, they *should* be able to read a manual. -- Josh -Original Message- From: Lisi [mailto:lists@;shemeshdirectory.co.il] Sent: Thursday, November 07, 2002 2:23 AM To: Snijders, Mark; 'Marco Tabini'; Terry Romine Cc: [EMAIL PROTECTED] Subject: RE: [PHP-DB] sort by date There is a difference between a general, "how do I do this" question and a specific "here's my code, I can't find the bug" question. Sometimes people just need a quick answer specific to their code. Also, unfortunately, many times when people want to point to a resource they give the standard "RTFM". Believe it or not, many newbies don't always know how to do this!! A polite "it's too long to go into on the list, but you can read more about this here" with a link is much more helpful. -Lisi At 04:22 PM 11/6/02 +0100, Snijders, Mark wrote: >why does everybody always gives the answers?? why not a hint, or where to >search that they can learn something about it??? > > > > > >-Original Message- >From: Marco Tabini [mailto:marcot@;inicode.com] >Sent: woensdag 6 november 2002 16:08 >To: Terry Romine >Cc: [EMAIL PROTECTED] >Subject: Re: [PHP-DB] sort by date > > >Ok, going out on a limb here... have you tried something like > >select e.id, title, location, address, contact, category, event_time, >urllink, descript, min(event_date) from eventTable e inner join >dateTable d on e.id = d.id group by e.id > >? > > >Marco > >-- > >php|architect - The magazine for PHP Professionals >The first monthly worldwide magazine dedicated to PHP programmer > >Come visit us at http://www.phparch.com! > > > > >-- >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 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Archiving A Database
Thanks Peter! It turns out the people I work for don't care at all about this data, they were only using it to push clients to buy bigger packages and for bragging rights, so grand totals/totals per client/per period are all they need, the extra data I was logging *just in case* is totally useless to them, so they pushed for the quickest solution. I ended up implementing a scheme to just sort of "condense" the data by a common factor (the client's username), and record totals (see my post: [PHP-DB] Query Help for more info). I'm using cron jobs to run SQL on the database periodically to "move" the data around, and I used table locking in an attempt to keep the data sound. I'm still weary of the huge number (ok, its only like 5, but still) of queries and loops I'm using to gather the data for display, but it seems to be working ok (any suggestions would be greatly appreciated). I'll definitely keep your suggestions in mind for more serious archiving of data in the future. Thanks again! -- Josh -Original Message- From: Peter Beckman [mailto:beckman@;purplecow.com] Sent: Thursday, November 07, 2002 12:05 AM To: Josh Johnson Cc: [EMAIL PROTECTED] Subject: Re: [PHP-DB] Archiving A Database Do you need to archive it forever? Do you need live access to it? If you just need to archive it, read the man page for mysqldump. You can dump specific rows to a file, rename that file dump.2002.05.24, compress it with gzip, and voila, you have all of your data readily available, easily reinserted into your existing live DB. After the dump is complete, just delete those rows out of the DB. Now you have to be sure that the file contains 100% of the data and is accurate. You'll have to figure out how to do that yourself! One way I did it with WWW log files was to make a tmp copy, run a program on it, see if the output had the same number of lines in it, and if it did, delete the tmp copy and replace the original copy with the new copy (IP->DNS translation). In this case you could write a script that parses the newly created dump file in the standard format and, heck, using perl or PHP parse the thing for ),( and see how many you get. If the mysql select gets X rows, and the "),(" or ");" occurs X-1 times, then you know you got all the rows. (OK, it will be more complex than this, but you get the idea.) One record per file could get ugly real quick, both on the filesystem side and the maintenance side. Doing it by day will allow you to repopulate an entire day back into the DB as needed for billing questions or what not. MySQL will keep the unique ID (assuming it is a number auto_incremented) unique and only use ever higher IDs, not use old ones that no longer exist in the DB at the moment. Once you are done with that Day (or days) of data, you just delete it from the DB, knowing you have a copy of that day on file. I would also advise you to have 2-4 copies of all your backups on both physically different computers as well as physically different locations. I kept a copy of my live DB, backed up every 6 hours, at the data center on other computer, on my computer file server at home, and another one 7 states over. Sure, it's a bit of a pain in the ass, but if the data center goes up in smoke and my file server is hacked on the same day, I still have a copy 7 states over. I just used scp (secure-shell copy) and/or rsync + ssh to keep copies current and up to date on remote machines. Peter On Tue, 29 Oct 2002, Josh Johnson wrote: > Does anyone know of speedy methods of periodically archiving and > retrieving a database table? I've got a table I'm using to log > statistical data, and it's getting 10k+ entries per day. Entries are > only logged in the database if the user is authenticated for access, and > only once per access session (the user is authenticated, a cookie is > set, and the entry is logged. From that point the user is authenticated > by verifying the cookie, which expires when the user's browser closes) > > The data is critical (used for billing and such), but the log viewing > script I've written runs slower and slower with each passing day, and at > one point the entire table was corrupted due to neglect on our system > admin's part (I warned them about the default setting of > mysql_max_connections being too low for a site that relied on the DB so > heavily and had so much traffic.). The script is a simple front end to > several MySQL queries, that retrieve totals for the past hour, day, > week, month and grand totals for all clients or a given client. The rest > of the site has been unaffected by the log issues. > > My current approach is to log the data as XML, one record per file, and > create a log file that is an index of refrences to each record. I then > empty previous data n the database. This w
RE: [PHP-DB] MySQL password protection?
Also, you can limit access to a specific table in a specific database for a specific user, if it makes sense in your application. -- Josh -Original Message- From: Peter Beckman [mailto:beckman@;purplecow.com] Sent: Wednesday, November 06, 2002 6:41 PM To: William Trappeniers Cc: [EMAIL PROTECTED] Subject: Re: [PHP-DB] MySQL password protection? Create a user "nobody" with no password and give that user select, update, delete and insert capabilities in your DB and can only connect from localhost (or a certain host). This way they have to be on localhost in order to gain access to your tables, and only then be able to do what your nobody user can do. Then you need to make sure nobody can gain access to localhost without express permission (i.e. plug all security holes). Why are you showing people your source-code that has your password in it? Peter On Wed, 6 Nov 2002, William Trappeniers wrote: > Hi all > > I was wondering if it is possible to protect my password to the MySQL-server > from being in a PHP-script. Now I can't do that, so everybody who gets to > see my php-sourcecode also can see my (not protected/not encrypted) > password. > How can I change this? > > Thanks, > > William > > --- > William Trappeniers > mail at: [EMAIL PROTECTED] > > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > --- Peter BeckmanSystems Engineer, Fairfax Cable Access Corporation [EMAIL PROTECTED] http://www.purplecow.com/ --- -- 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] MySQL password protection?
The standard apache install filters anything named .ht*. on the web tree. -- Josh -Original Message- From: Peter Beckman [mailto:beckman@;purplecow.com] Sent: Wednesday, November 06, 2002 6:44 PM To: Steve Cayford Cc: [EMAIL PROTECTED]; William Trappeniers Subject: Re: [PHP-DB] MySQL password protection? And make sure you make sure the webserver will not SERVE that file!!! You see the source, see that you are fopening the file, I'll find it on your system and get it from the web server and I have your password! Make sure the file is NOT in the document root that the web server serves from. You could also just use the file ".htpasswd", usually by default web servers will NOT serve any file named that. However, much safer to put it somewhere that the web server cannot see (but your PHP script can). Also, this is just as insecure as the other way to any person with a login on the box your PHP script is in. Usually the script is owned by nobody:nobody or read-write all, in which case all local users can get your password. The nobody method at least keeps no password. Peter On Wed, 6 Nov 2002, Steve Cayford wrote: > You could put it anywhere. Stick it in a text file somewhere, fopen() > and read the file for the password. Or keep it in a php script outside > of the web root if that's the issue, then just include() it when you > need to. > > Of course any file you put it in will have to be readable by whatever > user the webserver is running as. > > -Steve > > On Wednesday, November 6, 2002, at 04:16 PM, 1LT John W. Holmes wrote: > > >> I was wondering if it is possible to protect my password to the > > MySQL-server > >> from being in a PHP-script. Now I can't do that, so everybody who > >> gets to > >> see my php-sourcecode also can see my (not protected/not encrypted) > >> password. > >> How can I change this? > > > > You can't, unless you want to put it in php.ini or a my.conf file... > > > > ---John Holmes... > > > > > > -- > > 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 > --- Peter BeckmanSystems Engineer, Fairfax Cable Access Corporation [EMAIL PROTECTED] http://www.purplecow.com/ --- -- 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] Imploding an array?
Does $i have a value? -- Josh -Original Message- From: Rasmus Lerdorf [mailto:rasmus@;php.net] Sent: Wednesday, November 06, 2002 2:16 PM To: Aaron Wolski Cc: [EMAIL PROTECTED] Subject: Re: [PHP-DB] Imploding an array? You sure you want [$i] on that? Is it a 2-dimensional array? On Wed, 6 Nov 2002, Aaron Wolski wrote: > Hey all, > > Can't seem to figure out why this won't work: > > $test = implode(",", $order_index[$i]); > > When I print_r() the variable I have values so I know that works. > > Any thoughts on this? > > Thanks. > > Aaron > -- 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] mysql_fetch_array() question
Of course, you can avoid that problem if you use a join, I guess it all comes down to code complexity vs SQL complexity. -- Josh -Original Message- From: Ignatius Reilly [mailto:ignatius.reilly@;free.fr] Sent: Wednesday, November 06, 2002 1:38 PM To: Josh Johnson; '1LT John W. Holmes'; 'Graeme McLaren'; [EMAIL PROTECTED] Subject: Re: [PHP-DB] mysql_fetch_array() question John is right. In fact one routinely calls two different $result(s) when coding nested loops: while( $details = mysql_fetch_array( $result ) ) { while ( $Email = mysql_fetch_array( $result2 ) ) .. } } when executing the next instance of your loop: while( $details = mysql_fetch_array( $result ) and $Email = mysql_fetch_array( $result2 ) ), each mysql_fetch_array will push both pointers (on your two result resources) by one position. if your result sets do not have the same number of rows, the shorter one will choke before the longer one is finished. therefore you will finish the loop not having called all results from the "long" resource. My 0.02 Belgian francs Ignatius - Original Message - From: "Josh Johnson" <[EMAIL PROTECTED]> To: "'1LT John W. Holmes'" <[EMAIL PROTECTED]>; "'Graeme McLaren'" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sent: Wednesday, November 06, 2002 7:24 PM Subject: RE: [PHP-DB] mysql_fetch_array() question > :) see why I love mailing lists! :) > > It must have been their logic then, I respectfully retract everything I > said, sorry Graeme! Why do I have to work, I could spend my days > researching this stuff before I post! > > Thanks John! > -- Josh > > -Original Message- > From: 1LT John W. Holmes [mailto:holmes072000@;charter.net] > Sent: Wednesday, November 06, 2002 1:21 PM > To: Josh Johnson; 'Graeme McLaren'; [EMAIL PROTECTED] > Subject: Re: [PHP-DB] mysql_fetch_array() question > > That's not true. You can assign them to different variables and it works > fine. > > $r1 = mysql_query("select * from main limit 1") or die(mysql_error()); > $r2 = mysql_query("select * from apft limit 1") or die(mysql_error()); > > $row1 = mysql_fetch_array($r1); > $row2 = mysql_fetch_array($r2); > > print_r($row1); > echo ""; > print_r($row2); > > ---John Holmes... > > - Original Message - > From: "Josh Johnson" <[EMAIL PROTECTED]> > To: "'Graeme McLaren'" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> > Sent: Wednesday, November 06, 2002 1:02 PM > Subject: RE: [PHP-DB] mysql_fetch_array() question > > > > In my experience, (I haven't checked the docs just yet to figure out > > exactly why), you can only work with one result id at a time. Every > time > > you call mysql_query, it resets the result id (I think it frees the > > result id automatically so you can send another query before getting > the > > new result id), so even if you store it in two separate variables, it > > will only refrence the last id (which sounds just like what happened > in > > your initial post). I think this is limited to a given connection, but > > I'm not sure. > > > > One of the, I guess you could say, "shortcomings" of the mysql > interface > > in php is that you can only execute one query at a time, and I think > > this odd result id overwrighting that happens is due to that fact (I > > might be wrong, but I think you can execute multiple queries at a time > > with perl's DBI module). > > > > I hope that makes more sense :) > > > > -- Josh > > > > -Original Message- > > From: Graeme McLaren [mailto:mickel@;ntlworld.com] > > Sent: Wednesday, November 06, 2002 12:17 PM > > To: [EMAIL PROTECTED] > > Subject: Re: [PHP-DB] mysql_fetch_array() question > > > > Josh, Thank you for reply. Thank you to everyone else who replied to > my > > email also. I solved the problem shortly after posting my question, > > I've > > now got a massive SQL query which does the trick. > > > > I was interested when you replied and part of it read: "Just > > remember that you can only work with one mysql result per connection > at > > a time". Can you explain a little more about that please? I don't > > think I > > fully understand what you mean. > > > > Cheers, > > > > Graeme :) > > > > - Original Message - > > From: "Josh Johnson" <[EMAIL PROTECTED]> > > To: <[EMAIL PROTECTED]> > > Sent: Wednesday, November 06, 2002 12:
RE: [PHP-DB] mysql_fetch_array() question
:) see why I love mailing lists! :) It must have been their logic then, I respectfully retract everything I said, sorry Graeme! Why do I have to work, I could spend my days researching this stuff before I post! Thanks John! -- Josh -Original Message- From: 1LT John W. Holmes [mailto:holmes072000@;charter.net] Sent: Wednesday, November 06, 2002 1:21 PM To: Josh Johnson; 'Graeme McLaren'; [EMAIL PROTECTED] Subject: Re: [PHP-DB] mysql_fetch_array() question That's not true. You can assign them to different variables and it works fine. $r1 = mysql_query("select * from main limit 1") or die(mysql_error()); $r2 = mysql_query("select * from apft limit 1") or die(mysql_error()); $row1 = mysql_fetch_array($r1); $row2 = mysql_fetch_array($r2); print_r($row1); echo ""; print_r($row2); ---John Holmes... ----- Original Message - From: "Josh Johnson" <[EMAIL PROTECTED]> To: "'Graeme McLaren'" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sent: Wednesday, November 06, 2002 1:02 PM Subject: RE: [PHP-DB] mysql_fetch_array() question > In my experience, (I haven't checked the docs just yet to figure out > exactly why), you can only work with one result id at a time. Every time > you call mysql_query, it resets the result id (I think it frees the > result id automatically so you can send another query before getting the > new result id), so even if you store it in two separate variables, it > will only refrence the last id (which sounds just like what happened in > your initial post). I think this is limited to a given connection, but > I'm not sure. > > One of the, I guess you could say, "shortcomings" of the mysql interface > in php is that you can only execute one query at a time, and I think > this odd result id overwrighting that happens is due to that fact (I > might be wrong, but I think you can execute multiple queries at a time > with perl's DBI module). > > I hope that makes more sense :) > > -- Josh > > -Original Message- > From: Graeme McLaren [mailto:mickel@;ntlworld.com] > Sent: Wednesday, November 06, 2002 12:17 PM > To: [EMAIL PROTECTED] > Subject: Re: [PHP-DB] mysql_fetch_array() question > > Josh, Thank you for reply. Thank you to everyone else who replied to my > email also. I solved the problem shortly after posting my question, > I've > now got a massive SQL query which does the trick. > > I was interested when you replied and part of it read: "Just > remember that you can only work with one mysql result per connection at > a time". Can you explain a little more about that please? I don't > think I > fully understand what you mean. > > Cheers, > > Graeme :) > > - Original Message - > From: "Josh Johnson" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Wednesday, November 06, 2002 12:29 PM > Subject: RE: [PHP-DB] mysql_fetch_array() question > > > > I concur with Jason, but if restructuring is out of the question, just > > rearrange your queries like this: > > > > $query = "SELECT Name, Address FROM users"; > > $result = mysql_query($query); > > while($details = mysql_fetch_array($result)){ > > echo "Name: $details[Name]"; > > echo "Address: $details[Address]"; > > } > > $query2 = "SELECT EmailAddress From Members"; > > $result2 = mysql_query($query2); > > while($details = mysql_fetch_array($result2)){ > > echo "Email: $Email[EmailAddress]"; > > } > > > > The results won't come out at the same time, but you could use some > > logic to combine the results into an array by a common factor. Just > > remember that you can only work with one mysql result per connection > at > > a time. You *may* (untested!) be able to accomplish what you want to > do > > with two separate connections, but again, this is seriously overkill. > :) > > > > I'd definitely recommend restructuring your talbes as Jason suggested. > > -- Josh > > > > > > -Original Message- > > From: Jason Wong [mailto:phplist@;gremlins.com.hk] > > Sent: Wednesday, November 06, 2002 5:24 AM > > To: [EMAIL PROTECTED] > > Subject: Re: [PHP-DB] mysql_fetch_array() question > > > > On Tuesday 05 November 2002 05:47, Graeme McLaren wrote: > > > Hi, Anyone know how I can use two mysql_fetch_array() functions > > similar > > > to the code below? I've tried a few different ways but I keep > getting > > > Resource ID #4. I need to do this to retrieve an email address from > > one > > > t
RE: [PHP-DB] mysql_fetch_array() question
In my experience, (I haven't checked the docs just yet to figure out exactly why), you can only work with one result id at a time. Every time you call mysql_query, it resets the result id (I think it frees the result id automatically so you can send another query before getting the new result id), so even if you store it in two separate variables, it will only refrence the last id (which sounds just like what happened in your initial post). I think this is limited to a given connection, but I'm not sure. One of the, I guess you could say, "shortcomings" of the mysql interface in php is that you can only execute one query at a time, and I think this odd result id overwrighting that happens is due to that fact (I might be wrong, but I think you can execute multiple queries at a time with perl's DBI module). I hope that makes more sense :) -- Josh -Original Message- From: Graeme McLaren [mailto:mickel@;ntlworld.com] Sent: Wednesday, November 06, 2002 12:17 PM To: [EMAIL PROTECTED] Subject: Re: [PHP-DB] mysql_fetch_array() question Josh, Thank you for reply. Thank you to everyone else who replied to my email also. I solved the problem shortly after posting my question, I've now got a massive SQL query which does the trick. I was interested when you replied and part of it read: "Just remember that you can only work with one mysql result per connection at a time". Can you explain a little more about that please? I don't think I fully understand what you mean. Cheers, Graeme :) ----- Original Message - From: "Josh Johnson" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, November 06, 2002 12:29 PM Subject: RE: [PHP-DB] mysql_fetch_array() question > I concur with Jason, but if restructuring is out of the question, just > rearrange your queries like this: > > $query = "SELECT Name, Address FROM users"; > $result = mysql_query($query); > while($details = mysql_fetch_array($result)){ > echo "Name: $details[Name]"; > echo "Address: $details[Address]"; > } > $query2 = "SELECT EmailAddress From Members"; > $result2 = mysql_query($query2); > while($details = mysql_fetch_array($result2)){ > echo "Email: $Email[EmailAddress]"; > } > > The results won't come out at the same time, but you could use some > logic to combine the results into an array by a common factor. Just > remember that you can only work with one mysql result per connection at > a time. You *may* (untested!) be able to accomplish what you want to do > with two separate connections, but again, this is seriously overkill. :) > > I'd definitely recommend restructuring your talbes as Jason suggested. > -- Josh > > > -Original Message- > From: Jason Wong [mailto:phplist@;gremlins.com.hk] > Sent: Wednesday, November 06, 2002 5:24 AM > To: [EMAIL PROTECTED] > Subject: Re: [PHP-DB] mysql_fetch_array() question > > On Tuesday 05 November 2002 05:47, Graeme McLaren wrote: > > Hi, Anyone know how I can use two mysql_fetch_array() functions > similar > > to the code below? I've tried a few different ways but I keep getting > > Resource ID #4. I need to do this to retrieve an email address from > one > > table and retrieve details from another. > > > > Cheers for any tips - I'm stumped with this one, > > > > Graeme :) > > > > $query = "SELECT Name, Address FROM users"; > > $query2 = "SELECT EmailAddress From Members"; > > > > $result = mysql_query($query); > > $result2 = mysql_query($query2); > > > > while($details = mysql_fetch_array($result) and $Email = > > mysql_fetch_array($result2)) > > { > > echo "Name: $details[Name]"; > > echo "Address: $details[Address]"; > > echo "Email: $Email[EmailAddress]"; > > } > > Unless I've missed something you're going about this the wrong way. For > what > you want to do, you should (in general) be able to accomplish it using > just a > single query. > > What fields do the tables 'users' and 'Members' contain? There should be > a > field there (like eg. userid) which links the two together. If there > isn't > one then you should seriously restructure your tables so that there is > one. > > -- > Jason Wong -> Gremlins Associates -> www.gremlins.com.hk > Open Source Software Systems Integrators > * Web Design & Hosting * Internet & Intranet Applications Development * > > > /* > Cats are smarter than dogs. You can't make eight cats pull a sled > through > the snow. > */ > > > -- > 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 > -- 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] Question
This isn't the place for discussions of php development, I think php-dev is what you want... but ah, PHP is a full-blown programming language, even under widnows. http://www.php.net/manual/sv/features.commandline.php <-- check this page out You can write shell scripts with it, associate windows with php files so double-clicking on a php file will execute it, there's even wrappers for the windows API... http://www.php.net/manual/en/ref.w32api.php, not to mention the windows port of SDL *and* GTK... -- Josh -Original Message- From: Chris Payne [mailto:chris@;planetoxygene.com] Sent: Wednesday, November 06, 2002 11:28 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] Question Hi there everyone, Why are so many attachments coming in to the list? Hopefully it's not because somebody has a virus and is infecting people who open them. So don't open attachments unless you are expecting something. Are there any plans to make PHP for windows a full blown programming language that doesn't need to be run through a web browser? That would be so nice in my opinion. Chris -- 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] sort by date
I agree, but in regard to your last paragraph, you're assuming that they read your post and respond to it. Everybody's quick to answer simple redundant questions that every programmer *should* know the answer to, but higher level stuff seems to just get ignored. I'd hope in a high-frequency list like this the converse would be true. Where are the "seasoned pros" when somebody is asking a hard question, or asking for alternative approaches to a problem? -- Josh -Original Message- From: Hutchins, Richard [mailto:Richard.Hutchins@;GetingeCastle.com] Sent: Wednesday, November 06, 2002 10:48 AM To: [EMAIL PROTECTED] Subject: RE: [PHP-DB] sort by date Just to weigh in on the tail end here, a FAQ of the top N items would be nice. But I have to say, I use the archives a lot before I post to the list. The archives contain the answers to most questions out there. If subscribers to this list checked the archives to see if their answer is there, then questions like register_globals might decrease in frequency. The other side effect of researching answers for yourself before posting is that you gain exposure to more of the language faster. How many times do you read about something that doesn't solve your immediate problem, but puts an idea into your head as to how you might handle a future situation? I know I benefit from it. Still, nothing better than being able to get help from some of the seasoned pros on this list right away. -- 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] mysql_fetch_array() question
I concur with Jason, but if restructuring is out of the question, just rearrange your queries like this: $query = "SELECT Name, Address FROM users"; $result = mysql_query($query); while($details = mysql_fetch_array($result)){ echo "Name: $details[Name]"; echo "Address: $details[Address]"; } $query2 = "SELECT EmailAddress From Members"; $result2 = mysql_query($query2); while($details = mysql_fetch_array($result2)){ echo "Email: $Email[EmailAddress]"; } The results won't come out at the same time, but you could use some logic to combine the results into an array by a common factor. Just remember that you can only work with one mysql result per connection at a time. You *may* (untested!) be able to accomplish what you want to do with two separate connections, but again, this is seriously overkill. :) I'd definitely recommend restructuring your talbes as Jason suggested. -- Josh -Original Message- From: Jason Wong [mailto:phplist@;gremlins.com.hk] Sent: Wednesday, November 06, 2002 5:24 AM To: [EMAIL PROTECTED] Subject: Re: [PHP-DB] mysql_fetch_array() question On Tuesday 05 November 2002 05:47, Graeme McLaren wrote: > Hi, Anyone know how I can use two mysql_fetch_array() functions similar > to the code below? I've tried a few different ways but I keep getting > Resource ID #4. I need to do this to retrieve an email address from one > table and retrieve details from another. > > Cheers for any tips - I'm stumped with this one, > > Graeme :) > > $query = "SELECT Name, Address FROM users"; > $query2 = "SELECT EmailAddress From Members"; > > $result = mysql_query($query); > $result2 = mysql_query($query2); > > while($details = mysql_fetch_array($result) and $Email = > mysql_fetch_array($result2)) > { > echo "Name: $details[Name]"; > echo "Address: $details[Address]"; > echo "Email: $Email[EmailAddress]"; > } Unless I've missed something you're going about this the wrong way. For what you want to do, you should (in general) be able to accomplish it using just a single query. What fields do the tables 'users' and 'Members' contain? There should be a field there (like eg. userid) which links the two together. If there isn't one then you should seriously restructure your tables so that there is one. -- Jason Wong -> Gremlins Associates -> www.gremlins.com.hk Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * /* Cats are smarter than dogs. You can't make eight cats pull a sled through the snow. */ -- 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] need help with SHOW COLUMNS
I think you may want to loop over $row=mysql_fetch_array($result), each row should have the name of the field, and some additional info about it (I just ran a SHOW COLUMNS query on my log tables in my last post, that should give you an idea of what the output is), try executing the query in the mysql client, the top row of the output will be the names of the fields of the array So try: while($row = mysql_fetch_array ($result)){ var_dump($row); } to see what the db is returning, and access it accordingly. -- Josh -Original Message- From: David Rice [mailto:haloplayer@;hotmail.com] Sent: Tuesday, November 05, 2002 10:12 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] need help with SHOW COLUMNS I am tryin to create a DBMS, the part of my code that is currently causing a problem is mysql_select_db("filterseveuk") or die(mysql_error()); $query = "SHOW COLUMNS FROM " .$table. ""; $result = mysql_query ( $query ) or die( mysql_error () ); $numrows = mysql_num_rows ($result); $row = mysql_fetch_array ($result); for($x=0; $x <= $numrows; $x++){ echo $row[$x] ; } It produces the error user_idint(11)PRIauto_increment The output i want to obtain from this query is that php prints out a list of the field names. I don't know why this is not working How do i get it to only display the column names!? _ Protect your PC - get McAfee.com VirusScan Online http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963 -- 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] Idea as to why this query won't work as expected?
The or part should be in parens. Your bascialy saying grab everything that has order_status='Shipped' and your date requirements, OR everything where order_status is equal to 'Not Shipped'... -- Josh -Original Message- From: Aaron Wolski [mailto:aaronjw@;martekbiz.com] Sent: Tuesday, November 05, 2002 9:00 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] Idea as to why this query won't work as expected? Hi All, I have a query like: select * FROM OrderTable WHERE submitted=1 AND dateinserted>='1036386000' AND dateinserted<='1036502796' AND order_status='Shipped' OR order_status='Not Shipped' Now.. if I omit the "AND order_status='Shipped' OR order_status='Not Shipped'" part the query works fine and only returns 2 results (as expected). However, with the inclusion of the previous I get all the results (currently 8) returned. It seems to be ignoring everything before "AND order_status='Shipped' OR order_status='Not Shipped'". Any clues? Much thanks! Aaron -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Query Help
I've implemented the scheme I briefly outlined in my last post (locking for data integrity), and now I'm writing queries to get totals from my logs, and I think I might be over-complicating things, and I'd like some alternative views on the subject. My "grandiose scheme" works like this: Problem: logging unique users that are authenticated for access to my companies website into a MySQL database table, only valid data to report is total number of unique authentications. Solution: because of the high volume of unique authentications being logged (over 15k per day), I periodically "condense" the data into 3 tables beyond the main table that logs users as they come in. My tables look like this: +---+ | access_log| +---+---+--+-+-+---+ | Field | Type | Null | Key | Default | Extra | +---+---+--+-+-+---+ | timestamp | timestamp(14) | YES | MUL | NULL| | | code | text | | | NULL| | | refer | text | | | NULL| | | ip| varchar(64) | | | | | | access| varchar(128) | | MUL | 0 | | +---+---+--+-+-+---+ NOTE: The access field in the access_log table correlates to the client field in the table below. Logging was an afterthought initially, but then it became very important, so I cannot change the field now without a lot of debugging. Doing this database cleanup wasn't a priority either until a couple of months later when the size of the access_log table grew out of control (over 1GB on disk, 800k records). +-+ | access_log_daily/weekly/monthly | ++---+--+-+-+---+ | Field | Type | Null | Key | Default | Extra | ++---+--+-+-+---+ | client | varchar(32) | | | | | | total | bigint(20)| | | 0 | | | stamp | timestamp(14) | YES | | NULL| | ++---+--+-+-+---+ I've set up a cron jobs that run these queries periodically: Daily: LOCK TABLES access_log WRITE, access_log_daily WRITE; INSERT INTO access_log_daily (client, total) SELECT access, COUNT(timestamp) AS total FROM access_log GROUP BY access; DELETE FROM access_log; UNLOCK TABLES; Weekly: LOCK TABLES access_log_daily WRITE, access_log_weekly WRITE; INSERT INTO access_log_weekly (client, total) SELECT client, SUM(total) as total FROM access_log_daily GROUP BY client; DELETE FROM access_log_daily; UNLOCK TABLES; Monthly: LOCK TABLES access_log_weekly WRITE, access_log_monthly WRITE; INSERT INTO access_log_monthly (client, total) SELECT client, SUM(total) as total FROM access_log_weekly GROUP BY client; DELETE FROM access_log_weekly; UNLOCK TABLES; So this way, the access_log table is never bigger than the total number of users for a 24 hour period, but we can still look into it if a problem arises where we need someone's ip address or the auth code they were given, and the other tables can only be as big as the interval of "condensation", times the total number of clients, and store totals, so it *should* be easy to gather information from them. In my reporting scripts, I need to be able to find the grand totals for the past hour, day, week, month, and year. My first idea was to use multiple queries and just add all of the results together, but I'm not sure if this is the best way, or if it will reflect the most accurate per-period results. I appreciate any input anyone has. Thanks, -- Josh -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Locking for data integrity
I'm making a query to one table, and inserting it into another table (INSERT.SELECT syntax). The table that's the source of the copy is updated constantly, and is has a large amount of data in it. Will locking the table for write (or read??) access keep insert queries to the source table from executing at all, or will they be queued, and executed after the lock is lifted? The MySQL manual wasn't clear on this. I may be misunderstanding the SQL meaning of "locking" something; I want to keep a table from being updated while I'm getting information from it, but I still want the inserts to be executed after I'm finished with the table. I'm running the query in a cron job daily to "compress" the data in a log table, and keep it from growing out of control, by copying the totals per user from the live table into a daily table, and then deleting all of the records in the live table. If the live table is locked and the inserts made during the lock are queued and executed after the lock is released, it makes the whole thing a lot easier to manage. I can empty the live table and be sure that all of the data in the live table the following day is new data, and not worry about data loss because of the execution time of the script (which could be as long as 30 seconds or more, we've gotten over 17,500 unique entries in the past 24 hours, and the site is growing). Thanks for your help. -- Josh -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] boolean instead of array
It's hard to tell which output is from which loop, you might be getting confused (if anything, you might be confusing anyone that might help)... the Boolean was probabally due to a bad result, for whatever reason (maybe your connect code was wrong? I'm not sure but I think you get a valid resource id even when your connection fails or you don't get any returs on your query), and the arrays were more than likely empty before if they didn't contain your results, because mysql_fetch_row returned an array of nulls (try looping through those arrays, and checking is_null on the values). I'll skip the lecture on naming conventions, especially the lengthy section about other people reading your code. Without seeing the rest of your script, or your talbe structure, you might want to try a LEFT JOIN in your query, that will preserve values that are null. You might also want to use mysql_fetch_array (or mysql_fetch_object), which I've always used, and never had a problem getting results from. I'd be nice to at least see your table structure, then I or anybody else here could give you a more precise answer. I'd suggest looking at the mysql manual entries for SUM, JOIN, LEFT JOIN, and the php manual entries for mysql_fetch_row, mysql_fetch_array, and mysql_query. Hope this is helpful! -- Josh -Original Message- From: John Coder [mailto:jcoder@;insightbb.com] Sent: Saturday, November 02, 2002 9:23 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] boolean instead of array I seem to somehow get an boolean instead of an array from a mysql_fetch_row function and I have no idea how. Here's the code; $names=mysql_query("select name from dept join picdata where dept.deptid=picdata.deptid limit 5"); print $names.""; //offending query $resets=mysql_query("select sum(reset) from Tmp group by deptid order by deptid limit 5"); while($c=mysql_fetch_row($names)); { //$a[]=$c[0]; commented out for troubleshooting $y=gettype($c); print $y.""; } while($e=mysql_fetch_row($resets)) { $z=gettype($e); print $z.""; //$b[]=$e[0]; commented out for troubleshooting } Here's the output from a terminal: select name from dept join picdata where picdata.deptid=dept.deptid limit 5; +-+ | name| +-+ | BodyWatch | | BreakThroughGallery | | TempGallery | | KidZone | | Lobby | +-+ 5 rows in set (0.01 sec) here's the output from the browser: Resource id #3 boolean array array array array array Any suggestions as to what I'm doing wrong? John Coder -- 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] killing cookie
I'm pretty sure you just have to set a cookie to an empty string to delete it, i.e., no expiration time -- Josh -Original Message- From: Seabird [mailto:jacco@;vliegt.nl] Sent: Friday, November 01, 2002 7:16 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] killing cookie Hi everyone, I don't understand why my cookie won't be removed. I set my cookie: setcookie('user',$_SESSION['username'],time()+36000); setcookie('pass',$_SESSION['password'],time()+36000); I kill my cookie: setcookie('user','',time()-60); setcookie('pass','',time()-60); but it doesn't work. why not?? Jacco -- http://seabird.jmtech.ca Attitude is Everything! But Remember, Attitudes are Contagious! Is Yours worth Catching -- 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] COOKIE problem... URGENTLY NEEDED HELP - BEGGING
Are you maybe passing the last parameter in setcookie(), that makes sure that the cookie is only transmitted over a secure connection? Maybe limiting it to a domain, the domain of the secure server instead of the domain of the whole site? http://www.php.net/manual/sk/function.setcookie.php <--- -- Josh -Original Message- From: Aaron Wolski [mailto:aaronjw@;martekbiz.com] Sent: Friday, November 01, 2002 12:23 PM To: [EMAIL PROTECTED] Subject: FW: [PHP-DB] COOKIE problem... URGENTLY NEEDED HELP - BEGGING Importance: High Hi Guys, I'm begging here.. ANYONE have a clue. I can searchinbg and searching but I see nothing that's helping me. Anyone had issues like this before? Thanka!!! Aaron -Original Message- From: Aaron Wolski [mailto:aaronjw@;martekbiz.com] Sent: Friday, November 01, 2002 11:55 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] COOKIE problem... URGENTLY NEEDED HELP Hi All, Ok.. just went live with a site that 'appeared' to work wonderfuylly. However, now it seems I cannot read a cookie in a secure area (https) when it was set in a non-secure area (http). Any clue on how to get this universally to work? Really really need help with this. Arg. Thanks. Aaron -- 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] Newbie-Question: What's that @?
It suppresses error messages and warnings when you call a function, regardless of your level of error reporting. So yeah, it is like batch programming :) -- Josh -Original Message- From: Marcus Fleige [mailto:marcus.fleige@;gmx.de] Sent: Wednesday, October 30, 2002 7:05 PM To: PHP-Mailinglist Subject: [PHP-DB] Newbie-Question: What's that @? hi there, i've got a general question about php-scripts: whats the difference between @mysql_query($query) and @mysql_query($query)? is it the same as in batch programming? like, ignore all return messages? thanks and greetings from germany, marcus -- ^v^ [EMAIL PROTECTED] -- 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] Decimal places.
This works too: print (int)(($eall - $sall) / 1000); -- Josh -Original Message- From: Andrew Wilson [mailto:will@;netwaynetworks.com.au] Sent: Tuesday, October 29, 2002 11:18 PM To: '[EMAIL PROTECTED]' Subject: [PHP-DB] Decimal places. Hay guys, I have two variables ( integers ) that are being minused one from the other and i am printing the result to the screen but i am getting unwanted decimals. print ($eall - $sall) / 1000; My question is what is the easiest way to strip decimals off the above result. The only way i know around it is if i piped the above statement into another varible and set that variable to an integer then printed that. I dont really want to do this as i will end up with 50 extra variables. Thanks in advance for your comments. Andrew Wilson Technical Support Netway Networks 8920-8877 Netway Networks Pty Ltd (T) 8920 8877 (F) 8920 8866 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Archiving A Database
Does anyone know of speedy methods of periodically archiving and retrieving a database table? I've got a table I'm using to log statistical data, and it's getting 10k+ entries per day. Entries are only logged in the database if the user is authenticated for access, and only once per access session (the user is authenticated, a cookie is set, and the entry is logged. From that point the user is authenticated by verifying the cookie, which expires when the user's browser closes) The data is critical (used for billing and such), but the log viewing script I've written runs slower and slower with each passing day, and at one point the entire table was corrupted due to neglect on our system admin's part (I warned them about the default setting of mysql_max_connections being too low for a site that relied on the DB so heavily and had so much traffic.). The script is a simple front end to several MySQL queries, that retrieve totals for the past hour, day, week, month and grand totals for all clients or a given client. The rest of the site has been unaffected by the log issues. My current approach is to log the data as XML, one record per file, and create a log file that is an index of refrences to each record. I then empty previous data n the database. This works, but is very hard/slow to retrieve specific groups of information, and dumping the database takes a long time as well, which adds the difficulty of ensuring no records are lost. I also haven't yet tackled the issue of combining data from the XML seamlessly with live data from the database. I'm opening the floor to other potential solutions, or war stories from anyone else who's been in this situation before. If there's another approach aside from writing individual flat files, please let me know. I haven't tested it yet, but I think maybe logging all entries/data for a given log period into one file would speed things up, but I worry about the 40 megabyte files that could be potentially created. I'm also open to complete alternatives, since the main use for this data is to generate total accesses per a given factor (client, ip, referrer, etc). Any help is greatly appreciated. I can give any information needed, just ask! Thanks, -- Josh P.S. I did suggest that this issue be tackled when I first installed the system that creates the log, but management didn't think it was worth bothering with at the time. P.P.S. I did look through the archives before I posted, and didn't find anything. Please flame in private if I missed something! -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php