Re: [PHP-DB] newbie help

2001-03-25 Thread Matt Coyne

Hi 

Thanks to CC Zona and Dean for their help

It all made sense this morning (BST).

I echoed the query and lo and behold... errors ... and of course I could see
where the problems lay.

It's amazing what a good nights sleep will do!

thanks again

now does anyone know about getting ages from dates of birth (previous post
of mine) and also searching by age group when you only have dates of birth
in the table!!

cheers
matt


t  h  r  e  e  z  e  r  o :   :  :

the mill, millstone lane, leicester, le1 5jn
e : [EMAIL PROTECTED] ::  m : 07747 845690
w : http://www.threezero.co.uk

:   :  :t  h  r  e  e  z  e  r  o


> From: CC Zona <[EMAIL PROTECTED]>
> Reply-To: [EMAIL PROTECTED]
> Date: Sun, 25 Mar 2001 10:39:23 -0800
> To: [EMAIL PROTECTED]
> Subject: Re: [PHP-DB] newbie help
> 
> In article <[EMAIL PROTECTED]>,
> [EMAIL PROTECTED] (Matt Coyne) wrote:
> 
>> I have been trying to detect if the variable holds any value and then
>> building a query by concatenating like this:
> 
> if(!empty($foo))
>  {
>  ...
>  }
> 
>> $result=@mysql_query($concatsql, $connection) or die ("bugger...!");
>> 
>> This just dies on mysql_query.
> 
> $result=@mysql_query($concatsql, $connection) or die (mysql_error() . "
> from query \n$concatsql"); //show as much relevant info as possible
> 
> When building complex queries like this, it's really easy to miss a missing
> quote or extra comma, etc.  Displaying the query string usually makes it
> quite obvious where the problem lies (especially when coupled with a MySQL
> error message, since MySQL is pretty good about pointing out the spot where
> the syntax fails).
> 
> -- 
> CC
> 
> -- 
> PHP Database 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 Database 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-DB] MsSQL 7 Bug?

2001-03-25 Thread NosyMan

Loading mssql module in php4pl1 under Windows Millennium crash my Apache
server (error in php4ts.dll). On Win98 or NT works fine.



-- 
PHP Database 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-DB] Inserting Image as Blob in MySql DB

2001-03-25 Thread Stuart J. Browne

> Does anyone know the proper method for inserting an image(*.jpg or
> *.gif) into a MySql database blob field?  I am recieving the file via an
> html form with the usual enctype for this and 
> parameters.  I can save it as just a regular file and then display it
> fine on the page, but no way can I update the database with this...and
> have tried everything imaginable...surely this is done everyday and is
> quite simple.
>
> code snippet below - and yes, I am a php beginner...ASP by day and
> trying to learn
> PHP by night..
> -
> $photo  = fopen($txtImage, "r");
> $filecontents = fread($photo, filesize($txtImage));
> echo "";
> echo "";
> $anotherfile = fopen("/www/htdocs/Survey/$thisfile", "a+");
> fputs($anotherfile, $filecontents);
> //fclose($anotherfile);
> echo "";
> echo "";
> echo "";
> echo $photo;
> echo "";
> echo "";
> $crapola = "101010101";
> echo "";
>
>
>
>  $connection = mysql_connect("mysql.iticom.net","fractalv","fw348vnj")
> or die ("crap!");
>  $db = mysql_select_db("fractalv", $connection) or die ("db");
>  $sql = "INSERT INTO Images (Image,
> ImageType,ImageGallery,ImageLink,ThumbnailLink) VALUES
> ('$filecontents','$txtImageType', '$txtImageGallery', '$txtImageLink',
> '$txtThumbnailLink')";
>  $sql_result = mysql_query($sql,$connection) or die ("could not insert
> into DB");
>  mysql_close($connection);
> -ect.
>
> thanks in advance for absolutley any ideas!


Phil,

I can think of two possible ways..  Depending on the version of MySQL
you have.

If you have v3.23, MySQL has a function called LOAD_FILE() which you can
pass the temporary file-name that you get from the wb page:

mysql_query( "insert into Images ( Image ) values ( load_file(
$txtImage ) );" );

