Re: [PHP-DB] Sorting Multidimensional Array

2006-10-31 Thread Dave W

You should be able to use usort()

On 10/31/06, Keith Spiller [EMAIL PROTECTED] wrote:


Hi,

RE:  Sorting Multidimensional Array

I'm trying to sort a multidimensional array.  The data was taken from
a mysql query:

$myrow = mysql_fetch_row($result) {
  query[] = $myrow;
}

The purpose is to retrieve the table data and manually add a record,
then sort ASC by the startdate which is the forth field...

Something like:

$test = array_multisort($query, $key = '$query[4]');

Any help would be greatly appreciated.  Thanks,


Larentium





--
Dave W


Re: [PHP-DB] mysql databases

2006-10-13 Thread Dave W

He means that he wants to use REPLACE and take out the old entry and update
it with a new one. Although, you would probably use UPDATE instead.

--
Dave W


Re: [PHP-DB] Php 5 and Mysql on Windows

2006-10-03 Thread Dave W

You might want to try php.ini-recommended instead of php.ini-dist.

On 10/3/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:


Hey

I did that already. Step (8) of setting up php.

Do I need to move any files around or add anything else to the path?




-Original Message-
From: Stut [EMAIL PROTECTED]
Sent: Tue, October 3, 2006 14:12
To: [EMAIL PROTECTED]
Cc: php-db@lists.php.net
Subject: Re: [PHP-DB] Php 5 and Mysql on Windows

[EMAIL PROTECTED] wrote:
 I setup Mysql as follows:

 1. Download the 5.x installer
 2. Run the installer
 3. Run the configuration tool ater the installer

 When I run the following script, the error Fatal error: Call to
 undefined function mysql_connect() in Test.php on line 3  is returned.

 $conn = mysql_connect('localhost', 'root', 'password')

Installing MySQL is not enough - you need to enable the mysql extension
in your php.ini.

-Stut

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





--
Dave W


[PHP-DB] Re: Turning result into array from columns

2006-09-23 Thread Dave W

Yea, thanks. I forgot to hit reply to all. I usually use sprintf for mysql
injection stuff. I use that function from php.net for
mysql_real_escape_string.

On 9/23/06, Matthias Willerich [EMAIL PROTECTED] wrote:


Hello,
  $q = sprintf(SELECT id FROM content);
This has nothing to do with your problem, but why don't you just do the
following?
$q = 'SELECT id FROM content';

But here's your problem. Change
  $realones = $row['id'];
into
$realones[] = $row['id'];
And you get your desired result.

Matthias






--
Dave W


[PHP-DB] Turning result into array from columns

2006-09-22 Thread Dave W

So I'm trying to pull id's and put them into an array. I know I need to
iterate through them, but it doesn't seem to turn into an array. Here's the
function that I'm trying:

function checkID($id) {
$q = sprintf(SELECT id FROM content);
$result = $this-query($q);

while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
$realones = $row['id'];
}

if(in_array($id,array($realones))) { return true; } else { return false; }
}

It's only grabbing the first row id and putting it into the array. It won't
put any of the other ones in. If I just echo $row['id'], it will show both
of them, just not put both of them into an array.

--
Dave W


Re: [PHP-DB] Forms with letter verification

2006-07-29 Thread Dave W

You mean a CAPTCHA script?

On 7/29/06, Ron Piggott (PHP) [EMAIL PROTECTED] wrote:


You know forms which have a security field where the user reads back the
letters that are displayed?  I am wondering if someone has the time to
coach me in writing this --- or if you know of a web page that shows how
to create this feature.  I have already created a set of graphical
letters.  Ron





--
Dave W


[PHP-DB] pulling numbers from a column and getting a total

2006-07-26 Thread Dave W

Hi, I was just wondering on how I could get a whole column full of integers
and added them up and display that total? I currently use a for loop to
display the whole column in a table, but I wanted to add all those numbers
up.

Thanks.

--
Dave W


Re: [PHP-DB] pulling numbers from a column and getting a total

2006-07-26 Thread Dave W

Thanks Natalie and Miles! The loop thing worked. What I had tried before was
put the echo inside the loop and it wasn't working, but now it does, w00t!
Thanks!

On 7/26/06, Miles Thompson [EMAIL PROTECTED] wrote:


At 10:27 AM 7/26/2006, Dave W wrote:

Hi, I was just wondering on how I could get a whole column full of
integers
and added them up and display that total? I currently use a for loop to
display the whole column in a table, but I wanted to add all those
numbers
up.

