Re: [PHP-DB] echo into variable or the like

2012-08-21 Thread Karl DeSaulniers


On Aug 21, 2012, at 12:35 AM, s@optusnet.com.au wrote:

yeah, I am thinking I should make that a function and call it from a  
variable.

what do you think? I think I need a php.net 'arrays for dummies'.



Sean Williams
T: 0416 628 967 E: sm...@optusnet.com.au
Skype: seanw78
-Original Message- From: Karl DeSaulniers
Sent: Tuesday, August 21, 2012 2:22 PM
To: php-db@lists.php.net
Subject: Re: [PHP-DB] echo into variable or the like

You echo to the page not to a variable.

php.net is your friend.

:)

GL


On Aug 20, 2012, at 11:01 PM, s@optusnet.com.au s@optusnet.com.au

wrote:


Hi, this is my first post so forgive me if I missed a rule and do  
something wrong.


I have this code,

echo $_SERVER['PHP_SELF'].?;
foreach ($_GET as $urlvar=$urlval)
echo $urlvar.=.$urlval.;

It works by it’s self.
I want to insert the output in a table.  Is there a way to ‘echo’   
into a variable(i.e. make the output of this echo the value of a   
variable) or am I on the wrong track all together?


Karl DeSaulniers
Design Drumm
http://designdrumm.com


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


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





Na just go to php.net and do a search.
Look up -

foreach()

There are examples to learn from php.net and other users there.
May not be a copy and paste job, you'll most likely want to adopt  
things to your
situation, but the fundamentals are all there. Best way/place to learn  
IMO.


Then I would go and google MySQL INSERT or what ever SQL Lang your  
using.

Again, I would go to the php.net link that pops up. :)
Those two things should get you on track for what it looks like your  
trying to do.


if your not there after those two things, look up
array() php

and so on...

..but your not far off with what you have, you just need to swap a  
$var = with the echo text looks like.
Then use $var in your INSERT statement like so. $sql = INSERT     
(var, ... )  Value( '.mysql_real_escape_string($var).',  );
The single quotes are only needed for strings too. For variables that  
are integers (numbers), you don't need them.


You may also want to go ahead and look into how to set up your mysql- 
php scripts with mysqli as well. Like using  
mysqli_real_escape_string() instead.
I think mysql_ is getting depreciated. Instead of learning one way and  
then finding out you have to migrate later. :-/


Please correct me if I am wrong anyone.

HTH,

Best,

Karl DeSaulniers
Design Drumm
http://designdrumm.com


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



Re: [PHP-DB] echo into variable or the like

2012-08-21 Thread Daniel Brown
On Tue, Aug 21, 2012 at 12:01 AM,  s@optusnet.com.au wrote:
 Hi, this is my first post so forgive me if I missed a rule and do something 
 wrong.

 I have this code,

 echo $_SERVER['PHP_SELF'].?;
 foreach ($_GET as $urlvar=$urlval)
 echo $urlvar.=.$urlval.;

 It works by it’s self.
 I want to insert the output in a table.  Is there a way to ‘echo’ into a 
 variable(i.e. make the output of this echo the value of a variable) or am I 
 on the wrong track all together?

This question actually belongs on the PHP General mailing list.

As for echoing into a variable, the only way that's really
possible is with output buffering (ob_start(), ob_get_contents(),
ob_end_clean(), et al).  However, you don't need (and shouldn't want)
to do this here.  Instead, as your snippet really won't do much of
anything useful, you should (entirely) rewrite your code to look
something like this, for an HTML table:

?php
echo $_SERVER['PHP_SELF'].'?'.PHP_EOL;
echo 'table'.PHP_EOL;
foreach ($_GET as $key = $value) {
echo ' tr'.PHP_EOL;
echo '  td'.$key.'/td'.PHP_EOL;
echo '  td'.$value.'/td'.PHP_EOL;
echo ' /tr'.PHP_EOL;
}
echo '/table';
?

However, since it looks almost as if you're trying to build a
query string based upon the supplied GET variables, you may want to
try looking into http_build_query().

-- 
/Daniel P. Brown
Network Infrastructure Manager
http://www.php.net/

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



[PHP-DB] echo into variable or the like

2012-08-20 Thread s.dev
Hi, this is my first post so forgive me if I missed a rule and do something 
wrong.

I have this code,

echo $_SERVER['PHP_SELF'].?;
foreach ($_GET as $urlvar=$urlval)
echo $urlvar.=.$urlval.;

It works by it’s self. 
I want to insert the output in a table.  Is there a way to ‘echo’ into a 
variable(i.e. make the output of this echo the value of a variable) or am I on 
the wrong track all together?


Re: [PHP-DB] echo into variable or the like

2012-08-20 Thread Karl DeSaulniers

You echo to the page not to a variable.

php.net is your friend.

:)

GL


On Aug 20, 2012, at 11:01 PM, s@optusnet.com.au s@optusnet.com.au 
 wrote:


Hi, this is my first post so forgive me if I missed a rule and do  
something wrong.


I have this code,

echo $_SERVER['PHP_SELF'].?;
foreach ($_GET as $urlvar=$urlval)
echo $urlvar.=.$urlval.;

It works by it’s self.
I want to insert the output in a table.  Is there a way to ‘echo’  
into a variable(i.e. make the output of this echo the value of a  
variable) or am I on the wrong track all together?


Karl DeSaulniers
Design Drumm
http://designdrumm.com


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



Re: [PHP-DB] echo into variable or the like

2012-08-20 Thread s.dev
yeah, I am thinking I should make that a function and call it from a 
variable.

what do you think? I think I need a php.net 'arrays for dummies'.



Sean Williams
T: 0416 628 967 E: sm...@optusnet.com.au
Skype: seanw78
-Original Message- 
From: Karl DeSaulniers

Sent: Tuesday, August 21, 2012 2:22 PM
To: php-db@lists.php.net
Subject: Re: [PHP-DB] echo into variable or the like

You echo to the page not to a variable.

php.net is your friend.

:)

GL


On Aug 20, 2012, at 11:01 PM, s@optusnet.com.au s@optusnet.com.au

wrote:


Hi, this is my first post so forgive me if I missed a rule and do 
something wrong.


I have this code,

echo $_SERVER['PHP_SELF'].?;
foreach ($_GET as $urlvar=$urlval)
echo $urlvar.=.$urlval.;

It works by it’s self.
I want to insert the output in a table.  Is there a way to ‘echo’  into a 
variable(i.e. make the output of this echo the value of a  variable) or am 
I on the wrong track all together?


Karl DeSaulniers
Design Drumm
http://designdrumm.com


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


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