php-general Digest 28 Dec 2003 07:55:28 -0000 Issue 2498

Topics (messages 173383 through 173393):

Re: How New Is <<<HERE?
        173383 by: stiano.optonline.net
        173384 by: Olwen Williams

Re: HELP! -- Problem with imagejpeg()
        173385 by: Al

Re: Regular Expression
        173386 by: Joshua

newbie mysql and php
        173387 by: tony
        173390 by: Brad Pauly

PHP5 XML functions
        173388 by: TopTenNut.aol.com

Printing out html
        173389 by: Labunski
        173391 by: Mike Brum

Re: stop file process
        173392 by: Jed R. Brubaker
        173393 by: Jed R. Brubaker

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 ---
Bingo!

Thanks, everyone! And thanks especially to Andrew! You were right: I needed
the action and method attributes. And then it does increment.

My last question on this episode: Why did it work before this for some of
you trying it out for me? I mean, the code is the code, right? And either
it's correct or it's not. How come it worked without these other attributes
for some of you?

Steve 

-----------------

It looks like your form tag is missing some attributes needed to point
your browser to the script as to where to submit the data.

if you were to try with your form tag as <form
action="___SCRIPT_ITSELF_FILENAME___" method="post"> ??

Andrew.

--------------------------------------------------------------------
mail2web - Check your email from the web at
http://mail2web.com/ .

--- End Message ---
--- Begin Message --- It incrementeted for me only after I changed $_POST to $_GET, but never gave errors.

[EMAIL PROTECTED] wrote:

Bingo!

Thanks, everyone! And thanks especially to Andrew! You were right: I needed
the action and method attributes. And then it does increment.

My last question on this episode: Why did it work before this for some of
you trying it out for me? I mean, the code is the code, right? And either
it's correct or it's not. How come it worked without these other attributes
for some of you?

Steve

-----------------

It looks like your form tag is missing some attributes needed to point
your browser to the script as to where to submit the data.

if you were to try with your form tag as <form
action="___SCRIPT_ITSELF_FILENAME___" method="post"> ??

Andrew.

--------------------------------------------------------------------
mail2web - Check your email from the web at
http://mail2web.com/ .


--
Olwen Williams
See my B&B site
http://www.bandbclub.com
and my new site http://www.handyman.co.nz - A virtual shed for real kiwi blokes.

--- End Message ---
--- Begin Message --- Here is a complete function I wrote a few months ago. It should do it for you or give you hints for fixing your problem.

René fournier wrote:

Hello,

I have a function that is meant to check if an image is greater than
a certain width and height, and if it is, downsample it. The checking
part works fine. Downsampling is not happening though. Here's what I've got
(btw, $file = "/somedirectory/photo.jpg"):


$src_img=imagecreatefromJPEG($file); $dst_img=imagecreatetruecolor($new_width,$new_height);
imagecopyresampled($dst_img,$src_img,0,0,0,0,$new_width,$new_height,$siz e[0],$size[1]);
imagejpeg($dst_img,$file,$img_quality);


Any ideas?

Thanks.

...Rene

<?php
/**
 * Resize an image to a new width.  Original image portion is maintained.
 * 
 * Has two modes: 
*  
* $auto == "yes,  looks at $_FILES['username']['error'] to determine if a file was just uploaded. 
* If so, it gets the file name from $_FILES	and uses $file_location for the path, relative
* to the route.
* 
*  Or else, it uses the file $file_location, which must be the full path, relative to the route.  
*   
 * image resizer arguments:
 * $resize_args= array("quality" => 100, "new_width" => 200, "quality" =>100, "backup_org" => "no");
 * 
 *       quality = percent [e.g. "quality" => 90] meaning 90%
 *       width = pixels [e.g., "new_width" => 200] i.e., 200 pixels.
 *       backup_org [original file] "yes" or "no".  "no" is the default
 * 
 * Use this to fetch $resize_stats:
 * 		foreach($resize_stats as $key => $value)
 * {
 * echo $key . " = " . $value;
 * }
 */