Failing that, I would think that you have to read it in (as you do above),
escape it (addslashes() in php) then isnert that escaped string into the
database :

mysql_query( "insert into Images ( Image ) values ( '" . addslashes(
$filecontents ) . "' ); " );

Anyway.. a few possibilities to look into.

Bkx



-- 
PHP Database 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-DB] Re: [PHPLearners] uploading files.

2001-03-25 Thread olinux

here is the working script on my local windows machine. note that you will
need to change $the_path
Everything is pretty self explanatory. You can read the article that I took
this from at http://phpbuilder.com/columns/bealers2904.php3

olinux



 ".tar.gz, .tgz",
"application/x-zip-compressed" => ".zip",
"application/x-tar" => ".tar",
"text/plain" => ".html, .php, .txt, .inc (etc)",
"image/gif" => ".gif",
  "image/pjpeg"  => ".jpg, .jpeg",
  "image/jpeg"  => ".jpg, .jpeg",
"image/png" => ".png",
); # these are only a few examples, you can find many more!

$allowed_types = array("image/gif","image/jpeg","image/pjpeg","image/png");

# --

function form($error=false) {

global $PHP_SELF,$my_max_file_size;

if ($error) print $error . "";

print "\n";
print "\n";
print "\n";
print "\nUpload a file";
print "\nNOTE: Max file size is " . ($my_max_file_size / 1024) . "KB";
  print "\n";
print "\n";
print "\n";

} # END form

function validate_upload($the_file) {

global $my_max_file_size, $image_max_width,
$image_max_height,$allowed_types,$the_file_type,$registered_types;

$start_error = "\nError:\n";

if ($the_file == "none") { # do we even have a file?

$error .= "\nYou did not upload anything!";

} else { # check if we are allowed to upload this file_type

if (!in_array($the_file_type,$allowed_types)) {
$error .= "\nThe file that you uploaded was of a ".
"type that is not allowed, you are only
allowed to upload files of the type:\n";
while ($type = current($allowed_types)) {
$error .= "\n" . $registered_types[$type] . " (" . $type
. ")";
next($allowed_types);
}
$error .= "\n";
}

if (ereg("image",$the_file_type) &&
(in_array($the_file_type,$allowed_types))) {
  $the_file = stripslashes($the_file);

  $size = GetImageSize($the_file);
  list($foo,$width,$bar,$height) = explode("\"",$size[3]);
  if ($width > $image_max_width) {
  $error .= "\nYour image should be no wider than " .
  $image_max_width . " Pixels";
   }
  if ($height > $image_max_height)

  $error .= "\nYour image should be no higher than " .
  $image_max_height . " Pixels";
  }
   }
  if ($error) {
  $error = $start_error . $error . "\n";
  return $error;
  } else {
  return false;
  }
}
 } # END validate_upload



# --


function list_files() {

global $the_path;

$handle = dir($the_path);
print "\nUploaded files:";
while ($file = $handle->read()) {
if (($file != ".") && ($file != "..")) {
print "\n" . $file . "";
   }
}
print "";
}

# --

