ober
Staff Alumni-
Posts
5,327 -
Joined
-
Last visited
Everything posted by ober
-
I haven't dealt with extending, so you might just have to ignore my answer (and maybe explain your class a little better)... but why wouldn't you just create a new instance of the class for a new account?
-
Exactly. That's because fopen() returns a file handle number. You need to use fread() to actually read the contents of the file. You could also use fgets() in a loop.
-
[code]<?php $total = mysql_num_rows($query); ?>[/code] As a side note, your naming is confusing. Your "query" is actually a "result". Your "sql" is actually the "query".
-
No... you cannot run an "or die()" on a regular function. You just have to know what the output is supposed to be and if it isn't in that "range", you have to deal with it accordingly. Like I said, if you're processing before any output is created, you can redirect to another page and show some sort of error. If the processing or the running of the function is AFTER some output has been created, you'll just have to create your error message right there.
-
What are the PHP versions on both your local machine and the host?
-
[code]<?php for($i = 0; $i < count($myarray); $i++) { if(substr($myarray[i], -2) == 'ab') // do something } [/code] And yes, fopen() opens both remote and local files.
-
As long as the processing is all done before any output, you would redirect the user with the header() function.
-
How is your list of words setup? Is it an array? Is it all in a string? I'd use the substr() function to look at the words and determine if it matches your pattern. I would use fopen() for that, but I'm going to guess that you're not allowed to use that function either... but maybe.
-
That depends on how you use the form and what you want to do with it. If you just want to come back to the page and have the user selected again, you can set it from the $_POST/$_GET array, or you could set a cookie and pull it from that. Once you have the value in a cookie or in the POST/GET super global array, all you have to do is create an option like this: <option value="harry" selected="selected">harry</option> Then just create your other options normally.
-
I would imagine you could use ODBC or some sort of COM object to talk to it. I've never tried it, however. [a href=\"http://us2.php.net/manual/en/function.dbase-open.php\" target=\"_blank\"]http://us2.php.net/manual/en/function.dbase-open.php[/a] You might want to read the comment at the bottom of that page.
-
Error suppression. If the function errors out, it won't display anything to the user. The best way to use that is to set the function output equal to something and if it's not what you expect, you can append the error to a log file or email yourself and the user will never know the difference. You can also use it to display a "nice" error message to the user instead of the script spitting out what line the error came from and what the name of your file was, etc, etc.
-
You're going to have to use the COM object: [a href=\"http://us2.php.net/manual/en/class.com.php\" target=\"_blank\"]http://us2.php.net/manual/en/class.com.php[/a] And keep in mind that any Excel file you edit MUST be on the server, not on the client machine! Code from that page: [code]<?PHP $filename = "c:/spreadhseet/test.xls"; $sheet1 = 1; $sheet2 = "sheet2"; $excel_app = new COM("Excel.application") or Die ("Did not connect"); print "Application name: {$excel_app->Application->value}\n"; print "Loaded version: {$excel_app->Application->version}\n"; $Workbook = $excel_app->Workbooks->Open("$filename") or Die("Did not open $filename $Workbook"); $Worksheet = $Workbook->Worksheets($sheet1); $Worksheet->activate; $excel_cell = $Worksheet->Range("C4"); $excel_cell->activate; $excel_result = $excel_cell->value; print "$excel_result\n"; $Worksheet = $Workbook->Worksheets($sheet2); $Worksheet->activate; $excel_cell = $Worksheet->Range("C4"); $excel_cell->activate; $excel_result = $excel_cell->value; print "$excel_result\n"; #To close all instances of excel: $Workbook->Close; unset($Worksheet); unset($Workbook); $excel_app->Workbooks->Close(); $excel_app->Quit(); unset($excel_app); ?>[/code] And here's another function that I have, but have never used: [code]<?php /***************************/ function WriteExcel($strPath,$astrSheetName,$astrSQL){ /* This function takes a file save path, and array of sheet names and a corresponding array */ /* of SQL queries for each sheet and created a multi-worksheet excel spreadsheet*/ $C_NAME=__CLASS__."::".__FUNCTION__; $dbs=new clsDB; $exapp = new COM("Excel.Application") or Die ("Did not connect"); $intSheetCount=count($astrSheetName); $wkb=$exapp->Workbooks->Add(); $exapp->Application->Visible = 1; for ($int=0;$int<$intSheetCount;$int++){ $sheet=$wkb->Worksheets($int+1); $sheet->activate; $sheet->Name=$astrSheetName[$int]; $intRow=1; $qrySQL=$dbs->GetQry($astrSQL[$int],$C_NAME,__LINE__); $rstSQL=$qrySQL->fetchRow(DB_FETCHMODE_ASSOC); $astrKeyNames=array_keys($rstSQL); $intCols=count($astrKeyNames); $qrySQL=$dbs->GetQry($astrSQL[$int],$C_NAME,__LINE__); while($rstSQL=$qrySQL->fetchRow(DB_FETCHMODE_ASSOC)){ $strOut="";//initialize the output string for ($int2=0;$int2<$intCols;$int2++){//we start at 1 because don't want to output the table's index if($intRow==1){ $strOut=$astrKeyNames[$int2]; }else{ $strOut=$rstSQL[$astrKeyNames[$int2]]; } $sheet->activate; $cell=$sheet->Cells($intRow,($int2+1));//->activate; $cell->Activate; $cell->value = $strOut; }//end of colcount for loop $intRow++; }//end while loop }//end sheetcount for loop if (file_exists($strPath)) {unlink($strPath);} $wkb->SaveAs($strPath); $wkb->Close(false); unset($sheet); $exapp->Workbooks->Close(false); unset($wkb); $exapp->Quit; unset($exapp); unset($dbs); }//function WriteExcel ?>[/code]
-
Right, but you're missing thorpe's point. A session is specific to each user, not ALL users on your site. You will have to use a flat file or a database to see if any user is logged in. Think of sessions as bank accounts and your website as a bank. Everyone putting money into your bank has their own account. If you wanted to see what the balance was for ALL the users, you'd go to the bank's register, not someone's specific account.
-
I could repeat what Mark said, but he's pretty spot-on with everything. There's too much white space, you don't really have containment on the elements, and using that bright of a green on a white background is a bit shocking. I thought I was momentarily blinded when I first opened the site. Tone it down with some darker colors and try to give your areas a little better definition. It wouldn't hurt to narrow the focus as well and split the different areas up a little better. It looks like a big pile of mush at the moment.
-
I know you're going to hate me even saying this, but this is why a lot of places like that require that you copy and paste the information into their own forms and then they can store it and allow you to edit it that way. There aren't many good editors that will work nicely with all the file formats that you're going to come in contact with. However in most cases, if I wanted to edit a document that I had on your server, I'd just pull out my old copy, edit it, and upload it again, replacing the current one.
-
I'd do some work on the nav... drop the images and use more CSS. Or at least pad the top a little so the words are centered vertically. I also would move the left picture down a line or two. It looks off a little when you only have one line above it. And lastly, the whole site is kinda bland as far as color. You need something that stands out.
-
I'm definately more into video games, but my wife and I play bored (haha) games from time to time. We're not so much into the heavy strategy games, but we play Scrabble, Chess, and Cranium. We also got into a DVD movie game for a while. I personally like Chess, but she's not a huge fan.
-
You cannot combine queries like that. You have to run the SELECT query, store the values in variables and then create a second query for the insert.
-
Why would you put the words in the verse in a seperate table? That doesn't make any sense. The power of SQL is that you can use things like "LIKE" to look in field contents for specific words.
-
I don't know what you're trying to do. You can't include the contents of a text file like that in the middle of a string. It doesn't work like that.
-
That's a very open-ended question. It's all possibly and shouldn't be too bad for someone with half a year's experience in the language. If you have a specific question about the project, I suggest you point it out.
-
I changed the title... you want to split the results, not the DBs. And there are a hundred examples of how to do this throughout the forums and most likely there is a tutorial on the main portion of this site. I suggest you do a search.
-
Run a query to get them.....? You can run more than one query on the page. I'm confused by the question.
-
Sorry, must have missed that part in the origional post. I'd have to say it's probably a bug as well. For the longterm if they can't get a fix, I'd suggest modifying file names as they're put on the server.