[PHP-DB] Re: Newbie Question $2

2014-06-17 Thread Jim Giner
We're all so eager to help out poor Ethan (who many of you know is NOT a 
newbie) but nowhere does Ethan say what difficulty he is having.


The suggestions made so far are great but what are we solving?

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



[PHP-DB] Re: Newbie Question $2

2014-06-17 Thread Jim Giner

Finally figured out what the question was!

Here's a better version of your code Ethan:

$phn = $_POST['phone']; // note the quotes on the index
if (strlen($phn)  10)
{
echo Error in phone number entry - must be 10 digits;
exit();
}
$phn = mysqli_real_escape_string($cxn,$phn);
$masked_phone = substr($phn,0,3) . -.substr($phn,3,3). -. 
substr($phn,6,4);
$sql1 = select Lname, Fname from Customers where Phone = 
'$masked_phone';	// note use of diff quotes

$result1 = mysqli_query($cxn, $sql1);
if (mysqli_num_rows($result1) == 0)
{
echo Phone number $masked_phone not on file;
exit();
}
else
{
	echo Found {$result1['Fname']} {$result1['Lname']} is on file with 
number $masked_phone;

exit();
}


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



Re: [PHP-DB] Re: Newbie Question $2

2014-06-17 Thread Lester Caine
On 17/06/14 15:04, Jim Giner wrote:
 We're all so eager to help out poor Ethan (who many of you know is NOT a
 newbie) but nowhere does Ethan say what difficulty he is having.
 
 The suggestions made so far are great but what are we solving?
I see you have spotted the original question :)
The original post was fairly complete in what it was asking, and the
answers reasonably worded ...

-- 
Lester Caine - G8HFL
-
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk
Rainbow Digital Media - http://rainbowdigitalmedia.co.uk

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



Re: [PHP-DB] Re: Newbie Question $2

2014-06-17 Thread Jim Giner

On 6/17/2014 10:51 AM, Lester Caine wrote:

On 17/06/14 15:04, Jim Giner wrote:

We're all so eager to help out poor Ethan (who many of you know is NOT a
newbie) but nowhere does Ethan say what difficulty he is having.

The suggestions made so far are great but what are we solving?

I see you have spotted the original question :)
The original post was fairly complete in what it was asking, and the
answers reasonably worded ...

Yeah - I just didn't take Ethan's comment as 'his question' since a) it 
didn't even have a ? mark on it and b) his spelling of his phn vars was 
crisscrossed re: the usage in the query statement.  I knew people were 
seeing something I wasn't - just didn't realize that the question itself 
was a puzzle of sorts.


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



Re: [PHP-DB] Re: Newbie Question $2

2014-06-17 Thread Aziz Saleh
IMO a newbie is someone who read the docs and understood them (at least in
theory) before they attempt to write code, which doesn't seem to be the
case.


On Tue, Jun 17, 2014 at 10:04 AM, Jim Giner jim.gi...@albanyhandball.com
wrote:

 We're all so eager to help out poor Ethan (who many of you know is NOT a
 newbie) but nowhere does Ethan say what difficulty he is having.

 The suggestions made so far are great but what are we solving?


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




[PHP-DB] Re: newbie question on PHP Mysql...

2005-09-22 Thread Evert Meulie

Thanks!  :-)

Your solution gives me exactly what I need!


Regards,
Evert



Ziv Gabel wrote:

Try This
$result = mysql_query(SELECT SUM(AcctInputOctets),SUM(AcctOutputOctets) 
FROM radacct WHERE username = '$argv[1]' );


this will make sure that even if $arg[1] is empty it still get '' 
(empty) as part of the query



- Original Message - From: Sylvain Gourvil 
[EMAIL PROTECTED]

To: php-db@lists.php.net
Sent: Wednesday, September 21, 2005 3:26 PM
Subject: [PHP-DB] Re: newbie question on PHP  Mysql...



Evert Meulie wrote:


Hi!

I've tried your suggestions, but still get the same error message. 
The 'print_r($result);' that I added does not print anything, so that 
would explain why I get the errors.


My idea is to call this script with a value, like:
script.php value

Doesn't that put the value in $argv[1] ?


Regards,
Evert


What do you use to execute your php scripts.

Php on linux ssh ?
Apache ?

call your script with script.php?var=value to get your value in 
$_GET['var']