function upload($the_file) {

global $the_path,$the_file_name;

$error = validate_upload($the_file);
if ($error) {
form($error);
} else { # cool, we can continue
$the_file = stripslashes($the_file);

if (!@copy($the_file, $the_path . "/" . $the_file_name)) {
form("\nSomething barfed, check the path to and the permissions for
the upload directory");
} else {
list_files();
form();
}
}
} # END upload

# --

 Start page
print "\n\nUpload example\n\n";

switch($task) {
case 'upload':
upload($the_file);
break;
default:
form();
}

print "\n\n";

?>




enjoy,

olinux


- Original Message - 
  From: Josh Gasber 
  To: [EMAIL PROTECTED] 
  Sent: Sunday, March 25, 2001 2:42 PM
  Subject: RE: [PHPLearners] uploading files.


  olinux,
   
  I would be interested in hearing the solution, can you please pass it on.
   
  Thanks,
  Josh



Re: [PHP-DB] Help?

2001-03-25 Thread Felix Kronlage

On Mon, Mar 26, 2001 at 09:24:38PM -0800, Chris Hall wrote:

> Parse error: parse error, expecting `','' or `';'' in
> f:\inetpub\wwwroot\forums\index.php on line 38
> line 38 would be:
> echo "Name: "$row["user_id"]."\n";
  ^^ missing a '.' there.

either this way

echo "Name: " . $row["user_id"] . "\n";

or 
   echo "Name: $row['user_id']\n";


-fkr
-- 
gpg-fingerprint: 076E 1E87 3E05 1C7F B1A0  8A48 0D31 9BD3 D9AC 74D0 
  |http://www.hazardous.org/ | whois -h whois.ripe.de FKR-RIPE  |
  |all your base are belong to us  |  shame on me  | fkr@IRCnet | 

 PGP signature


Re: [PHP-DB] Help?

2001-03-25 Thread Phil Jackson

Perhaps the quote marks within quote marks?  PHP,as is javascript, very
particular..
Try:
echo "Name: $row['user_id'].'\n"; or some such.
or
echo "Name".$row[user_id]."\n";
It's the quote marks within that are playing havoc..

Phil J.

Chris Hall wrote:

> I keep getting this error on a little project im working on to learn PHP and
> MySQL better:
> Parse error: parse error, expecting `','' or `';'' in
> f:\inetpub\wwwroot\forums\index.php on line 38
> line 38 would be:
> echo "Name: "$row["user_id"]."\n";
> Can anyone help?
>
> --
> Chris Hall
> sytems administrator
> funnelbox mediaworks
> [EMAIL PROTECTED]
>
> --
> PHP Database 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 Database 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-DB] Help?

2001-03-25 Thread Chris Hall

I keep getting this error on a little project im working on to learn PHP and
MySQL better:
Parse error: parse error, expecting `','' or `';'' in
f:\inetpub\wwwroot\forums\index.php on line 38
line 38 would be:
echo "Name: "$row["user_id"]."\n";
Can anyone help?

--
Chris Hall
sytems administrator
funnelbox mediaworks
[EMAIL PROTECTED]



-- 
PHP Database 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-DB] Inserting Image as Blob in MySql DB

2001-03-25 Thread Phil Jackson

Hi,
Does anyone know the proper method for inserting an image(*.jpg or
*.gif) into a MySql database blob field?  I am recieving the file via an
html form with the usual enctype for this and 
parameters.  I can save it as just a regular file and then display it
fine on the page, but no way can I update the database with this...and
have tried everything imaginable...surely this is done everyday and is
quite simple.

code snippet below - and yes, I am a php beginner...ASP by day and
trying to learn
PHP by night..
-
$photo  = fopen($txtImage, "r");
$filecontents = fread($photo, filesize($txtImage));
echo "";
echo "";
$anotherfile = fopen("/www/htdocs/Survey/$thisfile", "a+");
fputs($anotherfile, $filecontents);
//fclose($anotherfile);
echo "";
echo "";
echo "";
echo $photo;
echo "";
echo "";
$crapola = "101010101";
echo "";



 $connection = mysql_connect("mysql.iticom.net","fractalv","fw348vnj")
or die ("crap!");
 $db = mysql_select_db("fractalv", $connection) or die ("db");
 $sql = "INSERT INTO Images (Image,
ImageType,ImageGallery,ImageLink,ThumbnailLink) VALUES
('$filecontents','$txtImageType', '$txtImageGallery', '$txtImageLink',
'$txtThumbnailLink')";
 $sql_result = mysql_query($sql,$connection) or die ("could not insert
into DB");
 mysql_close($connection);
-ect.

thanks in advance for absolutley any ideas!

Phil J.

.


-- 
PHP Database 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-DB] Error Control

2001-03-25 Thread Jason Bell

Hello! I'm writing a script that validates a form It creates users in a
mysql table, where there are 2 unique columns 'username' and 'email'.

I'm putting mysql_error() into a variable, but I don't want the end user to
see that particular message... is there a way to look at just the key that
has been duplicated, and create a custom error message for user display?

