php-general Digest 13 Dec 2010 19:59:11 -0000 Issue 7085
Topics (messages 310000 through 310006):
Re: Scalable Vector Graphics with PHP
310000 by: Nathan Rixham
empty() in email message
310001 by: Gary
310002 by: Bastien Koert
310003 by: [email protected]
310004 by: Paul M Foster
310005 by: Daniel P. Brown
array_multisort into Natural order?
310006 by: George Langley
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 ---
disclaimer: a different nathan
You may also be interested in protovis, and raphael, both of which are
js libraries which make, or export, svg graphics :)
Best,
Nathan
sudarshana sampath wrote:
Nathan, Thank you very much for your response, we are going to visualize
network management system(topolgy view) with SVG and AJAX.
We found a jQuery plugin, following are urls.
http://plugins.jquery.com/project/svg
http://keith-wood.name/svg.html
On Thu, Dec 9, 2010 at 10:50 PM, Nathan Nobbe <[email protected]>wrote:
On Thu, Dec 9, 2010 at 4:55 AM, sudarshana sampath <
[email protected]> wrote:
Hi,
We are going add a topology view to our Network Management System.
Our Network Management System is based on PHP, CakePHP, jQuery and other
web
related tools(middle tier written using C++).
So we are going to work with Scalable Vector Graphics.
We are looking for the best solution for doing that.
Are there any extensions, plugins, frameworks available for SVG related
things ?
not sure exactly what youre trying to accomplish, but obviously you could
use any number of vector programs over the cli from php.
you might also have a peak at the cairo library which php allegedly
supports (ive never tried it myself).
http://us.php.net/manual/en/intro.cairo.php
-nathan
--- End Message ---
--- Begin Message ---
I have an email message
$msg = 'Name: $fname ' . ' $lname\n'
. "Phone: $phone\n"
. "Email: $email\n"
and it works fine, however in this message there are about 30 variables that
are being called...as such
. "Order: beefschnitzel $beefschnitzel\n"
. "Order: beefstrips $beefstrips\n"
. "Order: cheesesausage $cheesesausage\n"
. "Order: crumbedsausage $crumbedsausage\n"
. "Order: chucksteak $chucksteak\n"
. "Order: cornedbeef $cornedbeef\n"
. "Order: dicedsteak $dicedsteak\n"
. "Order: filletmignon $filletmignon\n"
I want to only send the message if the submitter enters an amount in the
form for the corresponding variable, instead of having a bunch of empty
messages. So I have been trying to use the empty() function as such:
. if empty($beefolives){''} elseif (isset($beefolives)) { 'Order: beefolives
$beefolives\n'}
But I am getting the error
Parse error: syntax error, unexpected T_IF
Can someone point me in the right direction?
Thank you
--
Gary
__________ Information from ESET Smart Security, version of virus signature
database 5699 (20101213) __________
The message was checked by ESET Smart Security.
http://www.eset.com
--- End Message ---
--- Begin Message ---
On Mon, Dec 13, 2010 at 12:47 PM, Gary <[email protected]> wrote:
> I have an email message
>
> $msg = 'Name: $fname ' . ' $lname\n'
> . "Phone: $phone\n"
> . "Email: $email\n"
>
> and it works fine, however in this message there are about 30 variables that
> are being called...as such
>
> . "Order: beefschnitzel $beefschnitzel\n"
> . "Order: beefstrips $beefstrips\n"
> . "Order: cheesesausage $cheesesausage\n"
> . "Order: crumbedsausage $crumbedsausage\n"
> . "Order: chucksteak $chucksteak\n"
> . "Order: cornedbeef $cornedbeef\n"
> . "Order: dicedsteak $dicedsteak\n"
> . "Order: filletmignon $filletmignon\n"
>
> I want to only send the message if the submitter enters an amount in the
> form for the corresponding variable, instead of having a bunch of empty
> messages. So I have been trying to use the empty() function as such:
>
> . if empty($beefolives){''} elseif (isset($beefolives)) { 'Order: beefolives
> $beefolives\n'}
>
> But I am getting the error
>
> Parse error: syntax error, unexpected T_IF
>
> Can someone point me in the right direction?
>
> Thank you
> --
> Gary
>
>
>
> __________ Information from ESET Smart Security, version of virus signature
> database 5699 (20101213) __________
>
> The message was checked by ESET Smart Security.
>
> http://www.eset.com
>
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
Less complication is better, reduce the code to the below. The empty
portion needs to be inside the parentheses. Also double quotes are
needed to make the vairable parse correctly into the value you want to
see
if (!empty($beefolives)) { echo "Order: beefolives $beefolives\n";}
--
Bastien
Cat, the other other white meat
--- End Message ---
--- Begin Message ---
How are these variables being given their values by php? If you're making use
of register_globals then you're asking for problems.
Perform some sanity checks on your data, like using a regex of /^\d+$/ to check
for numerical values, and turn globals off; its a security breach waiting to
happen.
Get the values from $_GET or $_POST and treat each one as malicious until you
know its within the bounds of your application as a real value.
Thanks,
Ash
http://www.ashleysheridan.co.uk
----- Reply message -----
From: "Gary" <[email protected]>
Date: Mon, Dec 13, 2010 17:47
Subject: [PHP] empty() in email message
To: <[email protected]>
I have an email message
$msg = 'Name: $fname ' . ' $lname\n'
. "Phone: $phone\n"
. "Email: $email\n"
and it works fine, however in this message there are about 30 variables that
are being called...as such
. "Order: beefschnitzel $beefschnitzel\n"
. "Order: beefstrips $beefstrips\n"
. "Order: cheesesausage $cheesesausage\n"
. "Order: crumbedsausage $crumbedsausage\n"
. "Order: chucksteak $chucksteak\n"
. "Order: cornedbeef $cornedbeef\n"
. "Order: dicedsteak $dicedsteak\n"
. "Order: filletmignon $filletmignon\n"
I want to only send the message if the submitter enters an amount in the
form for the corresponding variable, instead of having a bunch of empty
messages. So I have been trying to use the empty() function as such:
. if empty($beefolives){''} elseif (isset($beefolives)) { 'Order: beefolives
$beefolives\n'}
But I am getting the error
Parse error: syntax error, unexpected T_IF
Can someone point me in the right direction?
Thank you
--
Gary
__________ Information from ESET Smart Security, version of virus signature
database 5699 (20101213) __________
The message was checked by ESET Smart Security.
http://www.eset.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
On Mon, Dec 13, 2010 at 12:47:49PM -0500, Gary wrote:
> I have an email message
>
> $msg = 'Name: $fname ' . ' $lname\n'
> . "Phone: $phone\n"
> . "Email: $email\n"
>
> and it works fine, however in this message there are about 30 variables that
> are being called...as such
>
> . "Order: beefschnitzel $beefschnitzel\n"
> . "Order: beefstrips $beefstrips\n"
> . "Order: cheesesausage $cheesesausage\n"
> . "Order: crumbedsausage $crumbedsausage\n"
> . "Order: chucksteak $chucksteak\n"
> . "Order: cornedbeef $cornedbeef\n"
> . "Order: dicedsteak $dicedsteak\n"
> . "Order: filletmignon $filletmignon\n"
>
> I want to only send the message if the submitter enters an amount in the
> form for the corresponding variable, instead of having a bunch of empty
> messages. So I have been trying to use the empty() function as such:
>
> . if empty($beefolives){''} elseif (isset($beefolives)) { 'Order: beefolives
> $beefolives\n'}
>
> But I am getting the error
>
> Parse error: syntax error, unexpected T_IF
>
> Can someone point me in the right direction?
It looks like you're trying to do something like:
$str = 'something' .
if ($somethingelse)
'another string'
else
'a different string';
For one thing, you can't put a conditional on the right side of a
concatenation mark (.). You'd have to do it this way:
$str = 'something';
if ($somethingelse) {
$str .= 'another string';
}
else {
$str .= 'a different string';
}
You also can't do:
elseif (isset($beefolives)) {
'Order: beefolives $beefolives\n';
}
For one thing, surrounding the 'Order...' line with single quotes will
cause the \n *not* to be interpreted as a newline. Second, your 'Order:
beefolives...' does nothing. You haven't assigned it to anything or
operated on that string in any way.
You might want to study up on single versus double quotes, the
concatenation operator (.), etc.
Paul
--
Paul M. Foster
--- End Message ---
--- Begin Message ---
On Mon, Dec 13, 2010 at 12:47, Gary <[email protected]> wrote:
> I have an email message
>
> $msg = 'Name: $fname ' . ' $lname\n'
> . "Phone: $phone\n"
> . "Email: $email\n"
>
> and it works fine, however in this message there are about 30 variables that
> are being called...as such
>
> . "Order: beefschnitzel $beefschnitzel\n"
> . "Order: beefstrips $beefstrips\n"
> . "Order: cheesesausage $cheesesausage\n"
> . "Order: crumbedsausage $crumbedsausage\n"
> . "Order: chucksteak $chucksteak\n"
> . "Order: cornedbeef $cornedbeef\n"
> . "Order: dicedsteak $dicedsteak\n"
> . "Order: filletmignon $filletmignon\n"
>
> I want to only send the message if the submitter enters an amount in the
> form for the corresponding variable, instead of having a bunch of empty
> messages. So I have been trying to use the empty() function as such:
>
> . if empty($beefolives){''} elseif (isset($beefolives)) { 'Order: beefolives
> $beefolives\n'}
>
> But I am getting the error
>
> Parse error: syntax error, unexpected T_IF
>
> Can someone point me in the right direction?
That's because you're concatenating. When appending to a
variable, you can't use constructs and conditions, unless using
ternaries:
. (!empty($beefolives) && is_numeric($beefolives) ? 'Order: beefolives
'.$beefolives : null)
However, for readability and ease of management, you might want to
try something like this. It makes at least two assumptions: you're
using a form post, and you understand that it's untested (as I'm just
typing it here into the body of this email).
<?php
// If we've posted our order
if (isset($_POST) && is_array($_POST['order'])) {
// Instantiate the $order variable
$order = null;
// Iterate the order quantities
foreach ($_POST['order'] as $k => $v) {
// If the field is set and the amount is a number
if (isset($v) && is_numeric($v)) {
$order .= 'Order: '.$k.': '.$v.PHP_EOL;
}
}
/**
* Note: in your example, you used single (literal)
* quotes and included the variables. That would
* literally print $fname and $lname.
*/
$msg = 'Name: '.$_POST['fname'].' '.$_POST['lname'].PHP_EOL;
$msg .= 'Phone: '.$_POST['phone'].PHP_EOL;
$msg .= 'Email: '.$_POST['email'].PHP_EOL;
$msg .= PHP_EOL;
$msg .= $order;
// And then handle the rest of your processing. Here, we just echo.
echo '<pre>'.PHP_EOL.$msg.'</pre>'.PHP_EOL;
}
?>
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
First Name: <input type="text" name="fname" id="fname"><br/>
Last Name: <input type="text" name="lname" id="lname"><br/>
Phone: <input type="text" name="phone" id="phone"><br/>
Email: <input type="text" name="email" id="email"><br/>
<br />
<h3>Order</h3>
Beef Schnitzel: <input type="text" name="order[beefschnitzel]"
id="order[beefschnitzel]" size="2" maxlength="3"><br/>
Beef Strips: <input type="text" name="order[beefstrips]"
id="order[beefstrips]" size="2" maxlength="3"><br/>
Cheese Sausage: <input type="text" name="order[cheesesausage]"
id="order[cheesesausage]" size="2" maxlength="3"><br/>
Crumbed Sausage: <input type="text" name="order[crumbedsausage]"
id="order[crumbedsausage]" size="2" maxlength="3"><br/>
Chuck Steak: <input type="text" name="order[chucksteak]"
id="order[chucksteak]" size="2" maxlength="3"><br/>
Corned Beef: <input type="text" name="order[cornedbeef]"
id="order[cornedbeef]" size="2" maxlength="3"><br/>
Diced Steak: <input type="text" name="order[dicedsteak]"
id="order[dicedsteak]" size="2" maxlength="3"><br/>
Filet Mignon: <input type="text" name="order[filletmignon]"
id="order[filletmignon]" size="2" maxlength="3"><br/>
<!-- NOTE: "Filet" as displayed on the form has one 'L', but the
variable is unchanged. -->
<br />
<input type="submit" value="Order Now">
</form>
--
</Daniel P. Brown>
Dedicated Servers, Cloud and Cloud Hybrid Solutions, VPS, Hosting
(866-) 725-4321
http://www.parasane.net/
--- End Message ---
--- Begin Message ---
Hi all. Can use natsort($array1) to sort a single array of filenames into a
"natural "alphanumeric order - 1.php, 2.php, 5.php, 10.php, 20.php, etc.
But using array_multisort($array1, $array2, $array3) doesn't offer a natsort
option, so I end up with 1.php, 10.php, 2.php, 20.php, 5.php, etc.
Anyone have a solution to this limitation already? Nothing found in the
archives or Googling.
Thanks.
George Langley Multimedia Developer Audio/Video Editor Musician,
Arranger, Composer www.georgelangley.ca
--- End Message ---