Thanks.

--
Dave W

Dave,

You're v. close to an answer. Think about it a bit.

Initialize a variable before your loop, setting it to zero.
 $tot = 0;
In the loop, add the amount to that variable,
 $tot += $num_to_add;
OR
 $tot = $tot + $num_to_add;

After the loop, echo $tot.

HTH - Miles


--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.1.394 / Virus Database: 268.10.4/399 - Release Date: 7/25/2006

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





--
Dave W


[PHP-DB] Re: Subject: making an array from data in textfile

2006-07-24 Thread Dave W

Thanks for all the suggestions.

On 7/24/06, Neil Smith [MVP, Digital media] [EMAIL PROTECTED]
wrote:




Message-ID: [EMAIL PROTECTED]
Date: Sat, 22 Jul 2006 21:31:35 -0400
From: Dave W [EMAIL PROTECTED]
To: Php-Db php-db@lists.php.net
MIME-Version: 1.0
Content-Type: multipart/alternative;
 boundary==_Part_157142_2227727.1153618295222
Subject: making an array from data in textfile

OK, so I have this text file that holds a list of ip addresses like this:
127.0.0.1,127.0.0.1,127.0.0.1,127.0.0.1,127.0.0.1


Which are strings... You with me OK so far ?
Numeric [float] values only have 1 period.
There's no numeric datatype which has 3.

Currently, here is my code:

$file = 'ip.txt';
$fh = fopen($file, 'r');
$theData = fread($fh, filesize($file));
fclose($fh);
$ips = array($theData);

Since it's a numeric array,


No, it isn't. It's an array of strings which has numeric indices
(or keys depends what you call em)


I shouldn't need quotes around the ip octets.


Yes, you should : They're strings unless you use inet_pton to convert
them to numeric values.


When I try to echo certain parts of the array like:

echo $ips[0];

It's returning the whole array.


If you print_r($ips) you'll see the array structure (View - Source
if you're looking at it in a browser).
My guess is your lines aren't terminated in \r\n, which PHP uses to
split the lines to array values.

You'll probably have to use some other method such as explode(',',
$ips) to break the individual comma separated entries into a set of
values. Other methods such as file_get_csv are generally more
efficient than reading line by line :
http://uk.php.net/manual/en/function.fgetcsv.php


  The text file is exactly like an array so it
shouldn't be a problem.


It's exactly like a CSV, from the example data you provided.
PS, please don't feel the need to prove it by posting the entire log file
;-)

Cheers - Neil









--
Dave W


Re: [PHP-DB] Re: making an array from data in textfile

2006-07-23 Thread Dave W

I figured it out before, but I didn't hit reply all. I used files() and
newlines to create it. Would using explode be a more reliable way?

On 7/23/06, Stut [EMAIL PROTECTED] wrote:


-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Dave W wrote:
 Currently, here is my code:

$file = 'ip.txt';
$fh = fopen($file, 'r');
 $theData = fread($fh, filesize($file));
 fclose($fh);
 $ips = array($theData);

...

 Since it's a numeric array, I shouldn't need quotes around the ip
octets.
 OK, well I did a debug and this is whats coming out:

 Array
 (
[0] = 127.0.0.1,127.0.0.1,127.0.0.1
 )

PHP doesn't know what separates each element of the array, so you need
to tell it...

$ips = explode(',', $theData);

- -Stut
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.2.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFEw2cA2WdB7L+YMm4RAlmaAJ4+cRJulnESdiZMZ5XtGWZ6Su5TzQCguSSY
fAqVdvlg4xX+RgrMepUJbc0=
=jI3V
-END PGP SIGNATURE-





--
Dave W


Re: [PHP-DB] Re: making an array from data in textfile

2006-07-23 Thread Dave W

Well, its what I want so I could do a foreach array like this and print out
the ips in a table:
   foreach($ips as $value) {
   $value = trim($value);
   $domain = gethostbyaddr($value);
   echo  tr class=\alternate\


   th scope=\row\3/th
   td$value/td
   td$domain/td/tr ;}
echo '
/tbody/table/div';

It works!

On 7/23/06, Stut [EMAIL PROTECTED] wrote:


-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Dave W wrote:
 I figured it out before, but I didn't hit reply all. I used files() and
 newlines to create it. Would using explode be a more reliable way?

I assume you mean the file() function, not files(). The only problem
with doing it that way is that each element of the array will have a
newline on the end. Maybe this is what you want, but I doubt it.