for example, when I duplicate a username, 'jbell', I get this from
mysql_error() : "Duplicate entry 'jbell' for key 2"

I want to be able to see that the error is from key 2, and react
accordingly

thank you,

Jason Bell


-- 
PHP Database 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-DB] mysql_connect() error

2001-03-25 Thread Chad Schmidt

Never mind I figured it out!

""Chad Schmidt"" <[EMAIL PROTECTED]> wrote in message
99lqi8$u00$[EMAIL PROTECTED]">news:99lqi8$u00$[EMAIL PROTECTED]...
> I'm having problems getting php to interface with mysql on a linux server.
> I have a Linux Redhat setup and everything has been rpm'ed.  Here is the
> error I get
>
> "Fatal error: Call to undefined function: mysql_connect() in
> /var/www/html/secure/index.php4 on line 4"
>
> Thanks in advance,
>
>
>
> --
> PHP Database 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 Database 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-DB] simple database for member

2001-03-25 Thread John

anybody can figure it out, and explain to me how to make a simple database
for members like this one
http://www.schroet.de/mem.php3

and when people click on the name of one members
http://www.schroet.de/members.php3?nick=Jap

they will redirect it to Jap member section

thanks



-- 
PHP Database 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-DB] mysql_connect() error

2001-03-25 Thread Chad Schmidt

I'm having problems getting php to interface with mysql on a linux server.
I have a Linux Redhat setup and everything has been rpm'ed.  Here is the
error I get

"Fatal error: Call to undefined function: mysql_connect() in
/var/www/html/secure/index.php4 on line 4"

Thanks in advance,



-- 
PHP Database 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-DB] newbie question on form..

2001-03-25 Thread Andreas D. Landmark


-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

At 25.03.2001 22:36, you wrote:
>Hello boys that's ok??  well 
>I have this question
>I connect to a database (on interbase 6) and retrive some datas from a
>table...
>now  i want to create a form where the input field show old datas into
>the respective input text box...

echo "";

should create a textbox with $from_database as it's value
and then it's up to you how you'd like to fill $from_database, either from
a database (duh) or by any other means...

Regards,


- -- 
Andreas Landmark / noXtension
[EMAIL PROTECTED]
"Martin Luther King, Malcom X, Freedom of speech is as good as sex."
 - Madonna, Perfomer
-BEGIN PGP SIGNATURE-
Version: PGPfreeware 7.0.3 for non-commercial use 

iQA/AwUBOr5se79yhB2yvq6AEQIQrwCfWLfduD8q42QvvVAkFdAOe3kscrkAmgKe
STRXaLiXYYohUzkxvhCPd0A1
=DZnR
-END PGP SIGNATURE-


-- 
PHP Database 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-DB] newbie question on form..

2001-03-25 Thread TONIATI ORAZIO

Hello boys that's ok??  well 
I have this question
I connect to a database (on interbase 6) and retrive some datas from a
table...
now  i want to create a form where the input field show old datas into
the respective input text box...

anyone can help me??

thank's at all...

by  Davide Marchesin


-- 
PHP Database 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-DB] newbie help

2001-03-25 Thread Dean Bennett

It looks like your checks are reversed, and you end up with 2 ANDs between 
the sex and height clauses.  Like someone else pointed out, it is very 
helpful to echo the generated query so you can see what you've got.

A simpler solution, assuming that both fields are optional:

$sql = "SELECT ref, firstname, surname FROM $tablename";
$sql .= " WHERE 1=1";
if ($sex)   // or if (!empty($sex)
$sql .= " AND sex = '$sex' ";
if ($heightFt)
$sql .= " AND heightFt = '$heightFt' ";

$sql .= " ORDER BY surname";

echo "query is $sql";
$result=@mysql_query($sql, $connection) or die ("bugger...!");


-- 
PHP Database 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-DB] mysql privilege

2001-03-25 Thread Johannes Janson

Hi,

to do this you'd need to be a quite priviledged user.
in order to create users you'll need acces to the
user-table of mysql. not likely to be given to a "normal"
user. developing on your home pc, well...