function resize_width($file_location, $resize_args, $auto)
{
    global $DOCUMENT_ROOT;

    if (empty($resize_args)) die("<p style=\"color:red\">Code error, argument(s) in \$resize_arg missing in resize_width. </p> ");

	if($auto== "yes"){

		if ($_FILES['username']['error'] == 0) {
	        
			$name = key($_FILES); 							//could use the register variables, but this is safer.
			
	        $org_img = $_FILES[$name]['name'];
	
	        $org_img = filename_fixer($org_img);
			
			$org_img = $file_location . $org_img;
		}
	}
	else{$org_img = $file_location;}
	
    if ($resize_args['backup_org'] == "yes") {
        file_backup($org_img);
    } 

    $org_img = $DOCUMENT_ROOT . $org_img;
	
	if (!file_exists($org_img))die("<p style=\"color:red\">Code error, $org_img missing or incorrect file name in resize_width()</p> </body></html>");

    $new_width = $resize_args['new_width'];
    $quality = $resize_args['quality'];

    $imagehw = GetImageSize($org_img);
    $org_width = $imagehw[0];
    $org_height = $imagehw[1];

    if ($new_width !== $org_width) {
        $imagevsize = $org_height * $new_width / $org_width;
        $new_height = ceil($imagevsize);

        $src_img = imagecreatefromjpeg($org_img);
        $dest_img = imagecreatetruecolor($new_width, $new_height);
        imagecopyresampled($dest_img, $src_img, 0, 0, 0, 0, $new_width, $new_height, $org_width, $org_height);
        imagejpeg($dest_img, $org_img, $quality);
        imagedestroy($src_img);
        imagedestroy($dest_img);
    } else {
        $newheight = $org_height;
    } 
    // see above how to use array
    $resize_stats = array("Orginal width" => $org_width, "Orginal height" => $org_height, "New width" => $new_width, "New height" => $new_height);

    if ($resize_args['show_stats'] == "yes") {
        foreach($resize_stats as $key => $value) {
            echo $key . " = " . $value . "<br>\r\n";
        } 
    } 

    return $resize_stats;
} 


?>

--- End Message ---
--- Begin Message ---
Thank you!! It worked!!

The wrong sample was 'dot'11'dot'abcd, but
the first dot was not shown properly...

And, now I have another problem:
In fact, the input strings are lines from a webpage, and
they sometimes have line-feed as in:

11.abcd.32.efgh.54.ij <--here
kh.41.lmno. <--here
63.pqrs

And, with ereg_replace("(\.)([0-9])","\\1<br><br>\\2",$string),
 the result I expect is:

 11.abcd.

32.efgh.

54.ijkh.

41.lmno.

63.pqrs.

But, the actual result is:

11.abcd.

32.efgh.

54.ij <-- problem
kh.

41.lmno.
63.pqrs. <-- problem

I tried some more regular expressions to solve this, but
they don work yet.
So, please help me~~

Thank you in advance.

Joshua

----- Original Message -----
From: "Kelly Hallman" <[EMAIL PROTECTED]>
To: "Joshua" <[EMAIL PROTECTED]>
Cc: "PHP General list" <[EMAIL PROTECTED]>
Sent: Saturday, December 27, 2003 1:27 PM
Subject: Re: [PHP] Regular Expression


> On Sat, 27 Dec 2003, Joshua wrote:
> > I'm trying to change the string, for example,
> >
> > $string = "11.abcd.32.efgh.53.ijk";
> > to
> >
> > 11.abcd.
> > 32.efgh.
> > 53.ijk.
> >
> > with ereg_replace. Like
> > ereg_replace("\.[0-9]","<BR>",$string);
> > How can I recover the original characters after replacing them with <BR>
> > in ereg_replace?
> >
> > ereg_replace("\.[0-9]","<BR>\\0",$string) gives me the
> > wrong result like:
> >
> > 11.abcd.
> > 32.efgh.
> > 53.ijk.
>
> Since the output you want and the output you didn't want are identical in
> your post, it was hard to tell what you were trying to do, but...
>
> I think this is what you want..
> ereg_replace("(\.)([0-9])","\\1<br>\\2",$string);
> (minus the last decimal point, missing from your original string)
>
> --
> Kelly Hallman
> // Ultrafancy
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message ---
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 ---
On Sat, 2003-12-27 at 17:17, tony wrote:
> 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