- -Stut
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.2.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFEw3tl2WdB7L+YMm4RAg3xAJ0SPUPR+00PXVIfJhDfg4WrBWVi/ACgsFOu
9usmbLbhNrXUCef+uCyzAY4=
=RXbe
-END PGP SIGNATURE-





--
Dave W


Re: [PHP-DB] Using MAX with COUNT?

2006-07-22 Thread Dave W

Why don't you use a where instead of a group function?

On 7/22/06, Skip Evans [EMAIL PROTECTED] wrote:


Hey all,

I have a table like this:

boroughID   Area
=   
1   Chelsea
1   East Village
1   West Village
1   So Ho
2   Prospect Park
2   Brooklyn Heights
3   Prospect Heights

What I want to know is which boroughID has the
most area's assocated with it, and how many.

So I tried this:

SELECT max(count(*)) FROM  `bsp_area` GROUP  BY
boroughID

...and got an Invalid use of group function error.

Anyone think of another way to do this in a single
SQL statement, or some other simple method?
--
Skip Evans
Big Sky Penguin, LLC
61 W Broadway
Butte, Montana 59701
406-782-2240

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





--
Dave W


[PHP-DB] making an array from data in textfile

2006-07-22 Thread Dave W

OK, so I have this text file that holds a list of ip addresses like this:
127.0.0.1,127.0.0.1,127.0.0.1,127.0.0.1,127.0.0.1

Currently, here is my code:

   $file = 'ip.txt';
   $fh = fopen($file, 'r');
$theData = fread($fh, filesize($file));
fclose($fh);
$ips = array($theData);

Since it's a numeric array, I shouldn't need quotes around the ip octets.
When I try to echo certain parts of the array like:

echo $ips[0];

It's returning the whole array. The text file is exactly like an array so it
shouldn't be a problem.



--
Dave W


[PHP-DB] Re: making an array from data in textfile

2006-07-22 Thread Dave W

OK, well I did a debug and this is whats coming out:

Array
(
   [0] = 127.0.0.1,127.0.0.1,127.0.0.1
)

Should I use fgets?

On 7/22/06, Dave W [EMAIL PROTECTED] wrote:


OK, so I have this text file that holds a list of ip addresses like this:
127.0.0.1,127.0.0.1,127.0.0.1, 127.0.0.1,127.0.0.1

Currently, here is my code:

$file = 'ip.txt';
$fh = fopen($file, 'r');
$theData = fread($fh, filesize($file));
fclose($fh);
$ips = array($theData);

Since it's a numeric array, I shouldn't need quotes around the ip octets.
When I try to echo certain parts of the array like:

echo $ips[0];

It's returning the whole array. The text file is exactly like an array so
it shouldn't be a problem.



--
Dave W





--
Dave W


Re: [PHP-DB] Discussion board integration

2006-07-19 Thread Dave W

Yea, phpBB2 is tough to integrate. I've been working with MyBB and I think
it's great! The templating is very simple (By bb standards). It's less
mature than phpBB, but they fix bugs faster and is quickly becoming very
stable. It works a lot like vBulletin except it's free and open source. I
know there is SMF too, but I don't use it, so I really can't tell you
anything about it.

On 7/19/06, Skip Evans [EMAIL PROTECTED] wrote:


Hey all,

I've got a requirement for a discussion board on a
new site we are building for a client.

I've integrated phpBB2 for discussion onto
existing sites before, but was wondering if anyone
had any experience with other PHP discussion
boards they favored over phpBB2.

I found the login integration of BB2 especially
troublesome, though I did get it to work in the end.

--
Skip Evans
Big Sky Penguin, LLC
61 W Broadway
Butte, Montana 59701
406-782-2240

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





--
Dave W


Re: [PHP-DB] Submitting form from a href

2006-07-17 Thread Dave W

The problem with GET is that a user that looks at the source code of the
html can easily just input what they want for the argument. Can you say SQL
injection?

On 7/17/06, Sean Mumford [EMAIL PROTECTED] wrote:


Couldn't you achieve the same effect without javascript by simply using
GET
values instead of post? As in each hyperlink would say something like a
href=search.php?letter=aA/a a href=search.php?letter=bB/a,
although perhaps you're trying to intentionally avoid using GET as to not
clutter up their browser history.
..
-Original Message-
From: Andrew Kreps [mailto:[EMAIL PROTECTED]
Sent: Friday, July 14, 2006 7:15 PM
To: Skip Evans
Cc: Php-Db
Subject: Re: [PHP-DB] Submitting form from a href

Skip,

Just so you know, there is a general PHP user's list available for just
such
a request.  It's rather high-traffic, so be warned.

Now then, on to the problem.  I believe I've figured out a way to make
this
happen.  I've only tested it on IE 6 and Firefox 1.5.0.4, so your browser
compatibility may vary.  I'll just post the scripts I used to test it here
and you can take what you need and run with it.

Here is the script that my form is built in:

--

html
head
script language=Javascript
function submitForm (letter)
{
document.search.letter.value =
letter;//
Here's where we're
setting the form value 'letter' to the letter the user clicked on.
document.search.submit();   // Then,
submit
the form.
}
/script
/head
body
form name=search method=POST
action=testingLinkSubmit.php
input type=hidden name=letter value=  !--
If this isn't here, the Javascript letter.value code won't work, since
form.letter doesn't exist.  --
input type=checkbox name=checky/ Search all
campuses
br

?
for ($i = 65;  $i = 90;  $i++)
{
$letter = chr($i);
print a
href=\javascript:submitForm('$letter')\$letter/a ;
}
?
/form
/body
/html

-

The receiving end of the form looks much as you might expect, it just
parses
the form values:

--

html
body
?
if (isset($_POST[checky]))
{
print Checkbox value is: Truebr\n;
}
else
{
print Checkbox value is: Falsebr\n; }

print Letter:  . $_POST[letter];
?
/body
/html



And there you go!  Let me know if you have any problems.



On 7/14/06, Skip Evans [EMAIL PROTECTED] wrote:
 Hey all,

 This is not database related, but I get the impression this list
 entertains general PHP questions? If I'm mistaken, flame away.

 I need submit a form when a hyper link is pressed, and have been
 trying all manner of onlicks, etc, but have been unable to hit the
 right combination.

 Here's the scenario:

 I have the alphabet in hyper links with a check box below:


 form...
 A B C D E F G H I J K.

 [] check for all campuses
 /form

 What needs to happen is that when they click a
 letter, which is a a href=... now, it submits
 the check box value as well, to be read through
 $_POST on the receiving end.

 And of course I need to know what letter was
 click, this I was trying to get through a
 $_REQUEST var, but was not able to do so.

 Any tips would be monstrously appreciated.
 --
 Skip Evans
 Big Sky Penguin, LLC
 61 W Broadway
 Butte, Montana 59701
 406-782-2240

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

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





--
Dave W


[PHP-DB] detecting negative numbers

2006-07-16 Thread Dave W

Currently I have this:

if($quant  $amount) {echo You don't have that many!; }

$quant is the user inputted amount and $amount is the amount that they
actually have. Is there any way of checking if the result is negative rather
than doing what I have above?

--
Dave W


Re: [PHP-DB] detecting negative numbers

2006-07-16 Thread Dave W

They are both positive numbers. I want to see if, when subtract, do they
equal a negative number?

On 7/16/06, Peter Beckman [EMAIL PROTECTED] wrote:


On Sun, 16 Jul 2006, Dave W wrote:

 Currently I have this:

 if($quant  $amount) {echo You don't have that many!; }

 $quant is the user inputted amount and $amount is the amount that they
 actually have. Is there any way of checking if the result is negative
rather
 than doing what I have above?

  I'm not sure which result you are refering to, but this echo's if:
 $quant is greater than $amount
 $amount is less than 0
 $quant is less than 0

  if ($quant  $amount or $amount  0 or $quant  0) {
 echo You don't have that many!;
  }


---
Peter Beckman  Internet
Guy
[EMAIL PROTECTED]
http://www.purplecow.com/

---





--
Dave W


Re: [PHP-DB] detecting negative numbers

2006-07-16 Thread Dave W

No, I get it. I just thought that there might have been some built in
function like if(neg_num($quant - $amount))
or something like that. I know how to do it, but I thought that there might
have been an alternate method. Just because I asked a simple question
doesn't mean I'm stupid, I'm just curious if there is a simpler way to do an
already simple task.

On 7/16/06, Stut [EMAIL PROTECTED] wrote:


-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Dave W wrote:
 Currently I have this:

 if($quant  $amount) {echo You don't have that many!; }

 $quant is the user inputted amount and $amount is the amount that they
 actually have. Is there any way of checking if the result is negative
 rather
 than doing what I have above?

Not sure which way around you want it, but I think this is what you are
after...

if (($quant - $amount)  0)
{
echo You don't have that many!;
}

I don't mean any offense, but the possibility that someone who couldn't
figure that out is writing PHP code scares me. You might want to think
about Googling for an absolute beginners guide to programming before
continuing.

- -Stut
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.2.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFEusYz2WdB7L+YMm4RAqGPAJ0QqkgfApO6h0GR9lXa47WyAhSsugCfaymW
Ba+bqZRbrcv6CuZ6g7FJJjw=
=ktnc
-END PGP SIGNATURE-





--
Dave W


Re: [PHP-DB] Re: posting information from a textarea

2006-07-07 Thread Dave W

Ha! I figured the damn thing out! Using the full text type created a bunch
of overhead and it wasn't storing it into the table. I realized that I was
unsetting the post array before I was doing the print_r so that is why the
variables weren't showing up. Then, I finally realized that for some reason,
I had to convert the textarea to a utf encoding before I entered it into the
database! That was annoying.

On 7/6/06, Dave W [EMAIL PROTECTED] wrote:


I think I might have found the problem, but I'm not sure how to fix it.
I'm just going to rebuild the form and it make it seperate (with all the
database calls in one page). For some reason, if I add another field before
the motto and i change it, it changes motto too...w/e I'll just make a new
one.

On 7/6/06, Dave W [EMAIL PROTECTED] wrote:

 hmm..interesting. Neither the motto or desc is showing up in the array.
 I made a simple form and the

 echo 'post vars: ' . print_r($_POST, true) . 'br/';

 works fine. I'm just perplexed on why the motto is still working and not
 the desc. Maybe it's because I'm using a fieldset, but then why wouldn't
 just one not work?

 On 7/6/06, Chris  [EMAIL PROTECTED] wrote:

  Dave W wrote:
   I'll show you all the steps it passes through.
   Here's the form:
  
form action=proc.php method=post
   fieldset
   label for=MottoMotto:/label
   input class=text type=text size=25
  name=motto
   value=?php if($form-value(motto) == ){
  echo $session-nationinfo['motto'];
   }else{
  echo $form-value(motto);
   } ? /
   label for=descNation Description:/label
   textarea name=desc cols=50 rows=5?php
   if($form-value(desc) == ){
  echo $session-nationinfo['desc'];
   }else{
  echo $form-value(desc);
   }
   ?/textarea
   input type=submit value= Edit Nation  /
/fieldset
   /form
  
   It's echoing the nationinfo right, but its not posting it. The motto
   also works too. When it's submitted, it goes through the function
   procEditNation().
  
   $session-editNation($_POST['motto'], $_POST['desc']);
  
   The editNation function:
  
  function editNation($motto, $desc){
 global $database, $form;
  
 if($motto){
$field = motto;
$motto = htmlspecialchars($motto);
$database-updateNationField($this-username,motto,$motto);
 
  
}
  
 if($desc){
$field = desc;
$desc = htmlspecialchars($desc);
$database-updateNationField($this-username,desc,$desc);
 
  
  
 }
  
 return true;
  }
  
   Then finally the updateNationField function:
  
  function updateNationField($username, $field, $value){
 $q = UPDATE nations SET .$field. = '$value' WHERE username
  =
   '$username';
 return mysql_query($q, $this-connection);
  }
  
   I just don't know what's wrong since it's posting the motto (which
  is
   just a text-type input) and not the description (which is a
  textarea). I
   echo'd out the mysql queries and excuted them myself from what
  echo'd
   out and it's selecting the desc column just fine.
 
  That definitely all looks fine.
 
  If you do:
 
  echo 'post vars: ' . print_r($_POST, true) . 'br/';
 
  does it show up in post at all?
 
  --
  Postgresql  php tutorials
  http://www.designmagick.com/
 



 --
 Dave W




--
Dave W





--
Dave W


[PHP-DB] Re: posting information from a textarea

2006-07-06 Thread Dave W

O, I also tried to change it to a $_FILES array, but that didn't work
either.
On 7/6/06, Dave W [EMAIL PROTECTED] wrote:


I seem to be having a problem posting text from a text area. I have a form
that posts data into a database and there are input fields which seem to
post the data fine. I know this because the entry is changing in the
database, but the text area text doesn't seem to be posting. I double
checked to make sure i got the names right, but it still doesn't seem to be
working. Before I put it into the database I'm using stripslashes. I thought
that might of been the problem and I changed it to trim, but that didn't
work. In the database, the field that I'm putting it into is a longtext type
with fulltext.

--
Dave W



[PHP-DB] posting information from a textarea

2006-07-06 Thread Dave W

I seem to be having a problem posting text from a text area. I have a form
that posts data into a database and there are input fields which seem to
post the data fine. I know this because the entry is changing in the
database, but the text area text doesn't seem to be posting. I double
checked to make sure i got the names right, but it still doesn't seem to be
working. Before I put it into the database I'm using stripslashes. I thought
that might of been the problem and I changed it to trim, but that didn't
work. In the database, the field that I'm putting it into is a longtext type
with fulltext.

--
Dave W


Re: [PHP-DB] posting information from a textarea

2006-07-06 Thread Dave W

The inputs are posting, but the textarea still isn't. Argh!

On 7/6/06, Brad Bonkoski [EMAIL PROTECTED] wrote:


stripslashes should not be needed...

if anything addslashes() may be needed if you have single quotes in the
text area.
I would say step 1 is to echo out your insert query to the page before
you even excute the insert, to verify the query, and that you are
getting the proper information from the form.
-B

Dave W wrote:

 I seem to be having a problem posting text from a text area. I have a
 form
 that posts data into a database and there are input fields which seem to

 post the data fine. I know this because the entry is changing in the
 database, but the text area text doesn't seem to be posting. I double
 checked to make sure i got the names right, but it still doesn't seem
 to be
 working. Before I put it into the database I'm using stripslashes. I
 thought
 that might of been the problem and I changed it to trim, but that didn't
 work. In the database, the field that I'm putting it into is a
 longtext type
 with fulltext.






--
Dave W


Re: [PHP-DB] Re: posting information from a textarea

2006-07-06 Thread Dave W

I'll show you all the steps it passes through.
Here's the form:

form action=proc.php method=post
   fieldset
   label for=MottoMotto:/label
   input class=text type=text size=25 name=motto
value=?php if($form-value(motto) == ){
  echo $session-nationinfo['motto'];
}else{
  echo $form-value(motto);
} ? /
   label for=descNation Description:/label
   textarea name=desc cols=50 rows=5?php
if($form-value(desc) == ){
  echo $session-nationinfo['desc'];
}else{
  echo $form-value(desc);
}
?/textarea
input type=submit value= Edit Nation  /
/fieldset
/form

It's echoing the nationinfo right, but its not posting it. The motto also
works too. When it's submitted, it goes through the function
procEditNation().

$session-editNation($_POST['motto'], $_POST['desc']);

The editNation function:

  function editNation($motto, $desc){
 global $database, $form;

 if($motto){
$field = motto;
$motto = htmlspecialchars($motto);
$database-updateNationField($this-username,motto,$motto);

}

 if($desc){
$field = desc;
$desc = htmlspecialchars($desc);
$database-updateNationField($this-username,desc,$desc);


 }

 return true;
  }

Then finally the updateNationField function:

  function updateNationField($username, $field, $value){
 $q = UPDATE nations SET .$field. = '$value' WHERE username =
'$username';
 return mysql_query($q, $this-connection);
  }

I just don't know what's wrong since it's posting the motto (which is just a
text-type input) and not the description (which is a textarea). I echo'd out
the mysql queries and excuted them myself from what echo'd out and it's
selecting the desc column just fine.



On 7/6/06, Chris [EMAIL PROTECTED] wrote:


Dave W wrote:
 I saw this bug: http://bugs.php.net/bug.php?id=22427. Could this be
related
 to problem I'm having?


Actually, show us the form you're trying to submit before doing anything
else. Since we haven't seen any html or php code, guessing it's a bug is
a bit of a stretch.

--
Postgresql  php tutorials
http://www.designmagick.com/

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





--
Dave W


Re: [PHP-DB] Re: posting information from a textarea

2006-07-06 Thread Dave W

hmm..interesting. Neither the motto or desc is showing up in the array. I
made a simple form and the
echo 'post vars: ' . print_r($_POST, true) . 'br/';

works fine. I'm just perplexed on why the motto is still working and not the
desc. Maybe it's because I'm using a fieldset, but then why wouldn't just
one not work?

On 7/6/06, Chris [EMAIL PROTECTED] wrote:


Dave W wrote:
 I'll show you all the steps it passes through.
 Here's the form:

  form action=proc.php method=post
 fieldset
 label for=MottoMotto:/label
 input class=text type=text size=25 name=motto
 value=?php if($form-value(motto) == ){
echo $session-nationinfo['motto'];
 }else{
echo $form-value(motto);
 } ? /
 label for=descNation Description:/label
 textarea name=desc cols=50 rows=5?php
 if($form-value(desc) == ){
echo $session-nationinfo['desc'];
 }else{
echo $form-value(desc);
 }
 ?/textarea
 input type=submit value= Edit Nation  /
  /fieldset
 /form

 It's echoing the nationinfo right, but its not posting it. The motto
 also works too. When it's submitted, it goes through the function
 procEditNation().

 $session-editNation($_POST['motto'], $_POST['desc']);

 The editNation function:

function editNation($motto, $desc){
   global $database, $form;

   if($motto){
  $field = motto;
  $motto = htmlspecialchars($motto);
  $database-updateNationField($this-username,motto,$motto);

  }

   if($desc){
  $field = desc;
  $desc = htmlspecialchars($desc);
  $database-updateNationField($this-username,desc,$desc);


   }

   return true;
}

 Then finally the updateNationField function:

function updateNationField($username, $field, $value){
   $q = UPDATE nations SET .$field. = '$value' WHERE username =
 '$username';
   return mysql_query($q, $this-connection);
}

 I just don't know what's wrong since it's posting the motto (which is
 just a text-type input) and not the description (which is a textarea). I
 echo'd out the mysql queries and excuted them myself from what echo'd
 out and it's selecting the desc column just fine.