you need GRANT to grant priviledges to any user.
also not likely to be given to a user.

> Hello php-db,
>
>   what privileges that i need to do this (privileges for any number):
>   1 create database
>   2 Give privilege to any user
>   3 create user
>   4
>   -
>   and what does GRANT and REFERENCE privileges for ?
>
> --
> Best regards,
>  andrie  mailto:[EMAIL PROTECTED]
>
>
>
> --
> PHP Database 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 Database 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-DB] PHP4 and MS SQL 2000

2001-03-25 Thread Thomas W. Badera

Hello -

I've been using PHP4 for a while with my MS SQL7 server, but recently
upgraded to Win2k and SQL2k.  Now, I can no longer connect via user/pass.  I
get the following error:

Warning: MS SQL message: Login failed for user '[EMAIL PROTECTED]'.
Reason: Not associated with a trusted SQL Server connection. (severity 14)
in D:\Webs\sportspotonline.com\listItems.php3 on line 27

Any suggestions would be greatly appreciated...

Thanks,
--TWB


---
Thomas W. Badera
WebTeam Manager
Clarkson University
< [EMAIL PROTECTED] >



-- 
PHP Database 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-DB] Read a few lines

2001-03-25 Thread [EMAIL PROTECTED]

Hello,

I want to copy a few single lines in a HTML file.
A want to read everything from  to 

Is this possible with php



Re: [PHP-DB] newbie help

2001-03-25 Thread CC Zona

In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] (Matt Coyne) wrote:

> I have been trying to detect if the variable holds any value and then
> building a query by concatenating like this:

if(!empty($foo))
   {
   ...
   }

> $result=@mysql_query($concatsql, $connection) or die ("bugger...!");
> 
> This just dies on mysql_query.

$result=@mysql_query($concatsql, $connection) or die (mysql_error() . " 
from query \n$concatsql"); //show as much relevant info as possible

When building complex queries like this, it's really easy to miss a missing 
quote or extra comma, etc.  Displaying the query string usually makes it 
quite obvious where the problem lies (especially when coupled with a MySQL 
error message, since MySQL is pretty good about pointing out the spot where 
the syntax fails).

-- 
CC

-- 
PHP Database 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-DB] newbie help

2001-03-25 Thread Matt Coyne

Hi all

Having created a form that sends values to a php file that searches a table
and returned results in the format specified I was on a high (little things
I know!). 

However, this only works if I enter values into all fields on the form. How
can I create an SQL query (mySQL) that will use only variables that have
values entered in the previous form and ignore those fields that were not
filled in?

At the moment I am using a simple query like (this query is a shortened
version for this email):

$sql = "SELECT ref, firstname, surname FROM artistes WHERE sex = '$sex' AND
heightFt = '$heightFt' AND heightIn= '$heightIn' ORDER BY surname";

$result=@mysql_query($sql, $connection) or die ("bugger...!");

---

I have been trying to detect if the variable holds any value and then
building a query by concatenating like this:

// ASSEMBLE SQL QUERY
// make the select
$select = "SELECT ref, firstname, surname ";

//add the tablename to the query
$fromtable = "FROM ";
$fromtable .= $tablename;

//build where clause
$where = " WHERE ";

//determine what we are selecting
if (!$sex) {
$Qsex = "sex = '$sex' ";
} else {
$Qsex = "";
}

if (!$heightFt) {
$QheightFt = "AND heightFt = '$heightFt' ";
} else {
$QheightFt = "";
}

// specify AND OR
$Qconcat = "AND ";

// specify how results are ordered
$orderby = "ORDER BY surname";

$concatsql = $select;
$concatsql .= $fromtable;
$concatsql .= $where;
$concatsql .= $Qsex;
$concatsql .= $Qconcat;
$concatsql .= $QheightFt;
$concatsql .= $orderby;

$result=@mysql_query($concatsql, $connection) or die ("bugger...!");

This just dies on mysql_query.

Sorry to make this such a long post, but this is really getting to me and I
believe there must be a simple answer that I am missing.

Can anyone help... please?!!

cheers
matt

