[PHP] upgrading from 4.1.2 to 4.3.0 - can anyone point me to a list ofMUST DO'S
I've heard that there are significant changes made between 4.1.2 and 4.3.0 so I need to know what the effects are going to be on our existing sites running old code. Is there a document that explains the effects of upgrading to 4.3.0 from 4.1.2 along with the steps I need to take to make my sites compatible with whatever PHP's new changes are? I've heard bits and pieces - which may as well be rumours - so I'd like to be able to find something in writing from the php.net site if possible. so far no luck. thanks, brian -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Redirection Question (I spoke to soon)
on 7/24/03 8:13 PM, Beauford.2005 at [EMAIL PROTECTED] wrote: > > action="post" name="testing"> > someone else already raised this issue and it doesn't look like you caught it: you have two actions in your form (the second should probably read method="post"), e.g., is your form even submitting to season-write.php? the other potential issue is that you mentioned your redirect function is within an external include file. since you moved the code from one server to another, make sure that the include file is in the correct path since the paths may be different on the new server. you could test by doing some debugging such as require("/path/to/include_file") or die("could not find include file"); brian -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] how can I return several query results per table row?
I'm trying to figure out how I can format the results from a MySQL query so that I can display several records per row, i.e., I'd like to be able to format the results in a table with 3 columns, and as many rows as needed. Please excuse my inability to be concise - my brain seems to be fried from a long day. I'm used to returning query results in a loop which prints out each record in a row: while (list($FirstName, $LastName) = mysql_fetch_row($result)) { echo " $FirstName $LastName "; } however that returns a page that looks like this: Joe Cool John Doe Homer Simpson Bob Vila Dr. Suess Captain Crunch I'm hoping to display the results so that I can have several results per line like so: Joe CoolJohn DoeHomer Simpson Bob VilaDr. Suess Captain Crunch in my naïve thinking, I'm guessing that I'd need to count the query results (mysql_num_rows) and divide them by 3. so if I had 25 records and I wanted them listed 3 per line, I would divide 25/3 = 8.33 and round it up to the next number meaning I would have 9 rows, the last row only having one record. this is about as far as I get before I start getting a bad headache. ;) I'm hoping someone might know of an article/tutorial on how to accomplish this so I don't need to reinvent the wheel. many thanks in advance, brian -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] need help looping through each record with a query - stumped
hey folks - i'm stumped. been working on what i thought would be a simple script to cycle through users' records and perform a query. But I can't get the loops right, it seems like only one or two records get updated. Using MySQL, we have about 2000 students enrolled. each month they take a test. if they pass the most recent 3 tests (consecutively) they earn "Certified" status and get a few perks. Somehow the certification status' got messed up. So I'm trying to create a script that will look through each user's test records to see if they've passed the last 3 tests, and if so, change their certification status in the database. Not very elegant since there are so many records in the database (2000 users), but I don't think i have a choice. Anyways, I've tried to loop through each user, and for each user loop through their scores. But the loops aren't working. I'm sure it's something simple and obvious I'm missing but my brain is fried! I'd appreciate it if someone could take a look and offer any advice. It's about 65 lines of code (with comments). thanks in advance! brian = 75)) { $tally++; } if (($Month == 'December') && ($Score >= 75)) { $tally++; } if (($Month == 'November') && ($Score >= 75)) { $tally++; } if (($Month == 'October') && ($Score >= 75)) { $tally++; } } /* the concept is that if a user has taken and passed the last 3 tests, they become certified. so we look at the current month first and go back 3 months, since it may be the beginning of the month and they may not have taken the current months test yet. Since we increase the counter for each passed test, if the counter equals 3 or more this means they have passed 3 tests and are thereby certified. So we update their certification status in the database. */ if ($tally >= 3) { $query1 = ("UPDATE users SET Certification = 'Y' WHERE Username = '$Username'"); $result1 = mysql_query($query1) or die ("Cannot update user to Certified" . mysql_error ()); } } print ("Update complete!"); ?> -- PHP General 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] need help looping through each record with a query -stumped
thanks guys, I really appreciate it. first off, Martin your suggestion looks great but I don't think its SQL syntax is supported by MySQL. It's a good start though - gives me something to work with :) I guess I need to clarify a bit more about what needs to happen... in the MySQL database, there are two tables involved - "users" and "scores" Both tables have a "Username" field so Username can be used as a key for joins. Unfortunately, since this database is ancient and far from normalized/optimized, neither table uses unique id's. So looking at the scores table the fields are Username, Month, and Score. Another big dud is the fact that the Month field is varchar, not a date field. So this makes it difficult to sort, as Mehmet suggested. And this also makes it difficult to write a function to automate the 3 consecutive month aspect that's required. That's why I had to code to look for specific months - this month (January) counting back 3 (December, November, October). Students have until the end of the month to take the monthly test - so they can maintain certification if they have passed Dec., Nov., and Oct.'s tests. Or, if they have taken and passed January's test, they can be certified if they've also passed December and November. Make sense? 4 months total: if the first 3 are passed and/or last 3 are passed the student is "certified". So... I tried to grab everyone's Username with the first query (which should result in an array of about 2,000 records). Then using the "while" function I thought I could perform a query for each Username. So for each Username in the first result set, I would query the database and select that user's test scores. I would then process these results by looking for specific months and checking to see if those scores were 75 or better. The problem lies in the loop - it doesn't go through each Username in the system like it's supposed to. Are you not supposed to have a 'while' loop inside another 'while' loop? I've really been fighting to restructure the whole database, as it really was poorly planned. But the system is old and there are many, many applications that rely on it. So it'll take time and caution to make that move. In the meantime I'm just trying to figure out how to get this certification bug resolved. I need to finish writing this script so that the database can accurately reflect who is certified. Hope that clarifies things. Any help would be greatly appreciated. In the meantime I'm going to play around with Martin's sql statement - seems like a good start. thanks! brian On 1/9/02 7:18 PM, "Martin Towell" <[EMAIL PROTECTED]> wrote: > i'm converting Brian's php code into sql - he's looking for scores in Oct, > Nov, Dec and Jan, that's what I'm doing in the sql, and the if's all have > "if score >= 75" which is what I'm doing in the sql too, Brian is getting a > total "$tally++" so am I "count(*)"... > > -Original Message- > From: Mehmet Kamil ERISEN [mailto:[EMAIL PROTECTED]] > Sent: Thursday, January 10, 2002 11:10 AM > To: Martin Towell; 'Brian Tully'; PHP DB; PHP > Subject: RE: [PHP] need help looping through each record with a query - > st umped > > > If you are querying the Score >= 75 how are you ging to > take the "Consecutive" requirement into the account. > --- Martin Towell <[EMAIL PROTECTED]> wrote: >> could you change this >> >> $query2 = ("SELECT Month, Score FROM scores WHERE >> Username = >> '$Username'"); >> >> to >> >> $query2 = ("SELECT count(*) FROM scores WHERE >> Username = '$Username' and >> Score >= 75 and Month in ('January', 'December', >> 'November', 'October')"); >> $result2 = mysql_query($query2) or die ("Cannot >> execute query" . >> mysql_error ()); >> $tally = mysql_fetch_row($result2); >> >> take out the while loop (the one with all the if's in it) >> and, if I haven't >> stuffed up somewhere, all will be okay - (btw, I haven't >> had experience >> using mysql, but I'm assuming that it's sql is compatable >> with interbase and >> oracle) >> >> Hope that helps >> Martin >> >> -Original Message- >> From: Brian Tully [mailto:[EMAIL PROTECTED]] >> Sent: Thursday, January 10, 2002 8:59 AM >> To: PHP DB; PHP >> Subject: [PHP] need help looping through each record with >> a query - >> stumped >> >> >> hey folks - >> &
[PHP] Re: [PHP-DB] Re: [PHP] need help looping through each record witha query -stumped
dn - thanks SO much for your detailed reply. :) yes there are tons of problems :( the "last 3 consecutive Months" issue is tricky enough - but the fact that the database is set up all wrong for this type of query is the real problem. unfortunately changing the structure and field formats then changes a LOT of other scripts that interact with with this table. So i need to figure out which is less time consuming - change the database or change the handful of scripts that use this part of the database. But as far as the loop I was trying to accomplish - any idea why it was not processed through completion.? I need to loop through each user's score and process each one. I can't figure out how to do this one user at a time, i.e.: while (list(Username, $Month, $Score) = mysql_fetch_row($result2)) { this will just return every record in the database and doesn't allow me to loop through each Username. so how would I do this? is this where i might use FOR or FOREACH? brian on 1/10/02 7:23 AM, DL Neil at [EMAIL PROTECTED] wrote: > Brian, > ... > > =regardless of the age of the database, the data appears to be normalised (to > the description given) however it > is definitely NOT optimised. You will notice that each of the contributors has > been attempting to work in MySQL, > but you still have the other option - that of tidying up and debugging your > torturous PHP code! The PHP effort > can be used to attempt to 'recover' from the poor database structure, but as > you have observed, at some cost - > particularly if you ask yourself how you are going to get things to work in > February... The problem with > persisting in this is that you have a weak database structure AND you have > some hairy (hard to understand) PHP > code as a work-around (and may God bless all who sail in her)! > > =like the others, my recommendations consist of revisiting your business rules > and then 'optimising' the > database/data structure - best to fix the problem at its source! > > =the idea that the NAME of each month should be used for processing is causing > major problems. The name of the > month is a LABEL, ie is very useful at the tops of reports, letters, > newspapers, etc. It is NOT a tool for > calculations. If you'd like to take a look at the archives of the PHP > discussion list, you'll find my > contribution on this topic dated a few days ago entitled: "counting with dates > (help!)" talking about the three > primary date formats and their uses. > > =So if I sit a test this month (January), and the last month of last year > (December), and the second-last month > of 2000 (November) [and with blinding arrogance, let me assume that I would > pass each with flying colors (cough, > cough)], and further assume that I haven't sat any other tests [much more my > speed!]; the current logic > (apparently) credits me with a certification!? [thank you] Now before anyone > following this labrythine logic > starts to laugh, let me say that there are good reasons/procedures that might > be in place to prevent such a > stupidity happening - but they will almost certainly also make the process of > keeping historical records more > difficult. > > =how does the system keep track of people who do not sit a test during a > particular month? > > =and the other way around: if I sit the test today and fail [please no jeers, > I'm very sensitive] do the rules > allow/is it possible for me to 'resit' during January. Thus is it possible for > me to sit (and pass) single tests > in Nov and Dec, but sit two tests in Jan - one a 'fail' and one a 'pass'. If > so, are you looking at my last > three tests with a view to certification, or are you looking at my last three > passes (during the pertinent three > months)? > > =further: can we assume that a record will be entered into the scores table > regardless of whether the person > passed or failed? (I have assumed so) > > =while on this theme, how is the system to react if tests are not held during > a particular month, eg the > certification center is closed for summer/Christmas vacation, or out of > respect for September 11? > > =another question about 'rules': the problem description indicates that it is > possible for a person to have sat > January's test already/early in the month, but it is also possible that (s)he > has not. Are the tests held on a > particular date for all candidates, or does the system allow each candidate to > pick his/her own test date? > (which also implies that the January date for all candidates will either be > the same, or is potentially very > different) - this may make it easier/harder to define an SQL query. > > =finally, if I have understood correctly, certification is calculated by three > 'month' units, not 90-days. Thus > the rule is not three passes in the last 90 days, but is in fact (today) > something like the last 100 days, ie > any time in November, not only since 10Nov2001. Correct? > > =all of these questions will have a m
[PHP] fopen "r+" not working - how to add to beginning of txt file
hey there - i've been going crazy trying to figure out how to add news items to the top of an already existing txt file containng previous news posts. While I'd love to change the system so everything is database-driven (as most of the rest of the site is), this news area has so much news posts that it would take forever to convert the info the database. SO... i want to just create a simple script that adds text to the beginning of an existing text file, without overwriting any previous text in the file. The manual and php site refer to using the fopen function with the r+ option - which i've done, BUT some if the text still gets overwritten with the new next. here's what I'm using: What happens is that the line does get written to the top of the page but it overwrites or deletes some of the existing text. Even though the r+ option is supposed to put the pointer at the beginning of the file and add to it as opposed to overwriting it doesn't seem to be working for me. What am I doing wrong? Is there a better way to accomplish what I'm trying to do? any help would be GREATLY appreciated! regards, brian -- PHP General 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: SV: [PHP] fopen "r+" not working - how to add to beginning oftxt file
not sure I know how to do this... do you mean to open the file twice? once to read it and put it into a variable and then close the file and open it again, this time for writing? I'm confused. this seems so much harder than it would be with Perl. But I really want to stick with PHP. Can anyone help me out here? I've looked the manual over and over, and checked the php.net website, but nothing covers the situation where you want to add text to the TOP of a file. fopen with the r+ option is not working the way it should. I'd be eternally grateful... brian On 11/19/01 6:45 PM, "Phelps" <[EMAIL PROTECTED]> wrote: > load the content of the file into an variable first and then add the new > text part into it. > > something like this: > > $text = $newtext + $text; > > then save it... It should work... > > P. > >> -Ursprungligt meddelande- >> Från: Brian Tully [mailto:[EMAIL PROTECTED]] >> Skickat: den 19 november 2001 22:03 >> Till: PHP >> Ämne: [PHP] fopen "r+" not working - how to add to beginning of txt file >> >> >> hey there - >> >> i've been going crazy trying to figure out how to add news items >> to the top >> of an already existing txt file containng previous news posts. While I'd >> love to change the system so everything is database-driven (as most of the >> rest of the site is), this news area has so much news posts that it would >> take forever to convert the info the database. >> >> SO... i want to just create a simple script that adds text to the >> beginning >> of an existing text file, without overwriting any previous text >> in the file. >> The manual and php site refer to using the fopen function with >> the r+ option >> - which i've done, BUT some if the text still gets overwritten >> with the new >> next. >> >> here's what I'm using: >> >> > >> $today = getdate(); >> $month = $today[month]; >> $mday = $today[mday]; >> $year = $today[year]; >> >> >> if ($fp = fopen("/home/foo/www/whats_new/whats_new2.txt", "r+")) { >> >> fwrite($fp, "this is the new line of text I want to add to the top of >> the page"); >> >> fclose($fp); >> >> print "success!"; >> >> } >> >> else { >> >> print "Could not open What\'s New file for updating."; >> >> } >> >> ?> >> >> >> What happens is that the line does get written to the top of the >> page but it >> overwrites or deletes some of the existing text. Even though the r+ option >> is supposed to put the pointer at the beginning of the file and >> add to it as >> opposed to overwriting it doesn't seem to be working for me. >> >> What am I doing wrong? >> >> Is there a better way to accomplish what I'm trying to do? >> >> any help would be GREATLY appreciated! >> >> regards, >> brian >> >> >> -- >> PHP General 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 General 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] electronic postcard recommendation?
hi there :) i've been asked to implement an electronic postcard app for a client's website, and was wondering if anyone can recommend an existing implementation, be it open source or commercial -- preferably PHP!. I found a couple of CGI scripts that do a minimal job, but i'm not to keen on doing the CGI thing ever since moving over to PHP for some time now. I'd like to avoid the Internal Server Errors if at all possible ;). anyways, any experience and/or recommendations would be much appreciated. regards, brian -- PHP General 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] is there a more efficient query?
i currently have to query a table for 5 separate values based on elementid and haven't figured out how to do it using just one query with an array or associative array. can someone enlighten me as to how I could perform the following queries more efficiently, i.e., is there a way to do it with one query instead of five? thanks a bunch in advance, brian code: -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] is there a more efficient query?
on 8/6/04 12:28 PM, Jay Blanchard at [EMAIL PROTECTED] wrote: > [snip] > Tis SQL > > SELECT value > FROM element_values > WHERE user = $user_id > AND(element=48 > OR element=52 > OR and so on) > [/snip] > > You can also use IN > > SELECT value > FROM element_values > WHERE user = $user_id > AND element IN ('48', '52',...) thanks Jay! but that only seems to return the first value. how should I be calling the results? $query2 = "SELECT value FROM element_values WHERE " . "(element=48 OR element=49 OR element=50 OR element=51 OR element=52 OR element=53) " . "AND user=$user_id"; $result2 = mysql_query($query2) or die("could not $query2 " . mysql_error()); list($user_name, $address_street, $address_city, $address_state, $address_zip, $phone) = mysql_fetch_array($result2); do i need to do a while loop and create an array or something? thanks again. brian -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Storing text with carriage returns in MySQL
Not sure if I understand the issue completely, but if it's a matter of displaying the text from the database you could use the nl2br function. http://us3.php.net/manual/en/function.nl2br.php Hope that helps, Brian on 7/15/04 4:40 PM, Andrew Wood at [EMAIL PROTECTED] wrote: > Sorry, its the crap software I'm using to view the DB! > > phpMyadmin shows that yes, the text is all there with CRs. > > so it IS something at the display end? > > any ideas, cos I haven't aclue? > > cheers > AW > > > On 15 Jul 2004, at 21:28, Vail, Warren wrote: > >> Perhaps you have another problem. >> >> Do you have PHPMyAdmin access to the database? Could it be that your >> string >> is being stored OK, and the problem is on the retrieval end? >> >> Warren Vail >> >> >> >> -Original Message- >> From: Andrew Wood [mailto:[EMAIL PROTECTED] >> Sent: Thursday, July 15, 2004 1:22 PM >> To: php-gen >> Subject: Re: [PHP] Storing text with carriage returns in MySQL >> >> >> That only seems to work for quotation marks and apostrophes etc. Not >> carriage returns? Unless I'm missing something. >> >> >> On 15 Jul 2004, at 20:23, Vail, Warren wrote: >> >>> http://www.php.net/manual/en/function.addslashes.php >>> >>> Warren Vail >>> >> >> -- >> PHP General Mailing List (http://www.php.net/) >> To unsubscribe, visit: http://www.php.net/unsub.php >> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Show Results one at a time ?
on 1/29/04 7:50 AM, Dave Carrera at [EMAIL PROTECTED] wrote: > Hi List, > > I have a test function who's aim is to take an array an do something which > each value of the array and show the result on screen one at a time. > > --- Test Function Code --- > > function TestFunc(){ > $cnt = array(1,2,3,4,5,6,7,8,9,10); > $i=0; > > while($i <=count($cnt)){ > set_time_limit(2); > echo $cnt[$i].str_repeat(" ", 300) . "";; > ob_flush(); > flush(); > $i++; > } > > --- End --- > > This just shows the output after processing all of the function which is the > behaviour of php as a server side engine, but after reading the manual I > thought the combination of flush() and ob_flush() would do what I wanted, > but I obviously got the wrong end of the stick which flush() and what is > dose. > > So I ask the list if there is a way to show success or fail results for each > of the values of an array one at a time: > i don' think there's a reliable way to do this since you're relying on the browser to display these items as PHP prints them out. as someone else pointed out some browsers don't render items as they load and instead wait for all the page to load before rendering the page. this is especially true of pages using tables. perhaps a workaround would be to use a little DHTML (CSS & Javascript). i don't have the exact code but i'm fairly confident it can be done. here's the concept: - when looping through each value place each in its own DIV with a unique ID, i.e., result$cnt[$i]. All DIVs should be styled so that they are NOT visible. (i.e., the page loads, all DIVs are loaded but are hidden). you can do this through visibility = "hidden" or display = "none" - create/find a Javascript show/hide layer script that also has a timer function. since you've given each DIV it's own unique ID based upon the $cnt[$i] value, you can reference these within the Javascript by doing a similar loop. in the loop you'll identify each layer by it's unique ID and change it's visibility = "visible" or display = "block". in between each item in the loop you can add a pause (similar to what you were trying in the PHP code). hope this is clear enough and hope it helps. regards, brian -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Managed Server/Cluster hosting recommendations?
sorry if this is considered "off-topic" but I'm desperate to find a new hosting provider that specializes in managed servers/clusters. it looks as though our current host is going under so we need to move fast. we have a pretty intricate setup that involves load balancing of both web (Apache) and database (MySQL) servers. ideally the host would also be capable of doing some development work (PHP/Perl/Ruby) - for those times when we're overwhelmed with work. we're in the upstate NY metro area, and would love to find a reliable, capable host that utilizes Telehouse's NY facility if possible. many thanks in advance, brian -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Php error with MySql
sounds like there's something up with the query, perhaps the wrong table name. as a debugging method I usually use the die() clause when performing a query so I can ensure the query is correct. try using this: $qResult = mysql_query ("SELECT * FROM blog_entries ORDER BY id DESC") or die("could not run the query: " . mysql_error()); chances are there is not a "blog_entries" table or an "id" field in the database you're connecting to. hope that helps, brian on 1/6/05 12:50 PM, Wil Hitchman at [EMAIL PROTECTED] wrote: > I get the following error > > Warning: mysql_num_rows(): supplied argument is not a valid MySQL result > resource in /home/wilmail/public_html/elblog.php on line 7 > &n=& //error ends here > > with the following bit of code > > $qResult = mysql_query ("SELECT * FROM blog_entries ORDER BY id DESC"); > > $nRows = mysql_num_rows($qResult); > $rString ="&n=".$nRows; > > If I am just naming a variable how is the argument not valid? > > Thanks, > > Wil -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Recommended Job Posting sites? Need to hire someone w/ PHP exp.
Hey there - I was wondering what the recommended sites are to post/find jobs related to web development - especially PHP. The sites I've visited list mostly ASP and Java related jobs so I'm wondering where do the PHP folks go to find opportunities. While I'm not looking for a PHP expert, I'm looking for someone with good web skills and has at least some PHP experience (as well as the desire to learn more!). I'd appreciate any recommendations/advice. Thanks in advance, brian -- PHP General 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]