That definitely all looks fine.

If you do:

echo 'post vars: ' . print_r($_POST, true) . 'br/';

does it show up in post at all?

--
Postgresql  php tutorials
http://www.designmagick.com/





--
Dave W


Re: [PHP-DB] Re: posting information from a textarea

2006-07-06 Thread Dave W

I think I might have found the problem, but I'm not sure how to fix it. I'm
just going to rebuild the form and it make it seperate (with all the
database calls in one page). For some reason, if I add another field before
the motto and i change it, it changes motto too...w/e I'll just make a new
one.

On 7/6/06, Dave W [EMAIL PROTECTED] wrote:


hmm..interesting. Neither the motto or desc is showing up in the array. I
made a simple form and the

echo 'post vars: ' . print_r($_POST, true) . 'br/';

works fine. I'm just perplexed on why the motto is still working and not
the desc. Maybe it's because I'm using a fieldset, but then why wouldn't
just one not work?

On 7/6/06, Chris [EMAIL PROTECTED] wrote:

 Dave W wrote:
  I'll show you all the steps it passes through.
  Here's the form:
 
   form action=proc.php method=post
  fieldset
  label for=MottoMotto:/label
  input class=text type=text size=25 name=motto
  value=?php if($form-value(motto) == ){
 echo $session-nationinfo['motto'];
  }else{
 echo $form-value(motto);
  } ? /
  label for=descNation Description:/label
  textarea name=desc cols=50 rows=5?php
  if($form-value(desc) == ){
 echo $session-nationinfo['desc'];
  }else{
 echo $form-value(desc);
  }
  ?/textarea
  input type=submit value= Edit Nation  /
   /fieldset
  /form
 
  It's echoing the nationinfo right, but its not posting it. The motto
  also works too. When it's submitted, it goes through the function
  procEditNation().
 
  $session-editNation($_POST['motto'], $_POST['desc']);
 
  The editNation function:
 
 function editNation($motto, $desc){
global $database, $form;
 
if($motto){
   $field = motto;
   $motto = htmlspecialchars($motto);
   $database-updateNationField($this-username,motto,$motto);

 
   }
 
if($desc){
   $field = desc;
   $desc = htmlspecialchars($desc);
   $database-updateNationField($this-username,desc,$desc);
 
 
}
 
return true;
 }
 
  Then finally the updateNationField function:
 
 function updateNationField($username, $field, $value){
$q = UPDATE nations SET .$field. = '$value' WHERE username =
  '$username';
return mysql_query($q, $this-connection);
 }
 
  I just don't know what's wrong since it's posting the motto (which is
  just a text-type input) and not the description (which is a textarea).
 I
  echo'd out the mysql queries and excuted them myself from what echo'd
  out and it's selecting the desc column just fine.

 That definitely all looks fine.

 If you do:

 echo 'post vars: ' . print_r($_POST, true) . 'br/';

 does it show up in post at all?

 --
 Postgresql  php tutorials
 http://www.designmagick.com/