t  h  r  e  e  z  e  r  o :   :  :

the mill, millstone lane, leicester, le1 5jn
e : [EMAIL PROTECTED] ::  m : 07747 845690
w : http://www.threezero.co.uk

:   :  :t  h  r  e  e  z  e  r  o



-- 
PHP Database 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-DB] uploading files.

2001-03-25 Thread olinux

here is the working script on my local windows machine. note that you will
need to change $the_path
Everything is pretty self explanatory. You can read the article that I took
this from at http://phpbuilder.com/columns/bealers2904.php3

olinux



 ".tar.gz, 
.tgz",
"application/x-zip-compressed" => ".zip",
"application/x-tar" => ".tar",
"text/plain" => ".html, .php, .txt, .inc 
(etc)",
"image/gif" => ".gif",
  "image/pjpeg"  => ".jpg, .jpeg",
  "image/jpeg"  => ".jpg, .jpeg",
"image/png" => ".png",
); # these are only a few examples, you can 
find many more!

$allowed_types = array("image/gif","image/jpeg","image/pjpeg","image/png");

# --

function form($error=false) {

global $PHP_SELF,$my_max_file_size;

if ($error) print $error . "";

print "\n";
print "\n";
print "\n";
print "\nUpload a file";
print "\nNOTE: Max file size is " . ($my_max_file_size / 1024) . "KB";
print "\n";
print "\n";
print "\n";

} # END form

function validate_upload($the_file) {

global $my_max_file_size, $image_max_width,
$image_max_height,$allowed_types,$the_file_type,$registered_types;

$start_error = "\nError:\n";

if ($the_file == "none") { # do we even have a file?

$error .= "\nYou did not upload anything!";

} else { # check if we are allowed to upload this file_type

if (!in_array($the_file_type,$allowed_types)) {
$error .= "\nThe file that you uploaded was of a ".
"type that is not allowed, you are only
allowed to upload files of the type:\n";
while ($type = current($allowed_types)) {
$error .= "\n" . $registered_types[$type] . " (" . $type
. ")";
next($allowed_types);
}
$error .= "\n";
}

if (ereg("image",$the_file_type) &&
(in_array($the_file_type,$allowed_types))) {
  $the_file = stripslashes($the_file);

  $size = GetImageSize($the_file);
  list($foo,$width,$bar,$height) = explode("\"",$size[3]);
  if ($width > $image_max_width) {
  $error .= "\nYour image should be no wider than " .
  $image_max_width . " Pixels";
   }
  if ($height > $image_max_height)

  $error .= "\nYour image should be no higher than " .
  $image_max_height . " Pixels";
  }
   }
  if ($error) {
  $error = $start_error . $error . "\n";
  return $error;
  } else {
  return false;
  }
}
 } # END validate_upload



# --


function list_files() {

global $the_path;

$handle = dir($the_path);
print "\nUploaded files:";
while ($file = $handle->read()) {
if (($file != ".") && ($file != "..")) {
print "\n" . $file . "";
   }
}
print "";
}

# --

function upload($the_file) {

global $the_path,$the_file_name;

$error = validate_upload($the_file);
if ($error) {
form($error);
} else { # cool, we can continue
$the_file = stripslashes($the_file);

if (!@copy($the_file, $the_path . "/" . $the_file_name)) {
form("\nSomething barfed, check the path to and the 
permissions for
the upload directory");
} else {
list_files();
form();
}
}
} # END upload

# --

 Start page
print "\n\nUpload example\n\n";

switch($task) {
case 'upload':
upload($the_file);
break;
default:
form();
}

print "\n\n";

?>




enjoy,

olinux



_
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


-- 
PHP Database 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-DB] Date

2001-03-25 Thread CC Zona

In article <002f01c0b52b$d4778e00$[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] ("[EMAIL PROTECTED]") wrote:

> I save the date in my MySQL db as 2001-03-25.
> 
> But in my PHP script i want do see it like 25-03-2001.

Do it in the MySQL select.  Assuming date_field is of field type 'date':

select date_format(date_field,"%d-%m-%y") as date_formatted from mytable;

