[PHP] Adding up query results
I hope someone can help with this frustratingly simple (I assume!) question I have. I run this mysql query: select sum(quantity)*price,price from sale where dvd_id=1 group by price; I get this result: sum(quantity)*price price 450.00 15.00 29.99 29.99 I want to display the sum of the values in the first column (450.00+29.99), but I cannot figure out how to do this! Can someone clue me in? Thanks a million, Nathan -- Nathan Mealey Website Manager Administrative Director Cycle-Smart, Inc. P.O. Box 1482 Northampton, MA 01061-1482 [EMAIL PROTECTED] (413) 210-7984 (512) 681-7043 Fax -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Mysql Connect Help
A seemingly simple problem, still confounding me. The following line of code: mysql_connect('database','user','password'); [with values of course] Generates the following error: Fatal error: Call to undefined function: mysql_connect() in /var/www/html/phptest.php on line 3 My PHP info page says that PHP (4.3) was compiled with MySQL, and extensions_dir is correct (although the extensions_dir itself is empty, but I don't know if this matters). So PHP itself is working. I installed MySQL 4.1 from RPM (client and server RPMs) on Redhat 8.0 this morning. Thanks for any help, Nathan -- Nathan Mealey Director of Operations Cycle-Smart, Inc. P.O. Box 1482 Northampton, MA 01061-1482 [EMAIL PROTECTED] (413) 587-3133 (413) 210-7984 Mobile (512) 681-7043 Fax -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] File Upload Problem
This file upload problem has me very confused. The code is: $upload_dir = '/articles_store/'; $uploadfile = $upload_dir . basename($_FILES['userfile']['name']); if (move_uploaded_file($_FILES['userfile']['tmp_name'],$uploadfile)) { } else { die (Cannot upload file); } (this code is practically verbatim the example from php.net) The directory '/articles_store' has permissions 777. And the user is and group are 'www' (the Apache user). But I keep getting the following error: [Wed Oct 20 19:01:34 2004] [error] PHP Warning: move_uploaded_file(/articles_store/case_for_base.pdf) [a href='function.move-uploaded-file'function.move-uploaded-file/a]: failed to open stream: No such file or directory in /usr/local/www/data-dist/cycle-smart/www/Articles/admin/ articleinsert.php on line 50 [Wed Oct 20 19:01:34 2004] [error] PHP Warning: move_uploaded_file() [a href='function.move-uploaded-file'function.move-uploaded-file/a]: Unable to move '/var/tmp/phpibRXhc' to '/articles_store/case_for_base.pdf' in /usr/local/www/data-dist/cycle-smart/www/Articles/admin/ articleinsert.php on line 50 Any help is very, very much appreciated. NM -- Nathan Mealey Director of Operations Cycle-Smart, Inc. P.O. Box 1482 Northampton, MA 01061-1482 [EMAIL PROTECTED] (413) 587-3133 (413) 210-7984 Mobile (512) 681-7043 Fax -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Array?
I cannot seem to access elements inside of the array $things in the code below. All of the errors say Undefined offset: 7 in /Library/WebServer/Documents/lis/check.php on line 26 I don't see why... The code is: $q = select * from users where email='.$email.' and password='.$pass.'; $results = mysql_query($q); if ($results) { while ($list=mysql_fetch_assoc($results)) { $things[]=$list; } } //$things[7] is a MySQL timestamp column named last_login $date = strtotime($things[7]); Thanks in advance, Nathan -- Nathan Mealey Director of Operations Cycle-Smart, Inc. P.O. Box 1482 Northampton, MA 01061-1482 [EMAIL PROTECTED] (413) 587-3133 (413) 210-7984 Mobile (512) 681-7043 Fax -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] FPDF Help
Anyone who is familiar with using FPDF to generate PDFs, I'd really appreciate some suggestions here: I am using the following code, virtually identical to that used in the FPDF tutorial examples. But I keep getting a parse error for the first line containing the variable $this. In the tutorial they do not declare this variable prior to using it the same way as in the example below, but when I try and do this, it's a no go. Any ideas? Suggestions? the code -- define('FPDF_FONTPATH','../../../font/'); require('../fpdf.php'); class PDF extends FPDF { function Header() { //Arial 12 $this-SetFont('Arial','',12); //Move to the right $this-Cell(80); //Title $this-Cell(30,10,'Title',1,0,'C'); //Line break $this-Ln(20); } function Footer() { //Position at 1.5 cm from bottom $this-SetY(-15); //Arial italic 8 $this-SetFont('Arial','I',8); //Page number $this-Cell(0,10,'Page '.$this-PageNo().'/{nb}',0,0,'C'); } $pdf=new PDF(); $pdf-AliasNbPages(); $pdf-AddPage(); $pdf-SetFont('Times','',12); for($i=1;$i=40;$i++) { $pdf-Cell(0,10,'Printing line number '.$i,0,1); } $pdf-Output(); } Nathan Mealey Director of Operations Cycle-Smart, Inc. P.O. Box 1482 Northampton, MA 01061-1482 [EMAIL PROTECTED] (413) 587-3133 (413) 210-7984 Mobile (512) 681-7043 Fax -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Using PDFLib
Hello, I am trying to generate PDFs using PDFLib for the first time, and have two questions, one of which is very confusing to me. 1) how can I tell the script generating the pdf to store it in a particular place on the computer where the pdf generation is happening? 2) this is the really confusing one. The text being put into the body of the pdf is an article about 6300 characters. The tutorials I have found all follow the same format, and end up printing all of this text in one line (or row), so that the pdf ends up being just one line across. So the question is, how do I get the text to be placed normally on the page, so as to be a readable document? I should add that I am using a block of text sent from an HTML form. Here is the PHP script: ?php $author=$_POST['author']; $text=$_POST['text']; $pdf = PDF_new(); PDF_open_file($pdf); PDF_set_info($pdf, author, $author); PDF_begin_page($pdf,612,792); $font = PDF_findfont($pdf, Helvetica, winansi,0); PDF_setfont($pdf,$font,12); PDF_show_xy($pdf, $text, 5,225); PDF_end_page($pdf); PDF_close($pdf); $buffer = PDF_get_buffer($pdf); header(Content-type: application/pdf); header(Content-Length: .strlen($buffer)); header(Content-Disposition: inline; filename=sample.pdf); echo $buffer ? Thanks! -- Nathan Mealey Director of Operations Cycle-Smart, Inc. P.O. Box 1482 Northampton, MA 01061-1482 [EMAIL PROTECTED] (413) 587-3133 (413) 210-7984 Mobile (512) 681-7043 Fax -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php