--
Dave W





--
Dave W


[PHP-DB] splitting string from database

2006-07-03 Thread Dave W

Hi,
I am trying to take a number from a MySQL database and then split it into
different strings using a comma. It's for display a cash amount into a
table. It's stored in the database as something like 100 and I want for
it to display as 1,000,000 on the table. This is what I got so far:

?php
  echo table align=\left\ border=\1\ cellspacing=\0\
cellpadding=\3\\n;
  echo trtdbCash/b/td/tr\n;
  for($i=0; $i$num_rows; $i++){
 $cash  = mysql_result($result,$i,cash);
 echo trtd$cash/td/tr\n;
  }
  echo /tablebr\n;
?

All this does is return the number. I tried using explode and split, but I
couldn't get either to work...It just kept saying Array in the cell. I also
tried strtok.

--
Dave W


Re: [PHP-DB] Cron unlink

2006-07-02 Thread Dave W

You have to use the absolute (or server, whatever you want to call it) path.
So like/home/www/sessions/files/ or whatever it is.

On 7/2/06, Ron Piggott (PHP) [EMAIL PROTECTED] wrote:


Does anyone have experience in getting unlink to work within the context
of a cron?

I created my own garbage collection function and I am trying to delete
some session files through a cron that runs every 10 minutes.