(See the MySQL manual's section on date/time functions for more ideas)

-- 
CC

-- 
PHP Database 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-DB] uploading files.

2001-03-25 Thread Mohammed Mahmoud Abdel'al

Yes Please
- Original Message - 
From: "boclair" <[EMAIL PROTECTED]>
To: "olinux" <[EMAIL PROTECTED]>; "PHP-DB" <[EMAIL PROTECTED]>
Sent: Sunday, March 25, 2001 2:55 AM
Subject: Re: [PHP-DB] uploading files.


> Yes please
> 
> Tim Morris
> 
> - Original Message -
> From: olinux <[EMAIL PROTECTED]>
> To: PHP-DB <[EMAIL PROTECTED]>
> Sent: Sunday, March 25, 2001 11:21 AM
> Subject: Re: [PHP-DB] uploading files.
> 
> 
> > mmmK,
> >
> > i have figured it out,
> > anyone want it?
> > lemme know
> >
> > olinux
> >
> >
> > - Original Message -
> > From: "olinux" <[EMAIL PROTECTED]>
> > To: <[EMAIL PROTECTED]>
> > Cc: "PHP-DB" <[EMAIL PROTECTED]>
> > Sent: Saturday, March 24, 2001 4:27 PM
> > Subject: [PHP-DB] uploading files.
> >
> >
> > K, I am using a script i found at hotscripts.com
> > I need it to upload an image to server.
> > I think that my issue is that i need to use the stripslashes();
> somewhere,
> > but i don't know where
> >
> > anyways here tis:
> >
> >  >
> >  function do_upload($filename,$newname) {
> >   $file = basename($filename);
> >   $tmp_upload_path = "c:/program files/apache group/apache/htdocs";
> >   $new_file_name = "c:/program files/apache
> group/apache/htdocs".$newname;
> >  $file = stripslashes($file);
> >  $tmp_upload_path = stripslashes($tmp_upload_path);
> >  $new_file_name = stripslashes($new_file_name);
> >   if (!copy($tmp_upload_path.$file, $new_file_name)) echo "failed to
> copy
> > file\n";
> >   return;
> > }
> >
> > ?>
> >
> > and later i calll the function:
> >
> > 
> >
> > here the error i receive:
> > Warning: Unable to open 'c:/program files/apache
> group/apache/htdocsphp2'
> > for reading: No such file or directory in c:\program files\apache
> > group\apache\htdocs\uploads\2\upload_go.php on line 9
> >
> > and script returns this
> >   upload tmp file: \\php2
> >
> >
> > There is an article at phpbuilder called file uploading made easy
> > http://phpbuilder.com/columns/bealers2904.php3
> >
> > i am having the same issues with this script and though i found an
> answer to
> > the file://php2 thing [it was a stripslashes()  solution] I am
> getting an
> > error with this script that there is an unset variable... It looks
> set to me
> > :)
> >
> > puzzled,
> > olinux [who thanks you all greatly]
> >
> >
> >
> > _
> > Do You Yahoo!?
> > Get your free @yahoo.com address at http://mail.yahoo.com
> >
> >
> > --
> > PHP Database 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 Database 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 Database 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-DB] Multiple Order By

2001-03-25 Thread Januar R. Kramadibrata

Make it to:
select * from Blah where test='testing' order by field1, field2

One step further:
if you want field1 ascendingly ordered and field2 descendingly ordered, 
make it to:
select * from Blah where test='testing' order by field1 asc, field2 desc

Hope this help.

Warmest Regards,
Januar - Bandung, Indonesia.


At 10:49 PM 3/25/01 +0930, you wrote:
>Hi There,
>
>I have a situation that requires me to do a multiple orderby on a MYSQL /PHP
>query. ie
>
>select * from Blah where test='testing' order by field1 then by field2
>
>I am wondering if this will work or is there some other way I can acomplish
>such a task. The ordering should be decending.
>
>
>Thanks for any help on this.
>
>- Shannon
>
>
>
>
>
>
>--
>PHP Database 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 Database 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-DB] problem with writing date/time into db

2001-03-25 Thread JJeffman