But even if your args are emptied, it should return an error in your 
$result !









Unnawut Leepaisalsuwanna wrote:


Hi,

I guess you used a single quote over the query so the text, $argv[1],
was entered into the query rather than the value inside it.

try:

$result = mysql_query('SELECT SUM(AcctInputOctets),
SUM(AcctOutputOctets)  FROM radacct WHERE username = ' .$argv[1] );

OR

$result = mysql_query(SELECT SUM(AcctInputOctets),
SUM(AcctOutputOctets)  FROM radacct WHERE username = $argv[1]);

should do the trick

21nu

Sylvain Gourvil wrote:



Hi !

Could you do a print_r($result) after your mysql_query ?

Or you sure of your argv[1] ?

Sylvain Gourvil

Evert Meulie wrote:



Hi all!

I'm taking my first steps with PHP  MySQL.

Can anyone give me a hint on why this would not work?

*

$result = mysql_query('SELECT SUM(AcctInputOctets),
SUM(AcctOutputOctets)  FROM radacct WHERE username = $argv[1] ');
echo mysql_result($result,0), \n;
echo mysql_result($result,0,1);

*


I get: Warning: mysql_result(): supplied argument is not a valid
MySQL result resource



Regards,
   Evert









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



 


This footnote confirms that this email message has been scanned by
PineApp Mail-SeCure for the presence of malicious code, vandals  
computer viruses.
 








 


This footnote confirms that this email message has been scanned by
PineApp Mail-SeCure for the presence of malicious code, vandals  
computer viruses.
 





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



[PHP-DB] Re: newbie question on PHP Mysql...

2005-09-21 Thread Sylvain Gourvil

Hi !

Could you do a print_r($result) after your mysql_query ?

Or you sure of your argv[1] ?

Sylvain Gourvil

Evert Meulie wrote:

Hi all!

I'm taking my first steps with PHP  MySQL.

Can anyone give me a hint on why this would not work?

*

$result = mysql_query('SELECT SUM(AcctInputOctets), 
SUM(AcctOutputOctets)  FROM radacct WHERE username = $argv[1] ');

echo mysql_result($result,0), \n;
echo mysql_result($result,0,1);

*


I get: Warning: mysql_result(): supplied argument is not a valid MySQL 
result resource




Regards,
Evert


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



Re: [PHP-DB] Re: newbie question on PHP Mysql...

2005-09-21 Thread Unnawut Leepaisalsuwanna
Hi,

I guess you used a single quote over the query so the text, $argv[1],
was entered into the query rather than the value inside it.

try:

$result = mysql_query('SELECT SUM(AcctInputOctets),
SUM(AcctOutputOctets)  FROM radacct WHERE username = ' .$argv[1] );

OR

$result = mysql_query(SELECT SUM(AcctInputOctets),
SUM(AcctOutputOctets)  FROM radacct WHERE username = $argv[1]);

should do the trick

21nu

Sylvain Gourvil wrote:

 Hi !

 Could you do a print_r($result) after your mysql_query ?

 Or you sure of your argv[1] ?

 Sylvain Gourvil

 Evert Meulie wrote:

 Hi all!

 I'm taking my first steps with PHP  MySQL.

 Can anyone give me a hint on why this would not work?

 *

 $result = mysql_query('SELECT SUM(AcctInputOctets),
 SUM(AcctOutputOctets)  FROM radacct WHERE username = $argv[1] ');
 echo mysql_result($result,0), \n;
 echo mysql_result($result,0,1);

 *


 I get: Warning: mysql_result(): supplied argument is not a valid
 MySQL result resource



 Regards,
 Evert



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



[PHP-DB] Re: newbie question on PHP Mysql...

2005-09-21 Thread Sigrid Krug
Hi Evert, try:

echo mysql_result($result,0,0), \n;
echo mysql_result($result,0,1);

You forgot a zero...

Regards, Sigrid

Evert Meulie [EMAIL PROTECTED] schrieb im Newsbeitrag
news:[EMAIL PROTECTED]
 Hi all!

 I'm taking my first steps with PHP  MySQL.

 Can anyone give me a hint on why this would not work?

 *

 $result = mysql_query('SELECT SUM(AcctInputOctets), SUM(AcctOutputOctets)
FROM radacct WHERE username = $argv[1] ');
 echo mysql_result($result,0), \n;
 echo mysql_result($result,0,1);

 *


 I get: Warning: mysql_result(): supplied argument is not a valid MySQL
result resource



 Regards,
 Evert

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



[PHP-DB] Re: newbie question on PHP Mysql...

2005-09-21 Thread Sylvain Gourvil

Evert Meulie wrote:

Hi!

I've tried your suggestions, but still get the same error message. The 
'print_r($result);' that I added does not print anything, so that would 
explain why I get the errors.


My idea is to call this script with a value, like:
script.php value

Doesn't that put the value in $argv[1] ?


Regards,
Evert

What do you use to execute your php scripts.

Php on linux ssh ?
Apache ?

call your script with script.php?var=value to get your value in $_GET['var']

But even if your args are emptied, it should return an error in your 
$result !









Unnawut Leepaisalsuwanna wrote:


Hi,

I guess you used a single quote over the query so the text, $argv[1],
was entered into the query rather than the value inside it.

try:

$result = mysql_query('SELECT SUM(AcctInputOctets),
SUM(AcctOutputOctets)  FROM radacct WHERE username = ' .$argv[1] );

OR

$result = mysql_query(SELECT SUM(AcctInputOctets),
SUM(AcctOutputOctets)  FROM radacct WHERE username = $argv[1]);

should do the trick

21nu

Sylvain Gourvil wrote:



Hi !

Could you do a print_r($result) after your mysql_query ?

Or you sure of your argv[1] ?

Sylvain Gourvil

Evert Meulie wrote:



Hi all!

I'm taking my first steps with PHP  MySQL.

Can anyone give me a hint on why this would not work?

*

$result = mysql_query('SELECT SUM(AcctInputOctets),
SUM(AcctOutputOctets)  FROM radacct WHERE username = $argv[1] ');
echo mysql_result($result,0), \n;
echo mysql_result($result,0,1);

*


I get: Warning: mysql_result(): supplied argument is not a valid
MySQL result resource



Regards,
   Evert








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



Re: [PHP-DB] Re: newbie question on PHP Mysql...

2005-09-21 Thread Ziv Gabel

Try This
$result = mysql_query(SELECT SUM(AcctInputOctets),SUM(AcctOutputOctets) 
FROM radacct WHERE username = '$argv[1]' );


this will make sure that even if $arg[1] is empty it still get '' (empty) as 
part of the query



- Original Message - 
From: Sylvain Gourvil [EMAIL PROTECTED]

To: php-db@lists.php.net
Sent: Wednesday, September 21, 2005 3:26 PM
Subject: [PHP-DB] Re: newbie question on PHP  Mysql...



Evert Meulie wrote:

Hi!

I've tried your suggestions, but still get the same error message. The 
'print_r($result);' that I added does not print anything, so that would 
explain why I get the errors.


My idea is to call this script with a value, like:
script.php value

Doesn't that put the value in $argv[1] ?


Regards,
Evert

What do you use to execute your php scripts.

Php on linux ssh ?
Apache ?

call your script with script.php?var=value to get your value in 
$_GET['var']


But even if your args are emptied, it should return an error in your 
$result !









Unnawut Leepaisalsuwanna wrote:


Hi,

I guess you used a single quote over the query so the text, $argv[1],
was entered into the query rather than the value inside it.

try:

$result = mysql_query('SELECT SUM(AcctInputOctets),
SUM(AcctOutputOctets)  FROM radacct WHERE username = ' .$argv[1] );

OR

$result = mysql_query(SELECT SUM(AcctInputOctets),
SUM(AcctOutputOctets)  FROM radacct WHERE username = $argv[1]);

should do the trick

21nu

Sylvain Gourvil wrote:



Hi !

Could you do a print_r($result) after your mysql_query ?

Or you sure of your argv[1] ?

Sylvain Gourvil

Evert Meulie wrote:



Hi all!

I'm taking my first steps with PHP  MySQL.

Can anyone give me a hint on why this would not work?

*

$result = mysql_query('SELECT SUM(AcctInputOctets),
SUM(AcctOutputOctets)  FROM radacct WHERE username = $argv[1] ');
echo mysql_result($result,0), \n;
echo mysql_result($result,0,1);

*


I get: Warning: mysql_result(): supplied argument is not a valid
MySQL result resource



Regards,
   Evert








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




This footnote confirms that this email message has been scanned by
PineApp Mail-SeCure for the presence of malicious code, vandals  computer 
viruses.









This footnote confirms that this email message has been scanned by
PineApp Mail-SeCure for the presence of malicious code, vandals  computer 
viruses.


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



[PHP-DB] Re newbie question

2005-04-15 Thread Balwant Singh
i am doing the following for inserting values in MYSQL DB through PHP.

$a = hello;
$b = 1;

$query = INSERT INTO tablename (a, b) VALUES ('$a', '$b');

try this

with best wishes
balwant



- Original Message -
From: Kenn Murrah [EMAIL PROTECTED]
To: php-db@lists.php.net
Sent: Wednesday, May 31, 2000 2:36 PM
Subject: [PHP-DB] newbie question:


 I'm trying to accomplish a simple task, that of
 inputting text and numbers from an HTML form,
 then writing to mySQL via PHP.

 Oddly enough, when I attempt this with numerals,
 all is well.  When I attempt it with a text string, it
 fails.

 Pardon the beginner question, but can anyone tell
 me what I'm likely doing wrong?

 Thanks in advance,

 Kenn

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



[PHP-DB] Re: Newbie question

2004-03-30 Thread Kim Steinhaug
Well,

Could be some sort of debugging mode on the PHP running on the
server. On the other hand your script is depending on the fact that
GLOBALS are turned on, which - you shouldnt.

1)
   Anywho - you form is using POST, so you should use this syntax :

   $_POST[variable], if using GET the equivilant is : $_GET[variable]

2)
You should try to avoid putting variables inside quotes, unless you have
a good reason for is. Meaning
Hello $variable;
should be written as :
Hello  . $variable;

So the answer to your question would be, on the second page, and I also
prefer echo instead of print.

echo Hello  . $_POST[name] . !;
or
echo 'Hello ' . $_POST[name] . '!';

-- 
-- 
Kim Steinhaug
--
There are 10 types of people when it comes to binary numbers:
those who understand them, and those who don't.
--
www.steinhaug.com - www.easywebshop.no - www.webkitpro.com
--

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



[PHP-DB] Re: Newbie-Question: What's that @?

2002-10-31 Thread rolf vreijdenberger
there is no difference between the two!
quote: 
@mysql_query($query)
and
@mysql_query($query)?

haha
but seriously, the @ supresses error messages from php, so these will not be
outputted.
No information on why or how, the query in this case, it failed.
you can do this on a per function basis with the @ or for the whole script
with error_reporting() function.

--
Rolf Vreijdenberger
De Pannekoek en De Kale
Maystraat 6
2593 VW Den Haag
T: 06-24245719
E: [EMAIL PROTECTED]
W: www.depannekoekendekale.nl
Marcus Fleige [EMAIL PROTECTED] schreef in bericht
news:php.db-22830;news.php.net...
hi there,

i've got a general question about php-scripts:

whats the difference between

@mysql_query($query)

and

@mysql_query($query)?

is it the same as in batch programming?
like, ignore all return messages?

thanks and greetings from germany,

marcus

--
^v^
[EMAIL PROTECTED]




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




[PHP-DB] Re: newbie question: fetchrow or smth else ?

2002-02-01 Thread Alecs

okay, thanks for help ;-p

fetchrow failed because my query was buggy, the proper syntax for left is
LEFT(something, number)

Alecs [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...

  Could some one please check the following code and guesstimate where am I
  wrong ?
  (the only thing I got from browser is: Fatal error: Call to undefined
  function: fetchrow() pc_list.php on line 14, but on that line I have
  fetchRow() not fetchrow(). To make it worse even when I am replacing
  fetchRow() with FetchRow the same error is reported)

  PS. I used PEAR that comes with php-4.1.1 and php-4.0.4pl1. nothing
changed
  :(

  ---
  require_once DB.php ;

  $db = DB::connect($db_type://$db_user:$db_pass@$db_host/$db_name,
  $db_pipe) ;
  $req = SELECT pc.hostname, m.logo, pc.mac, pc.ip FROM computer pc, mac m
  WHERE m.id = LEFT(pc.mac)  ;

  $p_req = $db-prepare($req) ;
  $res = $db-execute($p_req) ;

  echo  table border=1 \n ;
  echo  tr th Hostname /th th Logo /th th MAC /th th IP
 /th
  /tr\n ;

  $counter = 0 ;
  while ( $arr=$res-fetchRow() ) {
  echo  tr td $arr[0] /td td img src=\logos/$arr[1]\
  /td  ;
  echo  td $arr[2] /td td $arr[3] /td /tr \n ;
  $counter++ ;
  }






-- 
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: newbie question: request response

2002-02-01 Thread Luke Crouch

The real reason I'm asking is because I want to design a PHP app that uses a
similar framework to a current Java/JSP app I'm developing, and I will need
to use a controller php file that forwards the request and response objects
it receives to another php.

Java Servlets do this nicely because instead of parsing through all of the
arguments in the request object, and then going to the next servlet, it just
punches the whole request object to the next servlet.

Like I said, the only reason I would need them is to align with my current
framework. But I will probably just design a different framework for my PHP
apps.

Thanks, though...

-L




-- 
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: newbie question: request response

2002-01-30 Thread Oliver Cronk

No (not out of the box anyway) BUT the beauty of PHP is its much simpler
than JSP or ASP's server.response() server.request() methods (sorry if thats
not the exact syntax - I haven't done huge amounts of ASP/JSP work lately),
in most cases you simply output the data (i.e. print / echo something;)
for the response (maybe in conjuction with an optional http header - the
default is text/html but you could send pretty much any MIME type - jpegs,
pdfs etc).  This means knocking up simple scripts is much easier quicker...

The request object is taken care in most cases by just being there as a php
variable with the same name as html / http element - i.e. if your html form
has an element called bob then when this form is (via http post / get)
sent back to a PHP script the variable is available as $bob.  How simple!
Sometimes you might want to use HTTP_GET_VARS['bob'] but I haven't
encountered a time where thats necessary apart from when retrieving server
info - auth_user, server_name etc (perhaps someone else could explain other
situations when that is required?)

Of course you could create request and response classes in PHP if you wanted
to but that would remove the simplicity, beauty and speed of the langauge
(IMHO).  After all when I look at a JSP script I just think what a waste of
code - server.response(thismethod(anothermethod(x))) just to output
something!!

Don't get me wrong I am not bad mouthing Java (in fact I use it too - just
not for web programming) its features are there for security (ideal for
e-banking), object orientated reasons and J2EE stuff, but with PHP you can
really just get to the core of 90% of what web scripts need to do - you just
need to return some data in HTML / XML back to the browser as efficiently
and quickly as possible.

I am bad mouthing ASP though! I think its over-complicated for no good
reasons when compared to PHP! In addition you have a severe lack of libary
functions (image manipulation, database access (other than the terribly slow
ODBC option or the ADO option) XML etc).  I presume VB.NET and C# will try
to make up for these things by offering the windows forms interfaces and
other new stuff.

In my view

echo something; (interpreted by PHP machine code cgi / isapi module)

would appear on the face of things to be a lot quicker than:

servlet.response(something);  (in java byte code (hmm slow!) interpreted
by jsp/servlet/library engine then into machine code)

or

server.response(something); (code interpreted by class / library in
asp.dll or suchlike then into asp engine / windows service then machine
code)


obviously the string something would be something dynamic like a database
result or such like but you get the idea. But I could be wrong!

What really impresses me about PHP is that it offer a version of their
scripting engine that will run on any almost any platform. This is machine
code complied and so in theory outperforms the cross platform Java
(byte-code), and maybe asp (visual basic - interpreted) which is also know
to be a bit sluggish compared with PHP, but of course only really runs on
Win32 (i know there's chillisoft - asp for unix) - but thats not exactly a
realistic option.

As you can see I have bathered on a bit (opps I have just realised this was
a newbie question!), the reason being that I had to make this comparision
for a company a while back - they said whats the best web/ intranet servers
side technology - I said (after careful consideration of various factors,
including such things  as how easily existing staff could pick up the
technlogy, and value for money) PHP running on Win32/IIS (offers the best
solution - in my particular client's case - using a Windows Domain / MS-SQL
Databases).

What does everyone else think - or I am completely barking up the wrong
tree?  I expect a lot of Linux rocks use Linux and MYSQL/Postgres
responses, but for those coming from a ASP background with IT managers
wanting to use MS products whereever possible using PHP on Win32 makes
sense.


Luke Crouch [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]...
 Does PHP have built-in support for using request and response objects?
 Thanks,

 -L





-- 
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: Newbie Question

2001-11-09 Thread Steve Brett

have a look at get_html_translation_table() in the php manual.

there is an example of conversion of all special chars so they can be
inserted into the database as text (i.e. £pound) and a cool way of
'decoding' them if you need to write them to a file. A Browser wil interpret
them correctly when they are displayed.

This must be the question of the day as i have posted this answer three
times today :-)

Let me know if you need any more help

Steve

get_html_translation_table manual page is below:

  PHP Manual
  Prev  Next




get_html_translation_table
(PHP 4 = 4.0b4)

get_html_translation_table --  Returns the translation table used by
htmlspecialchars() and htmlentities()
Description

string get_html_translation_table (int table [, int quote_style])


get_html_translation_table() will return the translation table that is used
internally for htmlspecialchars() and htmlentities(). There are two new
defines (HTML_ENTITIES, HTML_SPECIALCHARS) that allow you to specify the
table you want. And as in the htmlspecialchars() and htmlentities()
functions you can optionally specify the quote_style you are working with.
The default is ENT_COMPAT mode. See the description of these modes in
htmlspecialchars(). Example 1. Translation Table Example

$trans = get_html_translation_table (HTML_ENTITIES);
$str = Hallo  Frau  Krämer;
$encoded = strtr ($str, $trans);



The $encoded variable will now contain: Hallo amp; lt;Fraugt; amp;
Krauml;mer.

The cool thing is using array_flip() to change the direction of the
translation.


$trans = array_flip ($trans);
$original = strtr ($str, $trans);




The content of $original would be: Hallo  Frau  Krämer.
  Note: This function was added in PHP 4.0.


See also: htmlspecialchars(), htmlentities(), strtr(), and array_flip().




  Prev Home Next
  explode Up get_meta_tags





Jay Fitzgerald [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Ok, I am still fairly new at PHP and MySQL also, so please bear with me.


 TASK: I have a client that wants to have job openings listed on their site
 and they want to be able to add, edit and delete the postings themselves.
I
 would do this in flat-file format but there is the risk of that file size
 getting too large and slowing down the server.


 SOLUTION: I have created a MySQL database that will hold all the postings
 in a table called 'jobs' and have created a PHP form that will post this
 jobs into the db.

 PROBLEM: When I go to the PHP form and enter all of the pertinent job
 information, there is one specific field that will have to have carriage
 returns/line breaks in it between paragraphs. Everything is working except
 for this. Is there a way whenever the user presses ENTER, that either
 PHP/MySQL will convert this into a BR tag only when being displayed in a
 browser and not in the db??


 Can anyone out there please help me with this? I am available off-list as
 well if it will be easier to pass code back and forth. Any assistance is
 greatly appreciated!



 Should you have any questions, comments or concerns, feel free to call me
 at 318-338-2034.

 Thank you for your time,

 Jay Fitzgerald, Design Director - CSBW-A, CPW-A, CWD-A, CEMS-A
 ==
 Bayou Internet..(888)
 30-BAYOUhttp://www.bayou.com
 Mississippi Internet...(800)
 MISSISSIPPI...http://www.mississippi.net
 Vicksburg Online..(800)
 MISSISSIPPIhttp://www.vicksburg.com
 ==
 Tel: (318) 338-2034ICQ: 38823829 Fax:
 (318) 323-5053




-- 
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: Newbie Question

2001-11-08 Thread Kodrik

I wrote this cleanup function:

function cleanup($copy)
{
$copy=trim($copy);
$copy=htmlspecialchars($copy, ENT_QUOTES);
$copy=eregi_replace (%, #37;, $copy);
$copy=eregi_replace (, lt;, $copy);
$copy=eregi_replace (, gt;, $copy);
$copy=eregi_replace (amp;, , $copy);
$copy=nl2br($copy);
$copy=StripSlashes($copy);
return($copy);
}

nl2br converts the carriage returns into br or br / depending on your 
version of php.
So if you want to offer your copy for editing instead of viewing, you might 
want to run
$string=str_replace(br /, , $string);

The rest of the code removes characters that can be used for malicious coding.
You might want to edit it if you want them to enter html code.

I also made some functions to access MySQl easier with php:
http://zc8.com/zc8/ZC8news/shownews.php?articleid=98

You are welcome to use and modify the code

-- 
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]