The session files are owned by 'www'
The cron is ran by 'actsmin'

The 'unlink' command works within the context of a php script when
activated by a user on the web site.

Is there another file deletion command within PHP other than unlink?

Here is the error message I am e-mailed by the cron when it doesn't
successfully delete a session file:


 Warning: unlink(/path/to/sessions/files/):
 Is a directory in /path/to/php/script/cron/calls/script.php on line 47

Any suggestions?

Ron

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





--
Dave W


Re: [PHP-DB] Cron unlink

2006-07-02 Thread Dave W

oops. yea, chris is right. I thought you were trying to delete files.

On 7/2/06, Dave W [EMAIL PROTECTED] wrote:


You have to use the absolute (or server, whatever you want to call it)
path. So like/home/www/sessions/files/ or whatever it is.


On 7/2/06, Ron Piggott (PHP) [EMAIL PROTECTED] wrote:

 Does anyone have experience in getting unlink to work within the context
 of a cron?

 I created my own garbage collection function and I am trying to delete
 some session files through a cron that runs every 10 minutes.

 The session files are owned by 'www'
 The cron is ran by 'actsmin'

 The 'unlink' command works within the context of a php script when
 activated by a user on the web site.

 Is there another file deletion command within PHP other than unlink?

 Here is the error message I am e-mailed by the cron when it doesn't
 successfully delete a session file:


  Warning: unlink(/path/to/sessions/files/):
  Is a directory in /path/to/php/script/cron/calls/script.php on line 47


 Any suggestions?

 Ron

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