Try checking your query results. mysql_query might return false which is
not a valid result.

$dbdo = mysql_query($query, $dbconnect)
        or die(mysql_error());

That should let you know what is going on.

- Brad

--- End Message ---
--- Begin Message ---
I've just gotten PHP5 B3 working using the precompiled binaries under Win XP, 
but the dom xml functions of PHP4 don't seem to be immediately available.  
Does anyone have suggestions on how to learn to use the new XML functionality?  
The source code?

Greg Steffenson

--- End Message ---
--- Begin Message ---
Hello, I have just entered PHP "world" and I have many questions. I have
already made PHP script that send's htm form values via e-mail.
Now I want to build PHP based web page..

>> 1.question>>
For example I have index.php file, but I want HTML (index.html) file to be
"printed out". How php code should look like?

>> 2.question >>
I know that code for IP address ($ip) is:
  $ip = getenv ("REMOTE_ADDR");

For example I have Index.php file, and I want an IP adders to be viewed in
the TD:

<td> IP address </td>

How should I write it?


Sorry for my dumb questions and bad english,
Regards,
Lab.

--- End Message ---
--- Begin Message ---
1. if you have index.php, then just get rid of index.html and print your
content via print or echo statements. 

2. 

$ip = getenv("REMOTE_ADDR"); 
print "<td>IP Address: " . $ip . "</td>";

(there's a few ways you can do that - this is just the standard I use)

Regards

-M

-----Original Message-----
From: Labunski [mailto:[EMAIL PROTECTED] 
Sent: Saturday, December 27, 2003 9:47 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Printing out html

Hello, I have just entered PHP "world" and I have many questions. I have
already made PHP script that send's htm form values via e-mail.
Now I want to build PHP based web page..

>> 1.question>>
For example I have index.php file, but I want HTML (index.html) file to be
"printed out". How php code should look like?

>> 2.question >>
I know that code for IP address ($ip) is:
  $ip = getenv ("REMOTE_ADDR");

For example I have Index.php file, and I want an IP adders to be viewed in
the TD:

<td> IP address </td>

How should I write it?


Sorry for my dumb questions and bad english, Regards, Lab.

--
PHP General Mailing List (http://www.php.net/) To unsubscribe, visit:
http://www.php.net/unsub.php

--- End Message ---
--- Begin Message ---
This one should be simple.

I am wondering if there is a simple way in which to stop the processing of a
file.

The current example is a program that checks to see if the user is logged
in. In the past I have done something like this:

if ($loggedIn != true) {
    echo "You are not logged in.";
}
else {
    echo "Welcome";
}

This, however, becomes a substantial problem (or at least annoyance) when
the else is pages long. I would prefer to have something like:

if ($loggedIn != true) {
    echo "You're not logged in.";
    // stop process of file here
}
// Page content (with no else)

The ultimate objective is to have a simple function in the my class include
file to verify that the user is always logged in.

Thanks in advance.

--- End Message ---
--- Begin Message ---
Found it!

Just use exit();


"Jed R. Brubaker" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> This one should be simple.
>
> I am wondering if there is a simple way in which to stop the processing of
a
> file.
>
> The current example is a program that checks to see if the user is logged
> in. In the past I have done something like this:
>
> if ($loggedIn != true) {
>     echo "You are not logged in.";
> }
> else {
>     echo "Welcome";
> }
>
> This, however, becomes a substantial problem (or at least annoyance) when
> the else is pages long. I would prefer to have something like:
>
> if ($loggedIn != true) {
>     echo "You're not logged in.";
>     // stop process of file here
> }
> // Page content (with no else)
>
> The ultimate objective is to have a simple function in the my class
include
> file to verify that the user is always logged in.
>
> Thanks in advance.

--- End Message ---

Reply via email to