php-general Digest 28 Dec 2003 21:19:11 -0000 Issue 2499
Topics (messages 173394 through 173402):
Re: newbie mysql and php
173394 by: Chris
173395 by: tony
173396 by: tony
Can't upload files > then 400K to MySQL
173397 by: ahmetax
173399 by: Raditha Dissanayake
HELP NEEDED PLEASE - IMAP, MySQL and PHP
173398 by: Vernon
Re: Can't upload file greater than 11kb
173400 by: raditha dissanayake
Re: Maths dumbass
173401 by: Ryan A
Simple question
173402 by: Labunski
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 ---
It looks like mysql_query is failing, add these two lines to your code, and
see what message pops up:
...
$dbdo = mysql_query($query,$dbconnect);
if(false === $dbdo) echo mysql_errno(),': ',mysql_error();
else echo 'The query worked, $dbdo value is:',$dbdo;
while($row= mysql_fetch_array($dbdo)){
...
Chris
-----Original Message-----
From: tony [mailto:[EMAIL PROTECTED]
Sent: Saturday, December 27, 2003 4:18 PM
To: [EMAIL PROTECTED]
Subject: [PHP] newbie mysql and php
hello
I'm new with php just learning and i have just a problem with the following
code
$dbconnect = mysql_connect("localhost", "prog_tony","PASSWORD");
mysql_select_db("prog_dealer", $dbconnect);
$stop = 0;
$counter = 1;
while(!$stop){
$query = "SELECT name FROM category WHERE id = $counter";
$dbdo = mysql_query($query,$dbconnect);
while($row= mysql_fetch_array($dbdo)){
if($row[0]){
$counter++;
}else{
$stop=1;
}
$row[0] = "";
}
}
I'm getting an error with mysql_fetch_array() which is line 14 because I
didn't show the other lines since it is not relevant.
here is the error
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result
resource in /home/prog/public_html/php/cateadded.php on line 14
Thank you
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
the problem i get is that its say no database selected
Anthony
"Chris" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> It looks like mysql_query is failing, add these two lines to your code,
and
> see what message pops up:
>
> ...
> $dbdo = mysql_query($query,$dbconnect);
> if(false === $dbdo) echo mysql_errno(),': ',mysql_error();
> else echo 'The query worked, $dbdo value is:',$dbdo;
> while($row= mysql_fetch_array($dbdo)){
> ...
>
>
> Chris
>
> -----Original Message-----
> From: tony [mailto:[EMAIL PROTECTED]
> Sent: Saturday, December 27, 2003 4:18 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP] newbie mysql and php
>
>
> hello
>
> I'm new with php just learning and i have just a problem with the
following
> code
>
> $dbconnect = mysql_connect("localhost", "prog_tony","PASSWORD");
> mysql_select_db("prog_dealer", $dbconnect);
> $stop = 0;
> $counter = 1;
> while(!$stop){
> $query = "SELECT name FROM category WHERE id = $counter";
> $dbdo = mysql_query($query,$dbconnect);
> while($row= mysql_fetch_array($dbdo)){
> if($row[0]){
> $counter++;
> }else{
> $stop=1;
> }
> $row[0] = "";
> }
>
> }
>
>
>
> I'm getting an error with mysql_fetch_array() which is line 14 because I
> didn't show the other lines since it is not relevant.
> here is the error
> Warning: mysql_fetch_array(): supplied argument is not a valid MySQL
result
> resource in /home/prog/public_html/php/cateadded.php on line 14
>
> Thank you
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
Hi,
I fixed it, I have not realize that my database was not connected to a user.
so when i logged as prog_tony dealer was not a member of prog_tony so it
could not be found.
thanks for the help
"Tony" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> hello
>
> I'm new with php just learning and i have just a problem with the
following
> code
>
> $dbconnect = mysql_connect("localhost", "prog_tony","PASSWORD");
> mysql_select_db("prog_dealer", $dbconnect);
> $stop = 0;
> $counter = 1;
> while(!$stop){
> $query = "SELECT name FROM category WHERE id = $counter";
> $dbdo = mysql_query($query,$dbconnect);
> while($row= mysql_fetch_array($dbdo)){
> if($row[0]){
> $counter++;
> }else{
> $stop=1;
> }
> $row[0] = "";
> }
>
> }
>
>
>
> I'm getting an error with mysql_fetch_array() which is line 14 because I
> didn't show the other lines since it is not relevant.
> here is the error
> Warning: mysql_fetch_array(): supplied argument is not a valid MySQL
result
> resource in /home/prog/public_html/php/cateadded.php on line 14
>
> Thank you
--- End Message ---
--- Begin Message ---
Hi,
I have the following PHP code to upload files to a MySQL table.
It works fine, but, I can't upload any files greater then 400K.
What might be the problem?
TIA
ahmet
<?
if (isset($_POST["submit"]))
{
$fname= $_FILES["user_file"]["name"];
$tmp= addslashes($_FILES["user_file"]["tmp_name"]);
$size= $_FILES["user_file"]["size"];
$type=$_FILES["user_file"]["type"];
$tanim=$_FILES["user_file"]["file_desc"];
$fd=fopen($tmp,"r") or die("Can't open file!");
$fdata=urlencode(fread($fd,filesize($tmp)));
$size=filesize($tmp);
$tanim=$descript;
include("baglan.inc");
mysql_select_db("dosyalar");
$sql="INSERT INTO files (name,file_type,file_desc,file_data,file_size)".
" VALUES('$fname','$type','$descr','$fdata','$size')";
mysql_query($sql);
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>AxTelSoft-Uploading a file </title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1254">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-9">
<meta http-equiv="Content-Language" content="tr">
<meta http-equiv="description" content="axtelsoft, indir, download, delphi,
source code, kaynak kod">
<meta http-equiv="Pragma" content="no-cache">
<meta name="Generator" content="Ahmet Aksoy">
</head>
<body>
<form enctype="multipart/form-data" action="<?php echo
$SERVER["PHP_SELF"];?>" method="post">
<input type="hidden" name="MAX_FILE_SIZE" value="16777215">
Send this file: <input name="user_file" type="file">
Explanations : <TEXTAREA NAME="descript" ROWS=10 COLS=45 WRAP><?php
echo($descr);
?></TEXTAREA>
<P><input type="submit" value="Send File" name="submit">
</form>
</body>
</html>
--- End Message ---
--- Begin Message ---
hi
try this article: http://www.radinks.com/upload/config.php
It's a quick guide on configuring php for large file uploads.
all the best
ahmetax wrote:
Hi,
I have the following PHP code to upload files to a MySQL table.
It works fine, but, I can't upload any files greater then 400K.
What might be the problem?
TIA
ahmet
<?
if (isset($_POST["submit"]))
{
$fname= $_FILES["user_file"]["name"];
$tmp= addslashes($_FILES["user_file"]["tmp_name"]);
$size= $_FILES["user_file"]["size"];
$type=$_FILES["user_file"]["type"];
$tanim=$_FILES["user_file"]["file_desc"];
$fd=fopen($tmp,"r") or die("Can't open file!");
$fdata=urlencode(fread($fd,filesize($tmp)));
$size=filesize($tmp);
$tanim=$descript;
include("baglan.inc");
mysql_select_db("dosyalar");
$sql="INSERT INTO files (name,file_type,file_desc,file_data,file_size)".
" VALUES('$fname','$type','$descr','$fdata','$size')";
mysql_query($sql);
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>AxTelSoft-Uploading a file </title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1254">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-9">
<meta http-equiv="Content-Language" content="tr">
<meta http-equiv="description" content="axtelsoft, indir, download, delphi,
source code, kaynak kod">
<meta http-equiv="Pragma" content="no-cache">
<meta name="Generator" content="Ahmet Aksoy">
</head>
<body>
<form enctype="multipart/form-data" action="<?php echo
$SERVER["PHP_SELF"];?>" method="post">
<input type="hidden" name="MAX_FILE_SIZE" value="16777215">
Send this file: <input name="user_file" type="file">
Explanations : <TEXTAREA NAME="descript" ROWS=10 COLS=45 WRAP><?php
echo($descr);
?></TEXTAREA>
<P><input type="submit" value="Send File" name="submit">
</form>
</body>
</html>
--
Raditha Dissanayake.
------------------------------------------------------------------------
http://www.radinks.com/sftp/ | http://www.raditha.com/megaupload
Lean and mean Secure FTP applet with | Mega Upload - PHP file uploader
Graphical User Inteface. Just 150 KB | with progress bar.
--- End Message ---
--- Begin Message ---
Hello all,
I have been struggling for some time now to develop or find some product
that will allow me to scan documents (I have that part down no problem,
using OMNIPAGE 14.0) and put then into a searchable database with a copy of
it in some form that is readable like a formatted txt file.
I am looking for the easiest way to do this. I'm thinking if I can have the
files emailed into a MySQL database that would work expect the programs I
have found, however,will not allow me to bring the attachments into the
database. I've tried Xeoport which uses IMAP to access the email records and
pull all but the attachments in. Anyone know of anything that will help me
do this?
Thanks
--- End Message ---
--- Begin Message ---
Hi,
if you are lucky LimitRequestBody could go into a .htaccess file (not
sure though been a couple of months since i last read the manual)
Chris wrote:
It has been my experience that max_file_size does terminate the upload
process if you include it in the form.
But you are right, if it gets to the upload, your stuck.
LimitRequestBody is beyond my control as the site is hosted by a third
party.
Thanks
Chris
"Raditha Dissanayake" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
Hi,
It's often said in many newsgroups and articles that the max_file_size
is next to useless. It's also said that once IE starts uploading it will
not stop even if you keep you foot on the stop button!
If i remembers the earlier messages you have said the php.ini settings
are correct. If so it could well be that you might be having
misconfigured proxy server or firewall in the way.
Apache also has a setting (LimitRequestBody) that could effect your
upload.
all the best
Chris wrote:
I don't believe that the MAX_FILE_SIZE needs to be there. It will only
terminate the upload process at the client, rather than wait for the
upload
to complete.
Anyway with or without MAX_FILE_SIZE the upload process is being
terminated
after the file is uploaded.
When the form is submitted, the selected file is uploaded to the server's
temp directory then copied to the maps dir. For some reason, when the
file
size exceeds 11kb (very small) the process
gets aborted (with or without MAX_FILE_SIZE). I've put in diagnostic
messages and the POST script throws an error message if it can't find the
file
in the temp directory. I've uploaded several file sizes up to the max of
2MB
and it appears the file is being uploaded. I base this assumption on the
fact the upload time is proportional to the file size. When the file size
is
greater than 11kb it appears that the file is deleted from the temp dir.
Still no idea what is going on.
Chris
"Larry Brown" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
The <input type="hidden" ... is more than a convenience for the client.
It
must be before the ...type="file"... tag and after <form.. (at least
with
Mozilla Firebird as the client) If you have it in there and remember it
is
in bytes not kb and set it to a size large enough the script accepting
the
file will show $_FILE['name'] and it will show $_FILE['tmp_name'] having
the
temporary file. Then you take that hidden tag out and do the same the
$_FILE['tmp_name'] variable will be empty since it did not recieve the
file.
So I know at least in my case that the hidden field has to be there.
Larry
-----Original Message-----
From: Chris [mailto:[EMAIL PROTECTED]
Sent: Monday, December 22, 2003 8:55 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Can't upload file greater than 11kb
I've got a situation where I want to upload a file to a server then
enter
the data in that file into mysql. I have used this well documented
upload
form
<form enctype="multipart/form-data" action="_URL_" method="POST">
Send this file: <input name="userfile" type="file">
<input type="submit" value="Send File">
</form>
script on many php servers. However I am on one now which is not
allowing
me
to upload a file greater than 12kb.
I know the upload_max_filesize is 2M but something else is stopping the
upload and I don't have a clue what it is. I know you should include
<input
type="hidden" name="MAX_FILE_SIZE" value="30000"> in the above form but
that
is only a convenience for the user.
This particular server is running php as a cgi module.
Thanks
Chris
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
Raditha Dissanayake.
------------------------------------------------------------------------
http://www.radinks.com/sftp/ | http://www.raditha.com/megaupload
Lean and mean Secure FTP applet with | Mega Upload - PHP file uploader
Graphical User Inteface. Just 150 KB | with progress bar.
--
Raditha Dissanayake.
------------------------------------------------------------------------
http://www.radinks.com/sftp/ | http://www.raditha.com/megaupload
Lean and mean Secure FTP applet with | Mega Upload - PHP file uploader
Graphical User Inteface. Just 150 KB | with progress bar.
--- End Message ---
--- Begin Message ---
Hi,
Thanks for replying, sorry for the late replies but was busy with the
holidays.
Will look in to what you guys wrote, dont fully understand it :-p so will
spend some time with it and if I run into any problems will get back to ya.
Cheers,
-Ryan
Basically, have an array of # of days per month. Do a quick compare given
the month for the # of days. For the sake of example, we'll assume the month
in question has 31 days. So, here's some givens:
$month_days = 31;
$former_plan_days = $current_date;
$new_plan_days = ($current_date - $month_days);
Now, to get the values:
$former_plan_bill = ($full_former_price * ($former_plan_days /
$month_days));
$new_plan_bill = ($full_new_price * ($new_plan_days / $month_days));
$total_month_bill = ($former_plan_bill + $new_plan_bill);
There you have it. This should work no matter if they get an "upgrade" or
"downgrade" in service because it just takes the ratio of days to get the
percentage of the price that's owed and then multiplies the full price to
get the percentage that's owed.
Make sense? :)
> >Problem, selling 4 packages rangeing from $27.50-$99.00 a month...the
> >subscriber can change anytime he wants from one package to the other
> >(upgrade), if so I have to calculate how many days he has is with us and
> >then he just pays the balance...
> >
> >eg:
> >if he is on the smallest package ($27.50)
> >and the month has 30 days,
> > and 15 days are up,
> >(means 50% is used and that translates to 13.75$)
> > and he wants to upgrade to the next higher package ($43.00) he just has
to
> >pay $29.25
> >
> >Can you give me a clue on how to calculate that depending on the 12
months
> >and 4 packages?
>
> basically just thinking out loud here... not sure if this is what we want,
but:
>
> $daysNotPaid = $maxDaysInPackage - $daysPaid;
> $pricePerDay = $newPrice / $daysInPackage;
> $priceToPay = $pricePerDay * $daysNotPaid;
>
> obviously, for this you need some code to pick up how many days have
> elapsed in the current month, and something to pull the number of days in
> the package along with the price.
>
> naturally you can shove this all into one calculation and save 2
variables:
>
> $priceToPay = ($newPrice / $daysInPackage) * ($maxDaysInPackage -
$daysPaid);
>
> and if some of it don't vary, you can change that into the appropriate
> values naturally...
>
> HTH
>
> Rene (not a math wiz, but I do calcs like this constantly in my Excel
macros)
>
> --
> Rene Brehmer
> aka Metalbunny
>
> http://metalbunny.net/
> References, tools, and other useful stuff...
>
>
>
--- End Message ---
--- Begin Message ---
Hello, I have only one simple question..
I'm using this method to get the values from the text box:
if(isset($_POST["Submit"]) && $_POST["Submit"]=="Submit")
{
$add = $_POST['textbox'] ;
}
But I don't know how to write the source for this:
If the value from the textbox ($add) is "Hello" then.. do something.
I think it could be nicely done with IF, but I dont know how to write this..
Can someone help me, please?
Regards,
Lab.
--- End Message ---