--
Dave W





--
Dave W


Re: [PHP-DB] ftp_connect($ftp_server);

2006-07-01 Thread Dave W

Use the unlink function:

$myFile = testFile.txt;
unlink($myFile);



On 7/1/06, Ron Piggott (PHP) [EMAIL PROTECTED] wrote:


Every now and then the following command fails --- the FTP connection is
refused by the server:

$conn_id = ftp_connect($ftp_server);

Is there a way to delete a file within PHP without having to FTP to the
server?

Ron

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





--
Dave W


Re: [PHP-DB] 時間の価値

2006-06-12 Thread Dave W

argh! Whatever jap is being stupid and spamming the list, please stop!

On 6/12/06, sakie [EMAIL PROTECTED] wrote:


1年の価値を知るには
卒業試験に落ちた学生に 聞いてみなさい

1ヶ月の価値を知るには
未熟児を産んだお母さんに 聞いてみなさい

1週間の価値を知るには
週刊誌の編集者に 聞いてみなさい

1時間の価値を知るには
会うのが待ちきれない恋人達に 聞いてみなさい

1分の価値を知るには
電車やバス、飛行機に乗り遅れた人に 聞いてみなさい

1秒の価値を知るには
事故で生き残った人に 聞いてみなさい

千分の1秒の価値を知るには
オリンピックで銀メダルを獲った人に 聞いてみなさい

時間は待ってくれません
あなたの持っている全ての時間を大切にしなさい




そしてここで全てを発散しなさい

http://vqlh.com/?jy111






拒否
[EMAIL PROTECTED]





--
Dave W