Re: [PHP] Add associative element to an an array

2002-03-07 Thread Matt Drake

I'd think $arr['8'] = 6 would work...

Using a number (as in $arr[8] = 6) would possibly confuse things, though
I can't get to a PHP machine right now so I'm not sure.

M

On Fri, 8 Mar 2002, Bradley Goldsmith wrote:

> Hi,
>
>   Ive got an array of associations like this:
>
>   [1]=>2 [2]=>3 [3]=>4 etc
>
>   I want to add a new element [8]=>6.
>
>   How do I do this? I have tried several ways: pushing the element,
> merging arrays, etc with no luck (it either increments the key or doesn't
> work at all).
>
>   Any ideas would be appreciated!
>
> Cheers,
> Brad
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>


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




Re: [PHP] New to PHP, need help.

2002-03-07 Thread Matt Drake

Michele,

Possible a dumb question, but does the machine you are running it on have PHP
installed and configured to work with the server software?

If so, did you name the file correctly? It may need to be called "page.php"
rather than "page.html"...

M

On Thu, 7 Mar 2002, Michele wrote:

> I currently working with some free source from CyberGl and am having a
> problem  with the membership module.
>
> I've inserted the php into the beginning of the page but when I go to test
> the page, nothing appears.  I don't get a 404 error or any error, the page
> just doesn't display.
>
> Any ideas?
>
> Thanks,
>
> Michele
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>


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




Re: [PHP] apostrphe's entered into MySQL database

2002-02-27 Thread Matt Drake

Whoops...helps if I write it legally.

$dbStr = preg_replace("/'/", "/\\'/", $dbStr);
$dbStr = preg_replace("/'/", "/''/", $dbStr);

M

On Wed, 27 Feb 2002, Matt Drake wrote:

> I don't see why addslashes wouldn't work, but why not roll your own?
>
> $dbStr = preg_replace("/'/", "/\\'/");
>
> I believe that, in MySQL, you can also double-up single quotes to escape
> them:
>
> $dbStr = preg_replace("/'/", "/''/");
>
> HTH
> Matt
>
> On Wed, 27 Feb 2002, Tim Thorburn wrote:
>
> > Hi,
> >
> > I've sent a few emails thus far regarding adding apostrophe's through a PHP
> > script form into a MySQL database.  The responses I received indicated to
> > me that I needed to get my hosting company to activate magic_quotes_gpc.
> >
> > After several days of talking with what seems to be the sole tech support
> > person left at my hosting company - I was told that the magic_quotes_gpc
> > variable is not supported by them.
> >
> > Sooo ... this leaves me in a rather awkward situation.  I need to have a
> > basic content management system up and running in the extremely near future
> > that will be utilized by a great number of individuals.  If when an
> > apostrophe is entered - all the information entered through the form is
> > rejected by the database - the entire endeavour suddenly becomes rather
> > useless.
> >
> > I know that if I enter a \ before any apostrophe's in the form, it all
> > works well ... but I highly doubt that the large number of volunteer's
> > we're going to be working with here will take the time to add them, or even
> > remember 5 minutes after I tell them.
> >
> > Does anyone have any possible solutions for this problem?  I'll include the
> > portion of code that seems to be causing the problems now ...
> >
> > I'm already using the addslashes() command and it is not working ... I'm
> > desperate at this point ...
> >
> > Again, the following works flawlessly on my local test machine running
> > Apache 1.3.23 and PHP 4.1.1 with MySQL 3.23.39 but not at all on my web
> > host running Apache 1.3.12 and PHP 3.0.16 with MySQL 3.22.32
> >
> > Thanks in advance,
> > -Tim
> >
> >
> >  > $db = mysql_connect("localhost", "", "");
> > mysql_select_db("edoinfo",$db);
> >
> > if ($submit) {
> > // here if no ID then adding else we're editing
> > if ($id) {
> > $sql = "UPDATE ai_data SET
> > 
>section='$section',subsection='$subsection',heading='$heading',title='$title',info='$info',entry=NOW()
> > WHERE id=$id";
> > } else {
> >  $sql = "INSERT INTO ai_data
> > (section,subsection,heading,title,info,entry) VALUES
> > ('$section','$subsection','$heading','$title','$info',NOW())";
> > }
> > // run SQL against the DB
> > $result = mysql_query($sql);
> > echo "Record updated/edited!";
> > echo "ADD A RECORD";
> >
> > } elseif ($delete) {
> > // delete a record
> >  $sql = "DELETE FROM ai_data WHERE id=$id";
> >
> >  $result = mysql_query($sql);
> >
> > echo "$sql Record deleted!";
> > echo "ADD A RECORD";
> >
> > } else {
> > // this part happens if we don't press submit
> > if (!$id) {
> > // print the list if there is not editing
> >  $result = mysql_query("SELECT * FROM ai_data",$db);
> >  while ($myrow = mysql_fetch_array($result)) {
> >  printf("%s \n", $PHP_SELF,
> > $myrow["id"], $myrow["title"]);
> >
> > printf("(DELETE)",
> > $PHP_SELF, $myrow["id"]);
> >  }
> > }
> >
> > ?>
> > ADD A RECORD
> > 
> > > if ($id) {
> > // editing so select a record
> > $sql = "SELECT * FROM ai_data WHERE id=$id";
> > $result = mysql_query($sql);
> > $myrow = mysql_fetch_array($result);
> >
> > $id = $myrow["id"];
> > $section = $myrow["section"];
> > $subsection = $myrow["subsection"];
> > $h

Re: [PHP] apostrphe's entered into MySQL database

2002-02-27 Thread Matt Drake

I don't see why addslashes wouldn't work, but why not roll your own?

$dbStr = preg_replace("/'/", "/\\'/");

I believe that, in MySQL, you can also double-up single quotes to escape
them:

$dbStr = preg_replace("/'/", "/''/");

HTH
Matt

On Wed, 27 Feb 2002, Tim Thorburn wrote:

> Hi,
>
> I've sent a few emails thus far regarding adding apostrophe's through a PHP
> script form into a MySQL database.  The responses I received indicated to
> me that I needed to get my hosting company to activate magic_quotes_gpc.
>
> After several days of talking with what seems to be the sole tech support
> person left at my hosting company - I was told that the magic_quotes_gpc
> variable is not supported by them.
>
> Sooo ... this leaves me in a rather awkward situation.  I need to have a
> basic content management system up and running in the extremely near future
> that will be utilized by a great number of individuals.  If when an
> apostrophe is entered - all the information entered through the form is
> rejected by the database - the entire endeavour suddenly becomes rather
> useless.
>
> I know that if I enter a \ before any apostrophe's in the form, it all
> works well ... but I highly doubt that the large number of volunteer's
> we're going to be working with here will take the time to add them, or even
> remember 5 minutes after I tell them.
>
> Does anyone have any possible solutions for this problem?  I'll include the
> portion of code that seems to be causing the problems now ...
>
> I'm already using the addslashes() command and it is not working ... I'm
> desperate at this point ...
>
> Again, the following works flawlessly on my local test machine running
> Apache 1.3.23 and PHP 4.1.1 with MySQL 3.23.39 but not at all on my web
> host running Apache 1.3.12 and PHP 3.0.16 with MySQL 3.22.32
>
> Thanks in advance,
> -Tim
>
>
>$db = mysql_connect("localhost", "", "");
>   mysql_select_db("edoinfo",$db);
>
>   if ($submit) {
>   // here if no ID then adding else we're editing
>   if ($id) {
>   $sql = "UPDATE ai_data SET
> 
>section='$section',subsection='$subsection',heading='$heading',title='$title',info='$info',entry=NOW()
> WHERE id=$id";
>   } else {
>  $sql = "INSERT INTO ai_data
> (section,subsection,heading,title,info,entry) VALUES
> ('$section','$subsection','$heading','$title','$info',NOW())";
>   }
>   // run SQL against the DB
>   $result = mysql_query($sql);
>   echo "Record updated/edited!";
>   echo "ADD A RECORD";
>
>   } elseif ($delete) {
>   // delete a record
>  $sql = "DELETE FROM ai_data WHERE id=$id";
>
>  $result = mysql_query($sql);
>
>   echo "$sql Record deleted!";
>   echo "ADD A RECORD";
>
>   } else {
>   // this part happens if we don't press submit
>   if (!$id) {
>   // print the list if there is not editing
>  $result = mysql_query("SELECT * FROM ai_data",$db);
>  while ($myrow = mysql_fetch_array($result)) {
>  printf("%s \n", $PHP_SELF,
> $myrow["id"], $myrow["title"]);
>
>   printf("(DELETE)",
> $PHP_SELF, $myrow["id"]);
>  }
>   }
>
>   ?>
> ADD A RECORD
> 
>   if ($id) {
>   // editing so select a record
>   $sql = "SELECT * FROM ai_data WHERE id=$id";
>   $result = mysql_query($sql);
>   $myrow = mysql_fetch_array($result);
>
>   $id = $myrow["id"];
>   $section = $myrow["section"];
>   $subsection = $myrow["subsection"];
>   $heading = $myrow["heading"];
>   $title = addslashes($myrow["title"]);
>   $info = addslashes($myrow["info"]);
>  $entry = $myrow["entry"];
>
>   // print the id for editing
>   ?>
>
>   }
>   ?>
>  
>  Section:
>  
> size="35" maxlength="100" >
>  
>
>
>  Sub-Section: 
>  
>>
>  
>
>
>  Heading Graphic: 
>  
> size="35" maxlength="255" >
>  
>
>
>  Section Title: 
>  
> size="35" maxlength="255" >
>  
>
>
>   
>
>
>  Document Information: 
>  
> include('../../../scripts/forms.css'); ?>>
>  
>
>
>   
>   
>
>
>  Event Entry: 
>  
>
>  
>
>
>   
>   
>
>
>  
> border=0 alt="Enter Information" style="background-color: 00;
> font-size: 14; color: cc;">
>  
>   
>
>
>   
>   
>
> 
>   
>
>  }
>   ?>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>


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




Re: [PHP] PHP/Java/SOAP

2002-02-21 Thread Matt Drake

> Is there a webserver (Tomcat?) that supports both servlets/JSP and PHP? If so, is it 
>possible to have PHP and servlet/JSP code collaborating? I'm looking into using SOAP 
>(apache project's implementation) but I need some of PHP's functionality.

You can use Tomcat and Apache together. There's an Apache-Tomcat HOWTO somewhere 
around. I
found it on Google.

Then you can set up PHP to run on Apache as normal. The kewl way to do things is to 
create
your XML files from a PHP script and redirect the user to the XML when your script is 
over.

HTH,
Matt

>
> thanks in advance,
> thalis
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>


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




Re: [PHP] PHP and HTTPS

2002-02-18 Thread Matt Drake

On Mon, 18 Feb 2002, wm wrote:

> i have written some PHP scripts that work every single time under http.
>
> under https (we have a valid security certificate) they work every
> single time on IE on mac and on NN on mac and pc.
>
> on IE on pc a "this page cannot be displayed" error (with possible
> reasons like your browser needs to be set to accept SSL2 and SSL3 [it is
> by the way]) is generated half of the time. the other half it works.

Do you have any static HTML pages in your SSL-protected area? How do those work?

If they have the same problem, you can eliminate PHP from the equation...if
not, you can focus more directly on PHP.

Matt


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




Re: [PHP] Returning table rows from MySQL

2002-02-18 Thread Matt Drake

On Mon, 18 Feb 2002, Scott Saraniero wrote:

> I've got a piece of code below that works great for me. Now I would like to
> modify the rows with alternating colors in the displayed results. Any
> suggestions on how to do this?

Try this:

$Count = 0;
while ($Row = mysql_fetch_array($Result) {
print("");
print('');

...
$Count++;
}

You could probably replace $Count with some mysql function (it would be named 
something like
mysql_current_row($Result)), but I obviously don't know that much about it.

Matt



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




Re: [PHP] Trying to put ips into database

2002-02-08 Thread Matt Drake

On Fri, 8 Feb 2002, Dennis Moore wrote:

> Not sure what your exact problem is but I did notice you had back ticks(`)
> in your insert statement.  You should be using (').   You may need a where
> clause in your insrt statement unless you want to populate all rows.  Just a
> couple of thoughts.

Actually, you don't need quotes around the col. names at all...

mysql_query("INSERT INTO ips (ip) VALUES ('$REMOTE_ADDR')");

As for only getting the first part, are you sure the ip field is big enough?
Try "explain ips" from a mysql client...it should be at least 15 chars.

Matt

>
> /dkm
>
>
> - Original Message -
> From: "Leif K-Brooks" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Friday, February 08, 2002 11:18 AM
> Subject: [PHP] Trying to put ips into database
>
>
> > I'm trying:
> > $query = mysql_query("select COUNT(*) as rowexists from ips where ip =
> > '$REMOTE_ADDR'");
> > $result = mysql_fetch_array($query);
> > if($result['rowexists'] == false){
> > mysql_query("INSERT INTO `ips` (`ip`) VALUES ('$REMOTE_ADDR')");
> > }
> >
> >
> > But it keeps putting the ip into tthe array, even if it's already there,
> and
> > it only gets the first section of the ip!  What am I doing wrong?
> >
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>



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