You've  misplaced a "$date" variable instead of $datum, $date has no value .

HTH

Jayme.

-Mensagem Original-
De: Florian Poppele <[EMAIL PROTECTED]>
Para: <[EMAIL PROTECTED]>
Enviada em: domingo, 25 de março de 2001 10:26
Assunto: [PHP-DB] problem with writing date/time into db


> Just started with PHP. I'm trying to write a news post script. Somehow den
> actual date isn't written properly into the db. There's always '-00-00
> 00:00:00' saved into the db.
>
> my code:
>
> $datum = date("Y-m-d H:m:s");
>
> $sql = "INSERT INTO news (datum,tag,text,autor) VALUES
> ('$date','$tag','$text', '$autor')";
>
> If anyone can help, i'd be happy. Thanks.
>
>
> --
> PHP Database 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 Database 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-DB] Getting ages from dates

2001-03-25 Thread Matt Coyne

Hi

I'm new to PHP and would appreciate any assistance in this query.

I am creating a search facility that searches on personal details
(measurements, age etc) and returns relevant records.

I have no problem so far in returning records based on measurements like
chest, waist etc. My problem is returning and searching an age value when
the records hold Date of Birth values.

Can someone point me in the right direction for info pertaining to getting
values (the age) based on a fixed date (the date of birth) and the date when
the record is searched (eg today's date).

The way my search works at the moment is like this:
1. Enter values, click go.
2. Return matche(s) with ID, Name, Surname.
3. Select individual.
4. Return all details based on ID.

I want to be able to search by age and also return the age in the 'details'
section (4)

Also, would anyone recommend books for PHP and MySQL. I have run through
Julie Meloni's PHP Fast and Easy (thanks Julie) and want to get in deeper.

Any help/pointers appreciated

TIA
Matt Coyne

t  h  r  e  e  z  e  r  o :   :  :

the mill, millstone lane, leicester, le1 5jn
e : [EMAIL PROTECTED] ::  m : 07747 845690
w : http://www.threezero.co.uk

:   :  :t  h  r  e  e  z  e  r  o



-- 
PHP Database 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-DB] problem with writing date/time into db

2001-03-25 Thread Florian Poppele

Just started with PHP. I'm trying to write a news post script. Somehow den
actual date isn't written properly into the db. There's always '-00-00
00:00:00' saved into the db.

my code:

$datum = date("Y-m-d H:m:s");

$sql = "INSERT INTO news (datum,tag,text,autor) VALUES
('$date','$tag','$text', '$autor')";

If anyone can help, i'd be happy. Thanks.


-- 
PHP Database 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-DB] Multiple Order By

2001-03-25 Thread Shannon Doyle

Hi There,

I have a situation that requires me to do a multiple orderby on a MYSQL /PHP
query. ie

select * from Blah where test='testing' order by field1 then by field2

I am wondering if this will work or is there some other way I can acomplish
such a task. The ordering should be decending.


Thanks for any help on this.

- Shannon






-- 
PHP Database 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-DB] Date

2001-03-25 Thread Felix Kronlage

On Sun, Mar 25, 2001 at 03:02:21PM +0200, [EMAIL PROTECTED] wrote:
> I save the date in my MySQL db as 2001-03-25.
> But in my PHP script i want do see it like 25-03-2001.
> How do i get this result

if you can't modify the formart the date is safed as, you could
use split on the string that comes out of the database, to get
the values for day, month, year and then just put the string
in a differen order together:

There is an example here:

http://www.php.net/manual/en/function.split.php

-fkr
-- 
gpg-fingerprint: 076E 1E87 3E05 1C7F B1A0  8A48 0D31 9BD3 D9AC 74D0 
  |http://www.hazardous.org/ | whois -h whois.ripe.de FKR-RIPE  |
  |all your base are belong to us  |  shame on me  | fkr@IRCnet | 


--
PHP Database 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-DB] Date

2001-03-25 Thread [EMAIL PROTECTED]

Hello,

I save the date in my MySQL db as 2001-03-25.

But in my PHP script i want do see it like 25-03-2001.

How do i get this result

thx