php-general Digest 25 Sep 2004 11:12:35 -0000 Issue 3016
Topics (messages 197802 through 197815):
php upload script problems
197802 by: AMC
197813 by: Marek Kilimajer
197815 by: Pablo M. Rivas
Re: A few questions about system requirements
197803 by: Steven
Re: opening table 2 inside table1
197804 by: John Taylor-Johnston
echo to rtf format
197805 by: John Taylor-Johnston
197807 by: Manuel Lemos
197808 by: Manuel Lemos
simple templateing
197806 by: Mag
Parse Error... can not find cause of error....
197809 by: GH
197814 by: Marek Kilimajer
supplied argument is not a valid
197810 by: John Taylor-Johnston
197811 by: Ramil Sagum
197812 by: John Taylor-Johnston
Administrivia:
To subscribe to the digest, e-mail:
[EMAIL PROTECTED]
To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]
To post to the list, e-mail:
[EMAIL PROTECTED]
----------------------------------------------------------------------
--- Begin Message ---
Hi,
I have the following php page. The page just opens up blank and I assume I
made an error I cannot see. I'm new to php and any help would be greatly
appreciated:
<?php
$extlimit = "yes"; //Do you want to limit the extensions of files uploaded
$limitedext = array(".pdf"); //Extensions you want files uploaded limited
to.
$sizelimit = "no"; //Do you want a size limit, yes or no?
$sizebytes = "200000"; //size limit in bytes
$dl = "http://www.corrige2.bluehill.com/pdfs"; //url where files are
uploaded
$absolute_path = "http://www.corrige2.bluehill.com/pdfs"; //Absolute path to
where files are uploaded
$websiteurl = "http://www.corrige2.bluehill.com"; //Url to you website
$websitename = "Corrigent";
switch($action) {
default:
echo "<html><head><title>Upload Or Download</title></head><body><a
href=$PHP_SELF?action=upload>Upload File</a> <a
href=$PHP_SELF?action=download>Download File</a>";
echo "<a href=$websiteurl>Return to $websitename</a><br><br>Powered by PHP
Uploader Downloader</a></body></html>";
break;
case "download":
echo "<html><head><title>File Download</title></head><body><a
href=$PHP_SELF?action=upload>Upload File</a> <a href=$websiteurl>Return to
$websitename</a>";
$list = "<table width=700 border=1 bordercolor=#000000
style=\"border-collapse: collapse\">";
$list .= "<tr><td width=700><center><b>Click To
Download</b></center></td></tr>";
$dir = opendir($absolute_path);
while($file = readdir($dir)) {
if (($file != "..") and ($file != ".")) {
$list .= "<tr><td width=700><a
href='$dl/$file'>$file</a></center></td></tr>";
}
}
$list .= "</table>";
echo $list;
echo"<br><br>Powered by PHP Uploader Downloader</a></body></html>";
break;
case "upload":
echo"<html><head><title>File Upload</title></head><body><form method=POST
action=$PHP_SELF?action=doupload enctype=multipart/form-data
ID="Form1"><p>File to upload:<br><input type=file name=file size=30
ID="File1">";
echo"<p><button name=submit type=submit
ID="Button1">Upload</button></form><br><br>Powered by PHP Uploader
Downloader</a></body></html>";
break;
//File Upload
case "doupload":
$dir = "dir";
if ($file != "") {
if (file_exists("$absolute_path/$file_name")) {
die("File already exists");
}
$ext = strrchr($file_name,'.');
if (($extlimit == "yes") && (!in_array($ext,$limitedext))) {
die("The file you are uploading doesn't have the correct extension.");
}
@copy($file, "$absolute_path/$file_name") or die("The file you are trying to
upload couldn't be copied to the server");
} else {
die("Must select file to upload");
}
echo "<html><head><title>File Uploaded</title></head><body>";
echo $file_name." was uploaded";
echo "<br><a href=$PHP_SELF?action=upload>Upload Another File</a><a
href=$PHP_SELF?action=download> Download File</a><a href=$websiteurl> Return
to $websitename</a><br><br>Powered by <a href=http://www.zachwhite.com/>PHP
Uploader Downloader</a></body></html>";
break;
}
?>
--- End Message ---
--- Begin Message ---
AMC wrote:
Hi,
I have the following php page. The page just opens up blank and I assume I
made an error I cannot see. I'm new to php and any help would be greatly
appreciated:
What is your register_globals and display_errors setting?
--- End Message ---
--- Begin Message ---
Hello:
When you want to know where is your error, set: error_reporting(E_ALL);
http://www.php.net/manual/en/function.error-reporting.php
the error is here:
case "upload":
echo"<html><head><title>File Upload</title></head><body><form method=POST
action=$PHP_SELF?action=doupload enctype=multipart/form-data
ID="Form1"><p>File to upload:<br><input type=file name=file size=30
ID="File1">";
you might change :
ID="Form1"
and ID="File1"
for :
ID=\"Form1\"
and ID=\"File1\"
echo"<html><head><title>File Upload</title></head><body><form method=POST
action=$PHP_SELF?action=doupload enctype=multipart/form-data
ID=\"Form1\"><p>File to upload:<br><input type=file name=file size=30
ID=\"File1\">";
Good Luck!
On Fri, 24 Sep 2004 16:01:48 -0700, AMC <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I have the following php page. The page just opens up blank and I assume I
> made an error I cannot see. I'm new to php and any help would be greatly
> appreciated:
>
> <?php
>
> $extlimit = "yes"; //Do you want to limit the extensions of files uploaded
>
> $limitedext = array(".pdf"); //Extensions you want files uploaded limited
> to.
>
> $sizelimit = "no"; //Do you want a size limit, yes or no?
>
> $sizebytes = "200000"; //size limit in bytes
>
> $dl = "http://www.corrige2.bluehill.com/pdfs"; //url where files are
> uploaded
>
> $absolute_path = "http://www.corrige2.bluehill.com/pdfs"; //Absolute path to
> where files are uploaded
>
> $websiteurl = "http://www.corrige2.bluehill.com"; //Url to you website
>
> $websitename = "Corrigent";
>
> switch($action) {
>
> default:
>
> echo "<html><head><title>Upload Or Download</title></head><body><a
> href=$PHP_SELF?action=upload>Upload File</a> <a
> href=$PHP_SELF?action=download>Download File</a>";
>
> echo "<a href=$websiteurl>Return to $websitename</a><br><br>Powered by PHP
> Uploader Downloader</a></body></html>";
>
> break;
>
> case "download":
>
> echo "<html><head><title>File Download</title></head><body><a
> href=$PHP_SELF?action=upload>Upload File</a> <a href=$websiteurl>Return to
> $websitename</a>";
>
> $list = "<table width=700 border=1 bordercolor=#000000
> style=\"border-collapse: collapse\">";
>
> $list .= "<tr><td width=700><center><b>Click To
> Download</b></center></td></tr>";
>
> $dir = opendir($absolute_path);
>
> while($file = readdir($dir)) {
>
> if (($file != "..") and ($file != ".")) {
>
> $list .= "<tr><td width=700><a
> href='$dl/$file'>$file</a></center></td></tr>";
>
> }
>
> }
>
> $list .= "</table>";
>
> echo $list;
>
> echo"<br><br>Powered by PHP Uploader Downloader</a></body></html>";
>
> break;
>
> case "upload":
>
> echo"<html><head><title>File Upload</title></head><body><form method=POST
> action=$PHP_SELF?action=doupload enctype=multipart/form-data
> ID="Form1"><p>File to upload:<br><input type=file name=file size=30
> ID="File1">";
>
> echo"<p><button name=submit type=submit
> ID="Button1">Upload</button></form><br><br>Powered by PHP Uploader
> Downloader</a></body></html>";
>
> break;
>
> //File Upload
>
> case "doupload":
>
> $dir = "dir";
>
> if ($file != "") {
>
> if (file_exists("$absolute_path/$file_name")) {
>
> die("File already exists");
>
> }
>
> $ext = strrchr($file_name,'.');
>
> if (($extlimit == "yes") && (!in_array($ext,$limitedext))) {
>
> die("The file you are uploading doesn't have the correct extension.");
>
> }
>
> @copy($file, "$absolute_path/$file_name") or die("The file you are trying to
> upload couldn't be copied to the server");
>
> } else {
>
> die("Must select file to upload");
>
> }
>
> echo "<html><head><title>File Uploaded</title></head><body>";
>
> echo $file_name." was uploaded";
>
> echo "<br><a href=$PHP_SELF?action=upload>Upload Another File</a><a
> href=$PHP_SELF?action=download> Download File</a><a href=$websiteurl> Return
> to $websitename</a><br><br>Powered by <a href=http://www.zachwhite.com/>PHP
> Uploader Downloader</a></body></html>";
>
> break;
>
> }
>
> ?>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
Pablo M. Rivas. http://pmrivas.ipupdater.com http://www.r3soft.com.ar
-----------------------------------------------------------
--- End Message ---
--- Begin Message ---
One thing I forgot to mention that the files themselves will probably
run between 12 - 14 megs per pop before they even touch the mysql/php
server (this is all done by hand). I'm not even sure how much space
they will take up when being entered in to the database. On average it
should be about 150-200 variables (mostly date/timestamps, 3-comma
integers, tinytext, and a few tables with 512+ character notes).
-----Original Message-----
From: M. Sokolewicz [mailto:[EMAIL PROTECTED]
Sent: Friday, September 24, 2004 4:07 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Re: A few questions about system requirements
Steven wrote:
> Howdy,
>
> I'm going to be writing an app for our company that
handles
> the day-to-day processes here and I have a question for the
experienced
> devs out here that would know the ins and outs of working with CMS and
> good stats on what is needed for a server.
>
> I want to integrate my system with an existing CMS so I
can
> have the username/password management and security features with the
> notifications, ratings, and user calendars all bundled into one thing.
> Obviously, there is going to be some kickback for the ones who
> originally wrote all the goodies, but I need to know what will best
suit
> my company's needs.
>
> There will be about 15,000 'files' entered in per year
with
> about 70 employees banging away at it daily,
that's not much... trust me...
I have a friend running a forum/CMS which is getting pounded (at noon)
with 60 hits/second. He's running a P3 1.6Ghz, 1GB memory, Red Hat Linux
7.2 (Enigma) and he's coping just fine ;) (it's shared hosting aswell)
so I will probably need to
> build a pretty hoss database server and front-end to handle all of the
> php function calls. The big thing though, is would it be feasible to
> use a CMS system, could it handle that many people hammering away at
it,
> and easily hook in all of the CMS's features into my main app (such as
> using smarty or somesuch)
>
> Please advise and thanks in advance!
>
> Steven A.
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
Curt,
Thanks.
> > #mysql_select_db($db2,$myconnection2); #not necessary
>
> Why isn't this necessary? if you have just opened a connection you
> must select a database. Besides the fact that the second connection
> isn't necessary.
>
>From what I have experimented with, if I declare $db.$table in my sql, it is no
>longer necessary:
$sql2 = 'select participant,biography,district from '.$db.'.'.$table2.' where
district=$mydata1->district';
> > while ($mydata1 = mysql_fetch_object($news))
> > {
> > echo "$mydata1->district<br />$mydata1->meeting<br />$mydata1->time<br />\n";
> >
> > $sql2 = 'select participant,biography,district from '.$db.'.'.$table2.' where
> > district=$mydata1->district';
>
My error was in the single quotes.
> If you need the stylesheet to go along with this see
> [EMAIL PROTECTED] :)
Thanks. I Will look athtat.
John
> HTH.
Thanks, yes.
--- End Message ---
--- Begin Message ---
I know there is a way to print to pdf. Wh«t about rtf?
I'm getting real tired of doing it myself. Must be an easier answer?
header("Content-type: text/rtf");
header("Content-Disposition: attachment; filename=directory.rtf");
echo
"{\\rtf1\ansi\ansicpg1252\deff0\deflang1033\deflangfe1033{\fonttbl{\f0\froman\fprq2\fcharset0
Times New Roman;}{\f1\fnil\fcharset0 Times New Roman;}}
\viewkind4\uc1\pard\qc\lang4105\b\f0\fs24 The Grand Lodge of Qu\'e9bec A.F.&A.M.\b0\par
\b La Grande Loge du Qu\'e9bec M.A.F.&A.\b0\par
\par
\b Qu\'e9bec Masonic Directory\b0\par
\b Annuaire Ma\'e7onnique du Qu\'e9bec\b0\par
\par
\b Autumn / Automne 2005\b0\par
\par
\b Published by / Publi\'e9 par\b0\par
\b The Grand Lodge of Qu\'e9bec Communications Committee\b0\par
\b Le Comit\'e9 des communications de la Grande Loge du Qu\'e9bec\b0\par
";
--- End Message ---
--- Begin Message ---
Hello,
On 09/24/2004 11:16 PM, John Taylor-Johnston wrote:
I know there is a way to print to pdf. Wh«t about rtf?
I'm getting real tired of doing it myself. Must be an easier answer?
You may want to try this RTF generator class:
http://www.phpclasses.org/rtfgenerator
--
Regards,
Manuel Lemos
PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/
PHP Reviews - Reviews of PHP books and other products
http://www.phpclasses.org/reviews/
Metastorage - Data object relational mapping layer generator
http://www.meta-language.net/metastorage.html
--- End Message ---
--- Begin Message ---
Hello,
On 09/24/2004 11:16 PM, John Taylor-Johnston wrote:
I know there is a way to print to pdf. Wh«t about rtf?
I'm getting real tired of doing it myself. Must be an easier answer?
You may want to try this RTF generator class:
http://www.phpclasses.org/rtfgenerator
--
Regards,
Manuel Lemos
PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/
PHP Reviews - Reviews of PHP books and other products
http://www.phpclasses.org/reviews/
Metastorage - Data object relational mapping layer generator
http://www.meta-language.net/metastorage.html
--- End Message ---
--- Begin Message ---
Hi,
I am searching for a REAL simple templateing
class/package
I have googled for this and basically SMARTY and PAT
is too bulky, the people who will be using this script
will be pretty dumb and all I can trust them to do
would be something like this:
<header>
<category> ---- <contents>
<footer>
and the template should have a cacheing feature...
Looking via google i think I can make such a "template
engine" or another option would be to "get the
contents of a file and eval() them" as was written on
devshed, but if someone knows of something like this
thats already written....
Thanks,
Mag
=====
------
- The faulty interface lies between the chair and the keyboard.
- Creativity is great, but plagiarism is faster!
- Smile, everyone loves a moron. :-)
__________________________________
Do you Yahoo!?
New and Improved Yahoo! Mail - 100MB free storage!
http://promotions.yahoo.com/new_mail
--- End Message ---
--- Begin Message ---
Greetings...
I am getting a parse error (line 45) and I do not know what is causing it...
since I have the same code with minor changes nyc_ renamed to fed_ and
it works...
can someone please assit.
code is also available at http://www.phpaste.com/536
File: /var/www/html/cert/mod/nyc_threat.php
error message:
Parse error: parse error in /var/www/html/cert/mod/nyc_threat.php on line 45
[START CODE... in its entirety -- from line 1]
<?PHP
// Get NYC Threat Alert Level (From Settings Table in DB)
require 'db_access.php';
$nyc_threat_query =<<< QUERY
Select S.Setting_Value
From CERT.settings S
Where S.Setting_Name = 'NYC Threat';
QUERY;
$nyc_threat_result = mysql_query($nyc_threat_query,$db_access) or
die("NYC THREAT".$mysql_error());
$nyc_match = mysql_fetch_row($nyc_threat_result);
$alert = "";
if(strtolower($nyc_match[0]) == strtolower('low')) $alert = "Green [Low]";
elseif(strtolower($nyc_match[0]) == strtolower('guarded')) $alert =
"Blue [Guarded]";
elseif(strtolower($nyc_match[0]) == strtolower('elevated')) $alert =
"Yellow [Elevated]";
elseif(strtolower($nyc_match[0]) == strtolower('high')) $alert =
"Orange [High]";
elseif(strtolower($nyc_match[0]) == strtolower('severe')) $alert =
"Red [Severe]";
else $alert="unknown [An Error Has Occured]";
# echo "New York City Threat Advisory <br>"; # This content is now in the image
# echo '<img
src="images/threat_advisory/gmh/'.strtolower($nyc_match[0]).'-NYCv1.png"
alt="New York City Threat Alert Status is currently at: '.
strtoupper($alert) .' ALERT" align = "center">';
$nyc_alert =<<< CODE
<script language="JavaScript1.2">
var nyc_slideshow_width='180px' //SET IMAGE WIDTH
var nyc_slideshow_height='90px' //SET IMAGE HEIGHT
var nyc_pause=0300 //SET PAUSE BETWEEN SLIDE (3000=3 seconds)
var nyc_fadeimages=new Array()
//SET IMAGE PATHS. Extend or contract array as needed
CODE;
$nyc_alert .= '
nyc_fadeimages[0]="images/threat_advisory/gmh/'.trim(strtolower($nyc_match[0])).
'-NYC_2v1.png"';
$nyc_alert .= '
nyc_fadeimages[1]="images/threat_advisory/gmh/' .
trim(strtolower($nyc_match[0])) . '-NYC_1v1.png"';
$nyc_alert .= <<<CODE
////NO need to edit beyond here/////////////
var nyc_preloadedimages=new Array()
for (p=0;p<nyc_fadeimages.length;p++){
nyc_preloadedimages[p]=new Image()
nyc_preloadedimages[p].src=nyc_fadeimages[p]
}
var nyc_ie4=document.all
var nyc_dom=document.getElementById
if (nyc_ie4||nyc_dom)
document.write('<div
style="position:relative;width:'+nyc_slideshow_width+';height:'+nyc_slideshow_height+';overflow:hidden"><div
id="nyc_canvas0"
style="position:absolute;width:'+nyc_slideshow_width+';height:'+nyc_slideshow_height+';top:0;left:0;filter:alpha(opacity=10);-moz-opacity:10"></div><div
id="nyc_canvas1"
style="position:absolute;width:'+nyc_slideshow_width+';height:'+nyc_slideshow_height+';top:0;left:0;filter:alpha(opacity=10);-moz-opacity:10"></div></div>')
else
document.write('<img name="nyc_defaultslide" src="'+nyc_fadeimages[0]+'">')
var nyc_curpos=10
var nyc_degree=10
var nyc_curcanvas="nyc_canvas0"
var nyc_curimageindex=0
var nyc_nextimageindex=1
function nyc_fadepic(){
if (nyc_curpos<100){
nyc_curpos+=10
if (nyc_tempobj.filters)
nyc_tempobj.filters.alpha.opacity=nyc_curpos
else if (nyc_tempobj.style.MozOpacity)
nyc_tempobj.style.MozOpacity=nyc_curpos/100
}
else{
clearInterval(nyc_dropslide)
nyc_nextcanvas=(nyc_curcanvas=="nyc_canvas0")? "nyc_canvas0" : "nyc_canvas1"
nyc_tempobj=nyc_ie4? eval("document.all."+nyc_nextcanvas) :
document.getElementById(nyc_nextcanvas)
nyc_tempobj.innerHTML='<img src="'+nyc_fadeimages[nyc_nextimageindex]+'">'
nyc_nextimageindex=(nyc_nextimageindex<nyc_fadeimages.length-1)?
nyc_nextimageindex+1 : 0
setTimeout("nyc_rotateimage()",nyc_pause)
}
}
function nyc_rotateimage(){
if (nyc_ie4||nyc_dom){
nyc_resetit(nyc_curcanvas)
var nyc_crossobj=nyc_tempobj=nyc_ie4?
eval("document.all."+nyc_curcanvas) :
document.getElementById(nyc_curcanvas)
nyc_crossobj.style.zIndex++
var nyc_temp='setInterval("nyc_fadepic()",50)'
nyc_dropslide=eval(nyc_temp)
nyc_curcanvas=(nyc_curcanvas=="nyc_canvas0")? "nyc_canvas1" : "nyc_canvas0"
}
else
document.images.nyc_defaultslide.src=nyc_fadeimages[nyc_curimageindex]
nyc_curimageindex=(nyc_curimageindex<nyc_fadeimages.length-1)?
nyc_curimageindex+1 : 0
}
function nyc_resetit(nyc_what){
nyc_curpos=10
var nyc_crossobj=nyc_ie4? eval("document.all."+nyc_what) :
document.getElementById(nyc_what)
if (nyc_crossobj.filters)
nyc_crossobj.filters.alpha.opacity=nyc_curpos
else if (nyc_crossobj.style.MozOpacity)
nyc_crossobj.style.MozOpacity=nyc_curpos/100
}
function nyc_startit(){
var nyc_crossobj=nyc_ie4? eval("document.all."+nyc_curcanvas) :
document.getElementById(nyc_curcanvas)
nyc_crossobj.innerHTML='<img src="'+nyc_fadeimages[nyc_curimageindex]+'">'
nyc_rotateimage()
}
if (nyc_ie4||nyc_dom)
window.onload=nyc_startit
else
setInterval("nyc_rotateimage()",nyc_pause)
</script>
CODE;
echo $nyc_alert;
?>
--- End Message ---
--- Begin Message ---
GH wrote:
Greetings...
I am getting a parse error (line 45) and I do not know what is causing it...
since I have the same code with minor changes nyc_ renamed to fed_ and
it works...
can someone please assit.
code is also available at http://www.phpaste.com/536
File: /var/www/html/cert/mod/nyc_threat.php
error message:
Parse error: parse error in /var/www/html/cert/mod/nyc_threat.php on line 45
$nyc_alert .= <<<CODE
There is a white space after CODE
--- End Message ---
--- Begin Message ---
Hi,
My question: can I open $table2 within $table1 - I thought so.
I thought I had this set up correctly. Sorry to throw all these lines of code at you.
But I need to situate the error for someone to see plainly what I'm doing.
I'm getting this error:
Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource
in /home/users/q/qx04t9mu/www/English/directory4.php on line 101
I'm using two tables: $table_glq & $table_officers
I'm trying to link to a second table with a first. This should work, but does not!
My error is here:
line 101> while ($mydata2 = mysql_fetch_object($news2))
---------snip------------
######################################################
$sql = 'select * from '.$db.'.'.$table_glq.' order by district,number asc';
$news = mysql_query($sql); //desc => z-a
$previous_district = "";
while ($mydata = mysql_fetch_object($news))
{
if ($previous_district != $mydata->district) {
$previous_district = $mydata->district;
echo "<hr size=1><h2>$mydata->district</h2>\n";
#$sql2 = 'select * from '.$db.'.'.$table_Officers.' where district=$mydata->district';
$sql2 = "select * from ".$db.".".$table_Officers."where district='" .
$mydata->district. "'";
$news2 = mysql_query($sql2); //desc => z-a
while ($mydata2 = mysql_fetch_object($news2))
{
echo "<li>$mydata2->Name</li>\n";
echo "<li>$mydata2->biography</li>\n";
}
}#end of if
echo "<h3>$mydata->group No.$mydata->number</h3>\n";
echo "Meets: $mydata->meetingtime</small>";
}#end of while
############################################################
Both versions of $sql2 work, by the way - if that helps.
John
--- End Message ---
--- Begin Message ---
On Sat, 25 Sep 2004 01:01:13 -0400, John Taylor-Johnston
<[EMAIL PROTECTED]> wrote:
> Hi,
Hi, the error on the line
line 101> while ($mydata2 = mysql_fetch_object($news2))
says that $news2 is null. The line
$news2 = mysql_query($sql2); //desc => z-a
probably didn't work. How about trying;
$news2 = mysql_query($sql2); //desc => z-a
print_r($news2);
first and see it $news2 is indeed a valid resource.
----
ramil
http://ramil.sagum.net
--- End Message ---
--- Begin Message ---
Ramil,
Got that. thanks. Yeah, I mis-named a field in the seond table. Needed to name title
for district
$sql2 = "select * from ".$db.".".$table_GLOfficers." where title='" .
$mydata->district. "'";
Thanks for that. Getting late, i guess.
John
--- End Message ---