[PHP] Re: Search Engine
Sascha, From just looking at it, the code looks fine. It could be that someone entered a special character in the array like a '%' or something else illegal. Check the code I wrote. I entered a debug statement to see what was generated. This should give you some clue what is wrong with it. You can then copy the code from the browser to enter it into a mySQL DB editor. HTH... Have a great day.. Dan --- $Query = "SELECT * FROM referenzen_tbl"; $wa = ' WHERE '; if (strlen($arrSearch) > 0) { // Überhaupt einschränken? for($i = 0; $i < count($arrSearch); $i++) { $Query .= " $wa (referenzen_tbl.kat LIKE '%$arrSearch[$i]%' OR referenzen_tbl.headLIKE '%$arrSearch[$i]%' OR referenzen_tbl.textLIKE '%$arrSearch[$i]%' OR referenzen_tbl.technik LIKE '%$arrSearch[$i]%' OR referenzen_tbl.yearLIKE '%$arrSearch[$i]%')"; $wa = " \nAND "; } $Result = mysql_query($Query, $connect); echo "$Result $Query "; DEBUG CODE } Sascha Braun wrote: > Whats wrong with this code? > > $arrSearch = explode(" ", $_REQUEST['string']); > $RSQuery = "SELECT * FROM referenzen_tbl"; > if (strlen($arrSearch) > 0) { // Überhaupt einschränken? > $Query .= " WHERE ("; > $Query .= " referenzen_tbl.kat LIKE '%" . $arrSearch[0] . "%'"; > $Query .= " OR referenzen_tbl.head LIKE '%" . $arrSearch[0] . "%'"; > $Query .= " OR referenzen_tbl.text LIKE '%" . $arrSearch[0] . "%'"; > $Query .= " OR referenzen_tbl.technik LIKE '%" . $arrSearch[0] . "%'"; > $Query .= " OR referenzen_tbl.year LIKE '%" . $arrSearch[0] . "%')"; > // mehrere Suchwörter sind UND-Verknüpft > for($i = 1; $i < count($arrSearch); $i++) { > $Query .= " AND ("; > $Query .= " referenzen_tbl.kat LIKE '%" . $arrSearch[$i] . "%'"; > $Query .= " OR referenzen_tbl.head LIKE '%" . $arrSearch[$i] . "%'"; > $Query .= " OR referenzen_tbl.text LIKE '%" . $arrSearch[$i] . "%'"; > $Query .= " OR referenzen_tbl.technik LIKE '%" . $arrSearch[$i] . "%'"; > $Query .= " OR referenzen_tbl.year LIKE '%" . $arrSearch[$i] . "%')"; > } > } > $Result = mysql_query($Query, $connect); > if (mysql_fetch_row($Result)<0) { > echo "Es wurden keinen Beiträge zu ".$_REQUEST['string'].""; > } else { > echo "Die Suche war erfolgreich!"; > while ($arrResult = mysql_fetch_array($Result, MYSQL_ASSOC)) { >echo ''; >echo $arrResult['referenzen_tbl.kat'].""; >echo $arrResult['referenzen_tbl.head'].""; >echo $arrResult['referenzen_tbl.text'].""; >echo $arrResult['referenzen_tbl.technik'].""; >echo $arrResult['referenzen_tbl.year'].""; >echo ''; > } > } > ?> > > I know that there is a result comming out of the string i entered, but these failure >messages are comming up when i load the page: > > Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource >in C:\Webverzeichnis\docs\schuraWeb\includes\result.inc.php on line 40 > > Die Suche war erfolgreich! > > Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource >in C:\Webverzeichnis\docs\schuraWeb\includes\result.inc.php on line 44 > > This is my global inc from where the $connect comes: > > $host = 'localhost'; // SQL Server zu dem eine Verbindung aufgebaut werden soll. > $user = 'root'; // Name des SQL Benutzers > $pass = 'none'; // Kennwort des SQL Benutzers > $dbase = 'weitsicht'; // Datenbank > > // Verbindung zum SQL Server wird hergestellt > $connect = mysql_connect($host, $user, $pass) or die("Fehler beim Öffnen der DB auf >$host User: $user Kennwort: $pass"); > // Datenbank wird ausgewählt > $Query = "USE ".$dbase; > $selectDB = mysql_query($Query, $connect) or die("Konnte Datenbank aus folgenden >Gründen nicht auswählen: ". mysql_error()); > ?> > > Please Help! > > Schura > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] counting number of records in a MySQL table; how do I get
Or another way if you don't want a result when it's zero. $rslt = mysql_query("SELECT count(*) as cnt FROM tbl having cnt > 0"); HTH.. Have a great day.. Dan Rasmus Lerdorf wrote: > $ret = mysql_query("SELECT count(*) as foo FROM AuthNum"); > $result = mysql_fetch_array($ret); > echo $result['foo']; > > One of many ways... > > -Rasmus > > > > On Wed, 2 Oct 2002, DonPro wrote: > > >>Hi, >> >>I need to do either an insert or update into a MySQL table. Insert if there >>are 0 records or update if one record exist: >> >>This is my code snippet: >> >>if (mysql_query("SELECT COUNT(*) FROM AuthNum") == 0) { >> mysql_query("INSERT into AuthNum (FirstNum, LastNum, NextNum) VALUES >>(1,2,3)",$dblink); >>} else { >> mysql_query("Update AuthNum Set FirstNum = 1, LastNum = 2, NextNum = >>3",$dbLink); >>} >> >>My problem is, a record never gets inserted because the SELECT COUNT query >>is returning a resource ID of 2. How can I get the actual number of records >>in the table? >> >>Thanks, >>Don >> >> >> >>-- >>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
[PHP] Re: Using checkboxes
This always works for me.. == /* *\ ** chk[] is the list of check boxes sent to browser. ** If chk[$i] equals $i as as you loop ** through the array.. then it was checked. ** But first we need to set all the boxes that ** ain't checked to -1 or something other than $i ** $num_chk = number of $chk[] boxes sent \* */ for ($i=$num_chk; $i>-1 ; $i--) { if (!isset($chk[$i])) $chk[$i] = -1; else{ $ii = $chk[$i]; $chk[$i] = -1; $chk[$ii] = $ii; } } /* Now you can loop through the chk[] ** list and find out what ones were set */ = HTH. Good luck ... Dan Dirk Beijaard wrote: > Hey all, > > I have a form, generated in php, with a lot of checkboxes on it. They > are initialized from the db. All checkboxes are in a 2d array and they > come through to my processing script fine. The only problem is that > the ones that are unchecked do not come through. I know that the post > command only sends the checked boxes. What I would like to know is which > ones were changed, ie checked or unchecked by the user. Right now I do > it by putting a string with the old values in a hidden textbox and > comparing those to what I get back in the array. I have been thinking > about writing some client side script to produce the differences. > > Does anyone know if there is a better way to do this? > > Thanks, > Dirk. > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Code Structure/Errors
Can simply set $i before the while. I assume the $last_name is coming from the DB. Not exactly sure what you want, but hope this helps. good luck... Dan. -- $i = 0; while ($row = mysql_fetch_array($result)) { extract($row); if (($i % 5) == 0) print "\n"; $i++; @$last_name .= ''; if($last_name <> '') else ... if (($i % 5) == 0) print "\n"; } Jason Soza wrote: > I'm just curious if there's a way to restructure my code so as to avoid > getting "Undefined Variable" errors. I keep getting them and I know they're > nothing to worry about for the most part, I'd like to get rid of them > without turning off error reporting if possible. In the following code, I > get an undefined variable error for $i and for $last_name, is there anything > I can do to actually define them? $last_name is a variable produced by my > MySQL query, $i is just a counter: > > while ($row = mysql_fetch_array($result)) { > extract($row); > $i++; > if($i=="1") { > print "\n"; > } > > if($last_name) { > > } else { > > } > ... > if ($i=="5") { >print "\n"; >$i=0; >} > } > > Thanks! > > Jason Soza > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: sorting and searching an Array
Unless I'm missing something, why put it in an array. Why not just just select the data from the data base that matches your search_name and list it. Something like: SELECT e_mail, name FROM e_mail_file WHERE name = '$search_name' ORDER by name HTH. Dan. [EMAIL PROTECTED] wrote: > After I read this file into an array (small sample of file below) I need to sorted >it by the name at > the end of each line and then echo out only the ones that the name > equals the name in a search variable. > > Also could somebody recommend a PHP book that covers a lot of info on > working with text files. It seams to be very little info in any of the > boos I have now. It is sort of skipped over a lot > > [EMAIL PROTECTED] mrgouldian > [EMAIL PROTECTED] myname > [EMAIL PROTECTED] mrgouldian > [EMAIL PROTECTED] mrgouldian > [EMAIL PROTECTED] myname > [EMAIL PROTECTED] mrgouldian > [EMAIL PROTECTED] myname > [EMAIL PROTECTED] myname > [EMAIL PROTECTED] mrgouldian > [EMAIL PROTECTED] myname > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: To print in PHP
Correct PDF does work and is well supported on Macs and Linux, and just about everywhere I looked. But, for out system, it don't work 'JUST FINE'. After a lot of test we decided it was just too slow for our use. Every system is different, and if you can live with PDF and it works for you, use it. Notice the period after RTF. The part I'm talking about is the printer functions. http://www.php.net/manual/en/ref.printer.php PHP: Printer functions - Manual Richard Lynch wrote: >>decided I didn't want to use the browser to print. Looked at PDF, RTF. I >>liked the printer functions, but they only worked on M$. After looking >> > > Excuse me. > > PDF works JUST FINE not only on Macs, but is also well-supported under > Linux. > > http://php.net/pdflib > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Got a problem I cant figure out
Yep! I agree it's probably an open bracket. Here is a little program I use to beautyify my programs and find open brackets. HTH dan.. --- beauty.php --- /* - *\ ** Beauty: cleans up source PHP code and ** indent nesting \* - */ $file_name = "???.php"; // gimme your program name $data = file("c:/???/$file_name"); // gimme your in area $fp = fopen("c:/???/$file_name",'w'); // gimme your out area $sho_nst = "N"; // [Y]es to show levels $cmt = 0; // start comment count $nst = 0; // start nesting count $i = 0; // count for input array while (isset($data[$i])) { // while going through data if (strstr($data[$i],"/*")) $cmt++; // tab count if comments start if (strstr($data[$i],"*/")) $cmt--; // tab count if comments end if (($cmt < 1) && (strstr($data[$i],"{"))) $nst++; // count nesting $x = '';// init the output file line for ($j = 0; $j < $nst; $j++) { // according to nestings $x .= "\t"; //put tabs on } // end for $y = ltrim($data[$i]); if (empty($y)) $y = "\n"; $out = $x . $y; // now strip leading junk and put tabs on if (($cmt < 1) && (strstr($data[$i],"}"))) $nst--;// un count nesting if ($sho_nst == 'Y') $out = $i . "|" . $cmt . "|" . $nst . "|" . "$out"; fwrite ($fp, $out); // put it to the output file echo "$i | $cmt | $nst | $out ";// lemme see it in the browser $i++; // bump count for input array } // end while fclose($fp); // close the output file - end beauty Ben Turner wrote: > Parse error: parse error in /var/www/docs/tacklebox/404handler.php on line 47 > > I am receiving this error on my page but the problem is that line 47 is the ?> and >last line of the page. Is their something Im missing here?? > > Thanks, > Ben > > -- 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] Re: Got a problem I cant figure out
Could be that you have a open curly bracket somewhere. Here is a quick program I use to beautify and clean up my PHP code and point out any open brackets; HTH .. Dan ";// lemme see it in the browser $i++; // bump count for input array } // end while fclose($fp); // close the output file ?> Ben Turner wrote: > Parse error: parse error in /var/www/docs/tacklebox/404handler.php on line 47 > > I am receiving this error on my page but the problem is that line 47 is the ?> and >last line of the page. Is their something Im missing here?? > > Thanks, > Ben > > -- 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] Re: Got a problem I cant figure out
Could be that you have a open curly bracket somewhere. Here is a quick program I use to beautify and clean up my PHP code and to point out any open brackets; HTH .. Dan ";// lemme see it in the browser $i++; // bump count for input array } // end while fclose($fp); // close the output file ?> Ben Turner wrote: > Parse error: parse error in /var/www/docs/tacklebox/404handler.php on line 47 > > I am receiving this error on my page but the problem is that line 47 is the ?> and >last line of the page. Is their something Im missing here?? > > Thanks, > Ben > > -- 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] newbe printing routine??
Being completely new to PHP I went to this site for help on how to print reports. Thanks for all the ideas. I guess being a newbe, I was wondering if this is kind of the standard way most of you do all your reporting. Based on all the help I got, I did the following: 1. Wrote a report writer with multiple header breaks, multiple total breaks. Selection of data in the detail , headers, and totals. Selection of 5 sort orders, and join selections. They select who gets copies of the report (up to 100 in the selection). 3. They give the report a name, and can execute it anytime. Or it can be fired with date triggers defined in item 1. Like every Friday at 10AM. etc. 4. I wrote a report file system. When a report fires it shows up in your IN-BASKET. When you delete it it goes to the Waste-Basket for 10 days. The file has the name of the report, number of lines, number of pages, who owns the report, when run and any comments set up in the report definition in item 1. 5. All reports run on the server, so they are fast. The report is stored in mySQL only once and everyone who gets the report has their IN-BASKET point to it. 6. Anyone can file the report or copy the report to multiple files or mail it to anyone. For example file a report from IN-BASKET to the Daily-Log file etc. The mail basically creates another entry in the recipient's IN-BASKET. 7. If you view a report it brings up as many pages at a time as you want (default is 5). you can move from page to page with arrows, or bring up the another section, or the whole report. You can print the report. I know this is a fairly simple reporting system. Just wondering if I'm on the right track. Thanks again for all the help.. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Random number Question
Try something like this and see if it works??? The computer has picked $another number between 1 and 10. Guess the number and you win! Enter your guess: "; if (isset($guess)) { srand((double)microtime()*100); $number = rand(1,10); echo "The number is: $number"; if ($guess == $number) { echo 'You have won!'; }else{ echo "Sorry that wasn't the answer"; } } ?> = Jennifer Downey wrote: > Hi all, > > I having a hard time understanding why this won't work. I have a form which > is suppose to pass the guess to the script. Here it is: > > the form is guess.php: > > > The computer has picked a number between 1 and 10. Guess the number and you > win! > > > Enter your guess: > > > > > > The script is number.php: > > echo"The number is:"; > > srand((double)microtime()*100); > $number = rand(1,10); > > echo $number; > > if($guess = = $number) { > echo"You have won!"; > }else{ > print("Sorry that wasn't the answer"); > > } > ?> > > Any help would be appreciated. > > Thanks in advance > Jennifer Downey > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Random number Question
OOPS! You are right on.. I noticed my error after I sent it. The name='guess' was on the input.?? Daaa! it's Monday .. OK!! This should work: === The computer has picked $another number between 1 and 10. Guess the number and you win! Enter your guess: "; if (isset($guess)) { srand((double)microtime()*100); $number = floor(rand(1,10)); echo "The number is: $number"; if ($guess == $number) echo 'You have won!'; else echo "Sorry that wasn't the answer"; } ?> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Using PHP for NULLs
I do believe it is a MySql question!! What's wrong with the old standard way as: $result = mysql_query(" SELECT *, if (last_name is NULL,'zzz end',last_name) as last_name_sort FROM new_miatapix ORDER BY last_name_sort LIMIT $page, 20"); Good Luck.. HTH.. Dan.. === Jason Soza wrote: > I thought this was a MySQL question, or something that could be solved using > a creative SQL string, but after looking through the MySQL manual, I don't > think I can handle this with the database alone. According to the manual, > MySQL always sorts NULL values first - I want them last. I have a last_name > field that sometimes contains people's last names, sometimes they choose not > to enter their last names. I want those who don't enter a last name to end > up last on the list. > > Right now I have: $result = mysql_query("SELECT * FROM new_miatapix ORDER BY > last_name LIMIT $page, 20"); > > Am I going to have to do two queries here, then store them somehow using an > array? It seems like I'm going to have to do one query to get all NULL > values for last_name, then do another query to get all NOT NULL values for > last_name, but how would I handle that after I get it to PHP? > > Or can I use some PHP function to sort $result to place all NULL values > last? I'd check the PHP manual, but it seems to not be responding well at > the moment. > > Thanks, > > Jason Soza > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Printing Reports
As a Newbe to PHP, I need to print reports. I'd like to stay away from PDF but will use it if necessary. In general, what seems to be the best way to print reports?? It would be nice when they ask for a report it would brint in the report window that allows them to select the printer, number of copies, print quality etc. Thanks for your help... Dan. -- 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] Re: Printing Reports
There are so many reports. The system I have is a manufacturing system, and currently contains some 400 programs. Some examples of reports are: Bill of Lading with bar codes Production reports Management and analysis Labels for lab analysis with bar codes Planning reports Quality assurance Preventative maintenance work orders Warehouse Planning Billing And others Some of these are reports long, but I guess most are less than 20 pages. Most of the sites that use the system are small and usually have from 200 to 500 terminals and have systems that manage multiple printers. So they would like to direct the printed output. Like just about everyone, I'd like them to use more interactive stuff on the system. But users want their reports... HTH. Thanks again for the help. -- 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] Printing Reports
Thanks Dean; I like your idea a lot. They happen to be internet. If you have example code on your solution it would save me some time. Thanks again... I'm gonna try it. Dan... > > -- 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] Re: Printing Reports
Well I guess it's like most applications. Every print job has it's own special requirements. For example the lab analysis report. When the manufacturing process starts on a liquid process, they request certain samples. Samples consist of lab analysis they should take and how often they should take a sample. Most samples consist of about 10 to 12 analysis and are usually taken every 20 minutes to 1/2 hr. A process may last a couple days. So if they take a sample every 1/2 hour for 2 days that's 96 samples at 10 analysis each or around 1000 lab analysis. So the system will print 96 labels with 10 bar coded analysis on it. The labels are sent to the operations area. As they take a sample they affix a label to the bottle and send it to the lab. The lab does the analysis, enters the result and wands the proper analysis bar code on the bottle. The bottle then goes to the next lab analysis area. Most lab work is automated and a dry lab such as gas chromatography and automatic absorption units. The bottle enters a conveyor, the analysis is done and the bar code scanned as it passes the scan area. The data is then sent automatically with the bar code information to the system. Since the bar code scanner can't know exactly what bar code to read a bar code to the bar code is also on the sample. This report is not as complicated as most, but it may help give you some idea of what is needed. Some reports need fairly exact font and line control and others are just text files. Thanks again for all the help.. Dan -- 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] Printing Reports
From what I've read the new PHP printer functions look like they do exactly what I want. Unfortunately they only run on windows. Wonder if this will ever be available to all OS. For now I've got a lot of good ideas from everyone, and I'm on my way to 'having fun'. Thanks loads to everyone... Dan > > The print function sets focus on the report and then executes this.print(). > The print dialogue box will automatically pop up and the user can select > their own printer along with number of copies, etc. If you use HTML you can > even set page breaks (in IE5 anyway). > > Have fun, > > > Dean > > > > > > -Original Message- > From: Dan Koken [mailto:[EMAIL PROTECTED]] > Sent: Tuesday, November 27, 2001 5:00 AM > To: [EMAIL PROTECTED] > Subject: [PHP] Printing Reports > > > As a Newbe to PHP, I need to print reports. I'd like to stay away from > PDF but will use it if necessary. > > In general, what seems to be the best way to print reports?? > > It would be nice when they ask for a report it would brint in the report > window that allows them to select the printer, number of copies, print > quality etc. > > Thanks for your help... > Dan. > > > -- 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]