[PHP] subtitute of mysql_error()

2007-08-01 Thread Patrik Hasibuan
Dear my friends

What is the substitute of mysql_error() ?

This line of my code does not work anymore:
$hslgbr=mysql_query($sqlgbr,$konek) or die ( mysql_error() 
);

Thank you very much in advance.
-- 
Patrik Hasibuan [EMAIL PROTECTED]
Junior Programmer

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



[PHP] I am confused to mysql_query.

2007-08-01 Thread Patrik Hasibuan
Dear my friends...

This sql string produces proper output in my MySQL-Query:
select image_src from products where product_id='10';
the output is:
gambarproduk/0/10/1.jpg

But my php code does not produce anything.

Please tell me what is my mistake.
===
?php
if (isset($pid)){
$koneksi=mysql_connect(127.0.0.1,root,mysuccess);
$stringsql=select style, 
description,
price 
from styles 
where product_id='$pid';;
$hsl=mysql_query($stringsql,$koneksi);
while ($brs=mysql_fetch_row($hsl)){
list($edisi,$deskripsi,$harga)=$brs;
}   

$konek=mysql_connect(127.0.0.1,root,mysuccess);
if ($konek){ 
echo konek berhasil br;
$sqlgbr=select image_src 
from products 
where product_id='$pid';;
echo $sqlgbr br;
$hslgbr=mysql_query($sqlgbr,$konek);
if (!$hslgbr){ 
echo query gambarproduk tidak berhasil br; 
}elseif ($hslgbr){
echo array gambar;
}
while ($brsgbr=mysql_fetch_row($hslgbr)){
list($gambarproduk)=$brsgbr;
echo urlgambar: $gambarproduk br;
}
}
}   
?
===
-- 
Patrik Hasibuan [EMAIL PROTECTED]
Junior Programmer

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



Re: [PHP] Reading registry values

2007-08-01 Thread Travis D
On 7/31/07, Crash Dummy [EMAIL PROTECTED] wrote:

  Hope this isn't overkill but it is a module (read COM, or VBA
 module)
  to manipulate the registry:

 Overkill is a massive understatement. :-)



No doubt.

To answer everyone's curiosity as to why I want to access the registry, I am
 working on my home computer with a dynamic IP, and I need to know what it
 is so
 I can modify my httpd.conf (or hosts) file, if necessary.


You might use http://www.php.net/reserved.variables SERVER_ADDR to get the
address of the host you are running under if you wanted to access it from
PHP only.

Travis Doherty


Re: [PHP] global variable does not exist anymore?

2007-08-01 Thread Patrik Hasibuan
OK, Thanks Richards.
===
On Wed, 25 Jul 2007 23:54:37 +0100
Richard Davey [EMAIL PROTECTED] wrote:

 Hi Patrik,
 
 Wednesday, July 25, 2007, 11:30:56 PM, you wrote:
 
  Dear my friends...
 
  I create a very simple script in html and php as a first step. I use suse, 
  apache2, mysql and php.
 
  I wonder why this script does not work:
  !DOCTYPE html PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN
  html
  head
 
meta content=text/html; charset=ISO-8859-1 http-equiv=content-type
titleGuru - Virtual bookstore who understands you for those want to be 
  a GURU/title
 
 
  /head
  body
 
  Help us for statistic data collection for increasing our service by 
  'filling our guestbook'.br
  form action=cgi/cgibukutamu.php method=post
  table
  trtd align=rightName: /tdtd align=leftinput
  type=text name=tfnama/td/tr
  trtd align=rightLocation: /tdtd align=leftinput
  type=text name=tflokasi/td/tr
  trtd align=rightE-Mail: /tdtd align=leftinput
  type=text name=tfemail/td/tr
  trtd align=rightURL: /tdtd align=leftinput type=text 
  name=tfurl/td/tr
  trtd align=rightComments: /tdtd align=leftinput
  type=text name=tfkomentar/td/tr
  trtd align=rightinput type=submit/tdtd
  align=leftinput type=reset/td/tr
  /table
  /form
 
  /body
  /html
 
  The value of tfnama is empty.
  cgi/cgibukutamu.php
  html
  table
  trtd/tdtd/td/tr
  trtd align=rightName/tdtd align=left?php echo $tfnama 
  ?/td/tr
  /table
  /html
 
  I had a look the into the /etc/apache2 but I didn't find any
  global_variable switch as I used to find in httpd.conf
  
  suseonthelap:/etc/apache2 # grep -n -r global_variable ./*
  suseonthelap:/etc/apache2 #  
  
 
  I got used to find global_variable=on line in the httpd.conf.
 
 Try looking in php.ini
 
 Then leave it disabled, and code your script properly so it checks the
 user input and validates it before using it.
 
 Cheers,
 
 Rich
 -- 
 Zend Certified Engineer
 http://www.corephp.co.uk
 
 Never trust a computer you can't throw out of a window
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 


-- 
Patrik Hasibuan [EMAIL PROTECTED]
Junior Programmer

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



Re: [PHP] Unexpected values in an associative array

2007-08-01 Thread Travis D
On 7/31/07, Ken Tozier [EMAIL PROTECTED] wrote:

 ...

   // set fetch prefs
 $this-db-setAttribute(PDO:: FETCH_ASSOC,
 true);   // also tried 1
  ...

Is that the way to do it?


Hmm.. Maybe I sent you in the wrong direction - I can't find any docs on
using setAttribute to set the fetch mode.  Anyway, setAttribute always works
like this:
setAttribute(attribute_to_set,value_to_set_to);

I was expecting something like:
setAttribute(PDO::FETCH_MODE, PDO::FETCH_ASSOC);

I don't think that works though, can't find anything in docs relating to
attribute called FETCH_MODE.  Anyway I dug in some code and this is what you
can do:

foreach ($pdo-query($query, PDO::FETCH_ASSOC)) {}

Query can take a second parameter.

Another option:
PDOStatement-setFetchMode(PDO::FETCH_ASSOC).. so your original code goes
from:

foreach ($pdo-query($query) as $row) {}

To:

$statement = $pdo-query($query);
$statement-setFetchMode(PDO::FETCH_ASSOC);
foreach( $statement as $row) {}

There must be a way to set it with setAttribute for the connection though,
instead of just on a per-statement basis...

Travis Doherty


Re: [PHP] global variable does not exist anymore?

2007-08-01 Thread Patrik Hasibuan
Thank you very much.
===
On Fri, 27 Jul 2007 00:26:24 -0500 (CDT)
Richard Lynch [EMAIL PROTECTED] wrote:

 It's register_globals, and you should fix this ancient script to not
 rely on register_globals being on
 
 On Wed, July 25, 2007 5:30 pm, Patrik Hasibuan wrote:
  Dear my friends...
 
  I create a very simple script in html and php as a first step. I use
  suse, apache2, mysql and php.
 
  I wonder why this script does not work:
  !DOCTYPE html PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN
  html
  head
 
meta content=text/html; charset=ISO-8859-1
  http-equiv=content-type
titleGuru - Virtual bookstore who understands you for those want
  to be a GURU/title
 
 
  /head
  body
 
  Help us for statistic data collection for increasing our service by
  'filling our guestbook'.br
  form action=cgi/cgibukutamu.php method=post
  table
  trtd align=rightName: /tdtd align=leftinput type=text
  name=tfnama/td/tr
  trtd align=rightLocation: /tdtd align=leftinput
  type=text name=tflokasi/td/tr
  trtd align=rightE-Mail: /tdtd align=leftinput type=text
  name=tfemail/td/tr
  trtd align=rightURL: /tdtd align=leftinput type=text
  name=tfurl/td/tr
  trtd align=rightComments: /tdtd align=leftinput
  type=text name=tfkomentar/td/tr
  trtd align=rightinput type=submit/tdtd
  align=leftinput type=reset/td/tr
  /table
  /form
 
  /body
  /html
 
  The value of tfnama is empty.
  cgi/cgibukutamu.php
  html
  table
  trtd/tdtd/td/tr
  trtd align=rightName/tdtd align=left?php echo $tfnama
  ?/td/tr
  /table
  /html
 
  I had a look the into the /etc/apache2 but I didn't find any
  global_variable switch as I used to find in httpd.conf
  
  suseonthelap:/etc/apache2 # grep -n -r global_variable ./*
  suseonthelap:/etc/apache2 #
  
 
  I got used to find global_variable=on line in the httpd.conf.
 
  What should I do now? Please tell me.
  --
  Patrik Hasibuan [EMAIL PROTECTED]
  Junior Programmer
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 
 
 -- 
 Some people have a gift link here.
 Know what I want?
 I want you to buy a CD from some indie artist.
 http://cdbaby.com/browse/from/lynch
 Yeah, I get a buck. So?
 
 
 


-- 
Patrik Hasibuan [EMAIL PROTECTED]
Junior Programmer

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



Re: [PHP] I am confused to mysql_query.

2007-08-01 Thread Patrik Hasibuan
Hi Sichta,

That's what I am confused. Quoted or no Quote makes no effect. mysql_query does 
not work.

I tried to debug with ..or die (mysql_error()); but it seems mysql_error() 
does not exist anymore.

Please keep telling me. I've wasted to much time today hanging around with this 
weird problem.

On Wed, 1 Aug 2007 08:27:51 +0200
Sichta, Daniel [EMAIL PROTECTED] wrote:

 Hi ,
 
 Try this:
   $hsl=mysql_query($stringsql,$koneksi); 
 
 DS
 
 -Original Message-
 From: Patrik Hasibuan [mailto:[EMAIL PROTECTED] 
 Sent: Wednesday, August 01, 2007 8:23 AM
 To: php-general@lists.php.net
 Subject: [PHP] I am confused to mysql_query.
 
 Dear my friends...
 
 This sql string produces proper output in my MySQL-Query:
 select image_src from products where product_id='10';
 the output is:
 gambarproduk/0/10/1.jpg
 
 But my php code does not produce anything.
 
 Please tell me what is my mistake.
 ===
 ?php
 if (isset($pid)){
   $koneksi=mysql_connect(127.0.0.1,root,mysuccess);
   $stringsql=select style, 
   description,
   price 
   from styles 
   where product_id='$pid';;
   $hsl=mysql_query($stringsql,$koneksi);
   while ($brs=mysql_fetch_row($hsl)){
   list($edisi,$deskripsi,$harga)=$brs;
   }   
   
   $konek=mysql_connect(127.0.0.1,root,mysuccess);
   if ($konek){ 
   echo konek berhasil br;
   $sqlgbr=select image_src 
   from products 
   where product_id='$pid';;
   echo $sqlgbr br;
   $hslgbr=mysql_query($sqlgbr,$konek);
   if (!$hslgbr){ 
   echo query gambarproduk tidak berhasil br; 
   }elseif ($hslgbr){
   echo array gambar;
   }
   while ($brsgbr=mysql_fetch_row($hslgbr)){
   list($gambarproduk)=$brsgbr;
   echo urlgambar: $gambarproduk br;
   }
   }
 } 
 ?
 ===
 -- 
 Patrik Hasibuan [EMAIL PROTECTED]
 Junior Programmer
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 


-- 
Patrik Hasibuan [EMAIL PROTECTED]
Junior Programmer

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



[PHP] DOMDocument - loadHTML() cuts off html input

2007-08-01 Thread Stijn Verholen

Hey List,

In my application, I am loading html content into a DOMDocument using 
loadHTML(). The DOMDocument is validated, then the element with a 
certain ID tag is extracted and loaded into a node in the main 
DOMDocument, which is then presented as html with saveHTML().


This works fine and has worked fine for relatively large pages 
(containing several select lists with up to 400 options in total).


The problem I am now facing is a page with a single, relatively large 
select list, i.e. some 330 options.
The html is generated as expected. However when I load it into a 
DOMDocument and saveHTML(), the select list is cut off to about 30 
options. The remainder of the html content dissappears
and instead, the remaining open tags are closed, presumably by 
DOMDocument's saveHTML() method.


Any ideas as to why this behaviour is occurring and how to fix it ?
Further information available if needed.

Thanks in advance,

Stijn

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



Re: [PHP] I am confused to mysql_query.

2007-08-01 Thread Patrik Hasibuan
Sorry, for my recklessness

I missed, $bdku=mysql_select_db(guru,$konek);

Es ist peinlich It's embarassing.

But thanks for your help.
=
On Wed, 1 Aug 2007 15:15:43 +0700
Patrik Hasibuan [EMAIL PROTECTED] wrote:

 Hi Sichta,
 
 That's what I am confused. Quoted or no Quote makes no effect. mysql_query 
 does not work.
 
 I tried to debug with ..or die (mysql_error()); but it seems 
 mysql_error() does not exist anymore.
 
 Please keep telling me. I've wasted to much time today hanging around with 
 this weird problem.
 
 On Wed, 1 Aug 2007 08:27:51 +0200
 Sichta, Daniel [EMAIL PROTECTED] wrote:
 
  Hi ,
  
  Try this:
  $hsl=mysql_query($stringsql,$koneksi); 
  
  DS
  
  -Original Message-
  From: Patrik Hasibuan [mailto:[EMAIL PROTECTED] 
  Sent: Wednesday, August 01, 2007 8:23 AM
  To: php-general@lists.php.net
  Subject: [PHP] I am confused to mysql_query.
  
  Dear my friends...
  
  This sql string produces proper output in my MySQL-Query:
  select image_src from products where product_id='10';
  the output is:
  gambarproduk/0/10/1.jpg
  
  But my php code does not produce anything.
  
  Please tell me what is my mistake.
  ===
  ?php
  if (isset($pid)){
  $koneksi=mysql_connect(127.0.0.1,root,mysuccess);
  $stringsql=select style, 
  description,
  price 
  from styles 
  where product_id='$pid';;
  $hsl=mysql_query($stringsql,$koneksi);
  while ($brs=mysql_fetch_row($hsl)){
  list($edisi,$deskripsi,$harga)=$brs;
  }   
  
  $konek=mysql_connect(127.0.0.1,root,mysuccess);
  if ($konek){ 
  echo konek berhasil br;
  $sqlgbr=select image_src 
  from products 
  where product_id='$pid';;
  echo $sqlgbr br;
  $hslgbr=mysql_query($sqlgbr,$konek);
  if (!$hslgbr){ 
  echo query gambarproduk tidak berhasil br; 
  }elseif ($hslgbr){
  echo array gambar;
  }
  while ($brsgbr=mysql_fetch_row($hslgbr)){
  list($gambarproduk)=$brsgbr;
  echo urlgambar: $gambarproduk br;
  }
  }
  }   
  ?
  ===
  -- 
  Patrik Hasibuan [EMAIL PROTECTED]
  Junior Programmer
  
  -- 
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
  
  
  
 
 
 -- 
 Patrik Hasibuan [EMAIL PROTECTED]
 Junior Programmer


-- 
Patrik Hasibuan [EMAIL PROTECTED]
Junior Programmer

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



[PHP] [possible re-post] [Fwd: DOMDocument - loadHTML() cuts off html input]

2007-08-01 Thread Stijn Verholen
I'm not sure if my previous mail got through. If that is the case, I 
apologize.




Hey List,

In my application, I am loading html content into a DOMDocument using 
loadHTML(). The DOMDocument is validated, then the element with a 
certain ID tag is extracted and loaded into a node in the main 
DOMDocument, which is then presented as html with saveHTML().


This works fine and has worked fine for relatively large pages 
(containing several select lists with up to 400 options in total).


The problem I am now facing is a page with a single, relatively large 
select list, i.e. some 330 options.
The html is generated as expected. However when I load it into a 
DOMDocument and saveHTML(), the select list is cut off to about 30 
options. The remainder of the html content dissappears
and instead, the remaining open tags are closed, presumably by 
DOMDocument's saveHTML() method.


Any ideas as to why this behaviour is occurring and how to fix it ?
Further information available if needed.

Thanks in advance,

Stijn



--


metastable
Stijn Verholen
Camille Huysmanslaan 114, bus 2
B-2020 ANTWERPEN
+32 (0)3 707 08 08
+32 (0)473 47 62 88
[EMAIL PROTECTED]
http://www.metastable.be

BTW-BE 0873.645.643
bankrek.nr. ING 363-0106543-77

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



[PHP] $_POST- Vars - Back-Button

2007-08-01 Thread Christian Hänsel

Hi guys,

this might be a noob- question, but I simply do not care anymore. After a 
few hours of fiddling with this @/**%$ (screaming AAa), I would 
like to ask you.


So what I have is this: I have a search engine for a car market, which has 
about 30 $_POST- vars. Now when the user clicks on a result link, it takes 
him to the car details page. Now when he hits the back button, he either 
gets the Page has expired (IE) or the Wanna send the form data again 
message box (FF).


Now I would like to have kind of a back-button, so the user will see the 
reusult list again without having to deal with this.


I guess what I'm asking for is a one-click re-submission of POST data... Do 
you have a clue on how to do this?


Cheers for any answers!

Chris

--
-
My baby's first words will be
Hello World

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



Re: [PHP] $_POST- Vars - Back-Button

2007-08-01 Thread Borokov Smith

Hey Chris,

1) Use sessions (read up on it if you don't know it; in short: 
session_start() at the very beginning of your script creates a $_SESSION 
array that is persistent through subsequent page calls)
2) Submit the form to the search page and preprocess it by putting the 
post vars into the session, then use header() to relocate to the actual 
processor
3) Have the actual processor work, i.e. the result list page script, 
with the session data. Do not destroy the session data afterwards.


Now if a user uses the back-button from your result list, he will again 
reach the search page, without the 'wanna send form again' message box.
I very strongly advise you not to break the browsers back button 
functionality. It's there for a reason and people rely on it to behave 
accordingly. Don't duplicate functionality that the browser  already has.


HTH,

Stijn

Christian Hänsel schreef:

Hi guys,

this might be a noob- question, but I simply do not care anymore. 
After a few hours of fiddling with this @/**%$ (screaming 
AAa), I would like to ask you.


So what I have is this: I have a search engine for a car market, which 
has about 30 $_POST- vars. Now when the user clicks on a result link, 
it takes him to the car details page. Now when he hits the back 
button, he either gets the Page has expired (IE) or the Wanna send 
the form data again message box (FF).


Now I would like to have kind of a back-button, so the user will see 
the reusult list again without having to deal with this.


I guess what I'm asking for is a one-click re-submission of POST 
data... Do you have a clue on how to do this?


Cheers for any answers!

Chris



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



[PHP] Re: $_POST- Vars - Back-Button

2007-08-01 Thread Colin Guthrie
Christian Hänsel wrote:
 Hi guys,
 
 this might be a noob- question, but I simply do not care anymore. After
 a few hours of fiddling with this @/**%$ (screaming AAa), I
 would like to ask you.
 
 So what I have is this: I have a search engine for a car market, which
 has about 30 $_POST- vars. Now when the user clicks on a result link, it
 takes him to the car details page. Now when he hits the back button, he
 either gets the Page has expired (IE) or the Wanna send the form data
 again message box (FF).
 
 Now I would like to have kind of a back-button, so the user will see
 the reusult list again without having to deal with this.
 
 I guess what I'm asking for is a one-click re-submission of POST data...
 Do you have a clue on how to do this?

OK, you generally use post data when you want to update something - e.g.
change a value in a database or similar.

For searching, POST is generally a bad idea as it will block search
engines from indexing past the form.

That aside, if you really do want to use POST there is a technique you
can use to not break the back button, which is roughly as follows:

1. Create a form which POSTs data.
2. On the handling page, take appropriate action (update DB, write file,
store info in session.
3. Issue a header('Location: http://server/page'); to redirect to a
new page which will do the necessary output of page content (perhaps
based on the db update/session vars from the actual script handler in
step 2).

By doing the header it will cause the browser to ignore the POST handler
in terms of it's page history and so when the user hit's back it works
as expected.

Hope this helps.

Col

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



Re: [PHP] Re: Pirate PHP books online?

2007-08-01 Thread Ryan A

 
 Some light humour:
 
 http://www.unm.edu/~humanism/socvsjes.htm
 
 Cheers,
 Rob.


Hey,


I usually find your humour postings pretty funny but
didnt find that in the least bit funny... :(

Cheers!
R

--
- The faulty interface lies between the chair and the keyboard.
- Creativity is great, but plagiarism is faster!
- Smile, everyone loves a moron. :-)


   

Boardwalk for $500? In 2007? Ha! Play Monopoly Here and Now (it's updated for 
today's economy) at Yahoo! Games.
http://get.games.yahoo.com/proddesc?gamekey=monopolyherenow  

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



Re: [PHP] $_POST- Vars - Back-Button

2007-08-01 Thread Richard Heyes
this might be a noob- question, but I simply do not care anymore. After 
a few hours of fiddling with this @/**%$ (screaming AAa), I 
would like to ask you.


So what I have is this: I have a search engine for a car market, which 
has about 30 $_POST- vars. Now when the user clicks on a result link, it 
takes him to the car details page. Now when he hits the back button, he 
either gets the Page has expired (IE) or the Wanna send the form data 
again message box (FF).


Now I would like to have kind of a back-button, so the user will see 
the reusult list again without having to deal with this.


I guess what I'm asking for is a one-click re-submission of POST data... 
Do you have a clue on how to do this?


The resubmit page is being displayed because the results page is the 
result of a form POST. You can do one of two things:


1. Change your search form to a GET request.
2. Stuff the existing POST data into the session and have your results 
page use that before looking to the POST data.


--
Richard Heyes
+44 (0)844 801 1072
http://www.websupportsolutions.co.uk

Knowledge Base and HelpDesk software
that can cut the cost of online support

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



[PHP] Parent Object

2007-08-01 Thread Ralph Kutschera
Hallo!

class A {
  ...
}

class B extends A {
  ...
  $name = get_parent_class($this); // would be A
  ...
}

This is *not* what I want!

class B {
  ...
  $name = get_parent_class2($this); // should give A
  ...
}

class A {
  ...
  $b = new B();
  ...
}

This *is* what I want!

How can i resolve this issue? I don't want to know which class is being
inherited, but I'd like to know which class has created the current object.

TIA, Ralph

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



[PHP] I'm prepared to feel like an idiot... But I just simply need the answer :)

2007-08-01 Thread Jason Pruim

Hi All :)

I have a php script that I am attempting to run from the CLI to  
connect to a MySQL database and update a field. but when I run it  
with this command: php cronjob.php it prints out the script on screen  
but doesn't process it...


Running: php-rphpinfo(); prints out the standard phpinfo screen..  
and I don't think I should have to write it differently to make it  
run from the command line right?


HELP! I'm desperate... I would offer to name my first born after  
you... But he's already been born :)



--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424
www.raoset.com
[EMAIL PROTECTED]




Re: [PHP] I'm prepared to feel like an idiot... But I just simply need the answer :)

2007-08-01 Thread Brad Bonkoski
I would start with suppling the entire path of for php in the cron.  The 
path in the cron environment may be vastly different then the path in 
your shell environment...

so: /path/to/php file.php
See how that works for you, of course I am assuming it runs fine from 
your command line...

-B

Jason Pruim wrote:

Hi All :)

I have a php script that I am attempting to run from the CLI to 
connect to a MySQL database and update a field. but when I run it with 
this command: php cronjob.php it prints out the script on screen but 
doesn't process it...


Running: php-rphpinfo(); prints out the standard phpinfo screen.. 
and I don't think I should have to write it differently to make it run 
from the command line right?


HELP! I'm desperate... I would offer to name my first born after 
you... But he's already been born :)



--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424
www.raoset.com
[EMAIL PROTECTED]





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



RE: [PHP] Parent Object

2007-08-01 Thread Edward Kay


 -Original Message-
 From: Ralph Kutschera [mailto:[EMAIL PROTECTED]
 Sent: 01 August 2007 13:19
 To: php-general@lists.php.net
 Subject: [PHP] Parent Object


 Hallo!

 class A {
   ...
 }

 class B extends A {
   ...
   $name = get_parent_class($this); // would be A
   ...
 }

 This is *not* what I want!

 class B {
   ...
   $name = get_parent_class2($this); // should give A
   ...
 }

 class A {
   ...
   $b = new B();
   ...
 }

 This *is* what I want!

 How can i resolve this issue? I don't want to know which class is being
 inherited, but I'd like to know which class has created the
 current object.

 TIA, Ralph

The concept of a parent class only exists with inheritance. In terms of
finding where an instance is created from this is non-sensical. Who's to say
the instance is even created by another class? It could be in a function.

If you want to be able to access an object that created another object, pass
it in via the constructor, e.g.

class A {
   ...
   $b = new B($this);
   ...
}

class B {
   private $a;

   public function __construct($a) {
  $this-a = $a;
   }
}

Edward

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



RE: [PHP] I'm prepared to feel like an idiot... But I just simply need the answer :)

2007-08-01 Thread Bastien Koert

I have had success in running CLI php pages from a bat file fired via a 
scheduled task. Since the output can be limited I would suggest adding some 
logging functionality to the page to trap errors and write them to a file that 
you can use to analyze any issues.
 
bastien To: php-general@lists.php.net From: [EMAIL PROTECTED] Date: Wed, 1 
Aug 2007 08:49:34 -0400 Subject: [PHP] I'm prepared to feel like an idiot... 
But I just simply need the answer :)  Hi All :)  I have a php script that I 
am attempting to run from the CLI to  connect to a MySQL database and update a 
field. but when I run it  with this command: php cronjob.php it prints out the 
script on screen  but doesn't process it...  Running: php-rphpinfo(); 
prints out the standard phpinfo screen..  and I don't think I should have to 
write it differently to make it  run from the command line right?  HELP! I'm 
desperate... I would offer to name my first born after  you... But he's 
already been born :)   --  Jason Pruim Raoset Inc. Technology Manager 
MQC Specialist 3251 132nd ave Holland, MI, 49424 www.raoset.com [EMAIL 
PROTECTED]  
_
Discover the new Windows Vista
http://search.msn.com/results.aspx?q=windows+vistamkt=en-USform=QBRE

Re: [PHP] I'm prepared to feel like an idiot... But I just simply need the answer :)

2007-08-01 Thread Daniel Brown
On 8/1/07, Jason Pruim [EMAIL PROTECTED] wrote:
 cannot connect to DB!Can't connect to local MySQL server through
 socket '/var/mysql/mysql.sock' (2)qs:/volumes/raider/webserver/
 documents/tests/ticklers japruim$


 This is only from the commandline... running the script straight in a
 browser doesn't show any errors... and it works just fine.

When running via the web, is it being included in another file?
Make sure that from the command line, it's either self-sufficient
(with the username/password combination hard-coded) or has any
necessary information parsed through included files.

-- 
Daniel P. Brown
[office] (570-) 587-7080 Ext. 272
[mobile] (570-) 766-8107

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



Re: [PHP] I'm prepared to feel like an idiot... But I just simply need the answer :)

2007-08-01 Thread Michael Preslar
 @mysql_connect('localhost', 'user', 'password') or die(Cannot
 connect to DB! . mysql_error());
..
 cannot connect to DB!Can't connect to local MySQL server through
 socket '/var/mysql/mysql.sock' (2)qs:/volumes/raider/webserver/
 documents/tests/ticklers japruim$

MySQL is running right? (I know, silly question, but have to make sure)

If it is.. grep sock /etc/my.ini .. Bet the socket file its creating
is in /tmp or /var/lib/mysql

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



Re: [PHP] subtitute of mysql_error()

2007-08-01 Thread Stut

Patrik Hasibuan wrote:

Dear my friends

What is the substitute of mysql_error() ?

This line of my code does not work anymore:
$hslgbr=mysql_query($sqlgbr,$konek) or die ( mysql_error() 
);

Thank you very much in advance.


In what way does it not work anymore?

The code above is perfectly valid. Incidentally, there is no need to put 
a single variable in quotes - all this does is cause extra pointless 
work for the PHP engine.


-Stut

--
http://stut.net/

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



Re: [PHP] I'm prepared to feel like an idiot... But I just simply need the answer :)

2007-08-01 Thread Thijs Lensselink
On Wed, 1 Aug 2007 08:49:34 -0400, Jason Pruim [EMAIL PROTECTED] wrote:
 Hi All :)
 
 I have a php script that I am attempting to run from the CLI to
 connect to a MySQL database and update a field. but when I run it
 with this command: php cronjob.php it prints out the script on screen
 but doesn't process it...
 
 Running: php-rphpinfo(); prints out the standard phpinfo screen..
 and I don't think I should have to write it differently to make it
 run from the command line right?
 
 HELP! I'm desperate... I would offer to name my first born after
 you... But he's already been born :)
 
 
 --
 
 Jason Pruim
 Raoset Inc.
 Technology Manager
 MQC Specialist
 3251 132nd ave
 Holland, MI, 49424
 www.raoset.com
 [EMAIL PROTECTED]
 
 
 
 

Maybe you can show use some code?

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



RE: [PHP] DOMDocument - loadHTML() cuts off html input

2007-08-01 Thread Bastien Koert

Is there a quote in the data?
 
That is the usual culprit in my situations like that...
 
bastien
 Date: Wed, 1 Aug 2007 10:54:59 +0200 From: [EMAIL PROTECTED] To: 
 php-general@lists.php.net Subject: [PHP] DOMDocument - loadHTML() cuts off 
 html input  Hey List,  In my application, I am loading html content into 
 a DOMDocument using  loadHTML(). The DOMDocument is validated, then the 
 element with a  certain ID tag is extracted and loaded into a node in the 
 main  DOMDocument, which is then presented as html with saveHTML().  This 
 works fine and has worked fine for relatively large pages  (containing 
 several select lists with up to 400 options in total).  The problem I am 
 now facing is a page with a single, relatively large  select list, i.e. 
 some 330 options. The html is generated as expected. However when I load it 
 into a  DOMDocument and saveHTML(), the select list is cut off to about 30  
 options. The remainder of the html content dissappears and instead, the 
 remaining open tags are closed, presumably by  DOMDocument's saveHTML() 
 method.  Any ideas as to why this behaviour is occurring and how to fix it 
 ? Further information available if needed.  Thanks in advance,  Stijn  
 --  PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: 
 http://www.php.net/unsub.php 
_
Explore the seven wonders of the world
http://search.msn.com/results.aspx?q=7+wonders+worldmkt=en-USform=QBRE

Re: [PHP] I'm prepared to feel like an idiot... But I just simply need the answer :)

2007-08-01 Thread Jason Pruim


On Aug 1, 2007, at 8:55 AM, Brad Bonkoski wrote:

I would start with suppling the entire path of for php in the  
cron.  The path in the cron environment may be vastly different  
then the path in your shell environment...

so: /path/to/php file.php
See how that works for you, of course I am assuming it runs fine  
from your command line...

-B


Actually I haven't gotten to the point of setting it up on the cron,  
I can't get it to run the php script from the cli.. thought I should  
test that first :)


Once that works I'll add it to the cron :)





Jason Pruim wrote:

Hi All :)

I have a php script that I am attempting to run from the CLI to  
connect to a MySQL database and update a field. but when I run it  
with this command: php cronjob.php it prints out the script on  
screen but doesn't process it...


Running: php-rphpinfo(); prints out the standard phpinfo  
screen.. and I don't think I should have to write it differently  
to make it run from the command line right?


HELP! I'm desperate... I would offer to name my first born after  
you... But he's already been born :)



--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424
www.raoset.com
[EMAIL PROTECTED]





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




--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424
www.raoset.com
[EMAIL PROTECTED]

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



Re: [PHP] DOMDocument - loadHTML() cuts off html input

2007-08-01 Thread Borokov Smith

Hey,

Thanks for your reply.

Yes there are quotes and 'special characters' in the list:
...
option value=181Acodev/option
option value=85Africa Co-operative Action Trust/option
option value=251Agence europeacute;enne pour le 
Deacute;veloppement et la Santeacute;/option
option value=226Agecirc;ncia de Notiacute;cias 
Esperanccedil;a/option

...

The list gets cut off after the 'Agence européenne pour le développement 
et la Santé'. What you're seeing is part of the raw html output.

When passed through saveHTML(), the character entities dissapear though.
Is this because of a configuration variable i need to set or unset on 
DOMDocument ?


The docs are very unclear on those, and I'm no XML expert. I've tried 
both with resolveExternals set to true and false.


How do you resolve those issues ?

greetz,

boro


Bastien Koert schreef:

Is there a quote in the data?
 
That is the usual culprit in my situations like that...
 
bastien
  
Date: Wed, 1 Aug 2007 10:54:59 +0200 From: [EMAIL PROTECTED] To: php-general@lists.php.net Subject: [PHP] DOMDocument - loadHTML() cuts off html input  Hey List,  In my application, I am loading html content into a DOMDocument using  loadHTML(). The DOMDocument is validated, then the element with a  certain ID tag is extracted and loaded into a node in the main  DOMDocument, which is then presented as html with saveHTML().  This works fine and has worked fine for relatively large pages  (containing several select lists with up to 400 options in total).  The problem I am now facing is a page with a single, relatively large  select list, i.e. some 330 options. The html is generated as expected. However when I load it into a  DOMDocument and saveHTML(), the select list is cut off to about 30  options. The remainder of the html content dissappears and instead, the remaining open tags are closed, presumably by  DOMDocument's saveHTML() method.  Any ideas as to why this behaviour is occurring and how to fix it ? Further information available if needed.  Thanks in advance,  Stijn  --  PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php 


_
Explore the seven wonders of the world
http://search.msn.com/results.aspx?q=7+wonders+worldmkt=en-USform=QBRE
  


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



Re: [PHP] I'm prepared to feel like an idiot... But I just simply need the answer :)

2007-08-01 Thread Jason Pruim


On Aug 1, 2007, at 9:37 AM, Thijs Lensselink wrote:

On Wed, 1 Aug 2007 08:49:34 -0400, Jason Pruim [EMAIL PROTECTED]  
wrote:

Hi All :)

I have a php script that I am attempting to run from the CLI to
connect to a MySQL database and update a field. but when I run it
with this command: php cronjob.php it prints out the script on screen
but doesn't process it...

Running: php-rphpinfo(); prints out the standard phpinfo screen..
and I don't think I should have to write it differently to make it
run from the command line right?

HELP! I'm desperate... I would offer to name my first born after
you... But he's already been born :)


--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424
www.raoset.com
[EMAIL PROTECTED]






Maybe you can show use some code?


@mysql_connect('localhost', 'user', 'password') or die(Cannot  
connect to DB! . mysql_error());
@mysql_select_db('ticklers') or die(Cannot select DB! . mysql_error 
());



$sql=UPDATE tasks SET completed='0';
mysql_query($sql);

also when looking at the code, I noticed that I didn't have the  
opening and closing php tags ... Now I do and I'm getting an error :)


cannot connect to DB!Can't connect to local MySQL server through  
socket '/var/mysql/mysql.sock' (2)qs:/volumes/raider/webserver/ 
documents/tests/ticklers japruim$



This is only from the commandline... running the script straight in a  
browser doesn't show any errors... and it works just fine.



--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424
www.raoset.com
[EMAIL PROTECTED]

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



Re: [PHP] I'm prepared to feel like an idiot... But I just simply need the answer :)

2007-08-01 Thread Daniel Brown
On 8/1/07, Thijs Lensselink [EMAIL PROTECTED] wrote:
 On Wed, 1 Aug 2007 08:49:34 -0400, Jason Pruim [EMAIL PROTECTED] wrote:
  Hi All :)
 
  I have a php script that I am attempting to run from the CLI to
  connect to a MySQL database and update a field. but when I run it
  with this command: php cronjob.php it prints out the script on screen
  but doesn't process it...
 
  Running: php-rphpinfo(); prints out the standard phpinfo screen..
  and I don't think I should have to write it differently to make it
  run from the command line right?
 
  HELP! I'm desperate... I would offer to name my first born after
  you... But he's already been born :)
 
 
  --
 
  Jason Pruim
  Raoset Inc.
  Technology Manager
  MQC Specialist
  3251 132nd ave
  Holland, MI, 49424
  www.raoset.com
  [EMAIL PROTECTED]
 
 
 
 

 Maybe you can show use some code?

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



Since it's being run as a cron, that indicates that it's a
*nix-like machine, so .bat files are out of the question, but you're
on the right track, Bastien.

Jason, try creating a file like this, chmod'ing it to 0755, and
running it with the full path as follows:

[EMAIL PROTECTED] dir]$ pwd
/path/to/dir
[EMAIL PROTECTED] dir]$ /path/to/dir/file

Provided the file is named `file` and is in the same directory as
the PHP script you want to run as a cron, it should run just fine with
this code:

#!/bin/bash
phppath=`which php`

# pwd can be changed to a hard-coded directory if
# the PHP file isn't in the same directory as this script.
# However, make sure not to use the tickmarks (below
#the tilde (~), but instead use single quotes.
pwd=`pwd`

# Change phpfile.php to whatever the actual name of the PHP file is.
$phppath $pwd/phpfile.php  /dev/null 21


If that doesn't work, post the code from your PHP file and we can
all take a look.

-- 
Daniel P. Brown
[office] (570-) 587-7080 Ext. 272
[mobile] (570-) 766-8107

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



RE: [PHP] Re: Pirate PHP books online?

2007-08-01 Thread Chris Boget
   Some light humour:
   http://www.unm.edu/~humanism/socvsjes.htm
  I usually find your humour postings pretty funny but didnt find that

  in the least bit funny... :(
 Can't please everyone all of the time. Maybe you didn't get the joke
:B 
 Certainly it had be ROFLMFAO.

Holy crap, that was funny!  It reminded me a lot of The Euthyphro. :)

thnx,
Chris

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



Re: [PHP] I'm prepared to feel like an idiot... But I just simply need the answer :)

2007-08-01 Thread Stut

Jason Pruim wrote:
I have a php script that I am attempting to run from the CLI to connect 
to a MySQL database and update a field. but when I run it with this 
command: php cronjob.php it prints out the script on screen but doesn't 
process it...


Running: php-rphpinfo(); prints out the standard phpinfo screen.. and 
I don't think I should have to write it differently to make it run from 
the command line right?


Sounds like you're not using ?php and ? tags to surround your code. 
Without those PHP will simply output the content of the file rather than 
running it.


-Stut

--
http://stut.net/

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



Re: [PHP] I'm prepared to feel like an idiot... But I just simply need the answer :)

2007-08-01 Thread Jason Pruim


On Aug 1, 2007, at 9:55 AM, Michael Preslar wrote:


@mysql_connect('localhost', 'user', 'password') or die(Cannot
connect to DB! . mysql_error());

..

cannot connect to DB!Can't connect to local MySQL server through
socket '/var/mysql/mysql.sock' (2)qs:/volumes/raider/webserver/
documents/tests/ticklers japruim$


MySQL is running right? (I know, silly question, but have to make  
sure)


If it is.. grep sock /etc/my.ini .. Bet the socket file its creating
is in /tmp or /var/lib/mysql


Okay, so the command didn't work.. couldn't find my.ini... But I just  
cd'ed into /tmp and there is a file mysql.sock in there... Do I need  
to move that somewhere else? I realize that this is starting to get  
off topic for this list... So Maybe I should take this to a mysql  
list since it looks like php isn't at fault?




--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424
www.raoset.com
[EMAIL PROTECTED]

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



Re: [PHP] I'm prepared to feel like an idiot... But I just simply need the answer :)

2007-08-01 Thread Jason Pruim


On Aug 1, 2007, at 9:53 AM, Daniel Brown wrote:


On 8/1/07, Jason Pruim [EMAIL PROTECTED] wrote:

cannot connect to DB!Can't connect to local MySQL server through
socket '/var/mysql/mysql.sock' (2)qs:/volumes/raider/webserver/
documents/tests/ticklers japruim$


This is only from the commandline... running the script straight in a
browser doesn't show any errors... and it works just fine.


When running via the web, is it being included in another file?
Make sure that from the command line, it's either self-sufficient
(with the username/password combination hard-coded) or has any
necessary information parsed through included files.



Hey Dan,

All the info is hardcoded into the php file, no includes on this one...

--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424
www.raoset.com
[EMAIL PROTECTED]

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



Re: [PHP] I'm prepared to feel like an idiot... But I just simply need the answer :)

2007-08-01 Thread Jason Pruim


On Aug 1, 2007, at 9:55 AM, Stut wrote:


Jason Pruim wrote:
I have a php script that I am attempting to run from the CLI to  
connect to a MySQL database and update a field. but when I run it  
with this command: php cronjob.php it prints out the script on  
screen but doesn't process it...
Running: php-rphpinfo(); prints out the standard phpinfo  
screen.. and I don't think I should have to write it differently  
to make it run from the command line right?


Sounds like you're not using ?php and ? tags to surround your  
code. Without those PHP will simply output the content of the file  
rather than running it.


-Stut


Hey Stut,

Yeah that was the result of the first issue which led to the  
second... Newbie mistake I guess... :) Thanks for looking!


--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424
www.raoset.com
[EMAIL PROTECTED]

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



Re: [PHP] Re: Pirate PHP books online?

2007-08-01 Thread Robert Cummings
On Wed, 2007-08-01 at 04:29 -0700, Ryan A wrote:
  
  Some light humour:
  
  http://www.unm.edu/~humanism/socvsjes.htm
  
  Cheers,
  Rob.
 
 
 Hey,

 I usually find your humour postings pretty funny but
 didnt find that in the least bit funny... :(

Can't please everyone all of the time. Maybe you didn't get the joke :B
Certainly it had be ROFLMFAO.

Cheers,
Rob.
-- 
...
SwarmBuy.com - http://www.swarmbuy.com

Leveraging the buying power of the masses!
...

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



Re: [PHP] I'm prepared to feel like an idiot... But I just simply need the answer :)

2007-08-01 Thread Brad Bonkoski

Brad Bonkoski wrote:

Jason Pruim wrote:


On Aug 1, 2007, at 9:55 AM, Michael Preslar wrote:


@mysql_connect('localhost', 'user', 'password') or die(Cannot
connect to DB! . mysql_error());

..

cannot connect to DB!Can't connect to local MySQL server through
socket '/var/mysql/mysql.sock' (2)qs:/volumes/raider/webserver/
documents/tests/ticklers japruim$


MySQL is running right? (I know, silly question, but have to make sure)

If it is.. grep sock /etc/my.ini .. Bet the socket file its creating
is in /tmp or /var/lib/mysql


Okay, so the command didn't work.. couldn't find my.ini... But I just 
cd'ed into /tmp and there is a file mysql.sock in there... Do I need 
to move that somewhere else? I realize that this is starting to get 
off topic for this list... So Maybe I should take this to a mysql 
list since it looks like php isn't at fault?



I *think* the mysql config file is named: my.cnf
so run a slocate or find on your system to see where it is and look at 
the line:
socket  = 
/var/run/mysqld/mysqld.sock


You can also go into your php.ini file and check out the line:
mysql.default_socket =
and perhaps setting that to where it is located in your /tmp directory 
will do the trick...


-B


As a quick follow up...
the command:
$ php -i | grep mysql

will spit out info on how php thinks mysql is set up currently...
one of the items is:
MYSQL_SOCKET = ...
So just make sure that is in tune with where the socket really is running
-B



--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424
www.raoset.com
[EMAIL PROTECTED]

--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] I'm prepared to feel like an idiot... But I just simply need the answer :)

2007-08-01 Thread Brad Bonkoski

Jason Pruim wrote:


On Aug 1, 2007, at 9:55 AM, Michael Preslar wrote:


@mysql_connect('localhost', 'user', 'password') or die(Cannot
connect to DB! . mysql_error());

..

cannot connect to DB!Can't connect to local MySQL server through
socket '/var/mysql/mysql.sock' (2)qs:/volumes/raider/webserver/
documents/tests/ticklers japruim$


MySQL is running right? (I know, silly question, but have to make sure)

If it is.. grep sock /etc/my.ini .. Bet the socket file its creating
is in /tmp or /var/lib/mysql


Okay, so the command didn't work.. couldn't find my.ini... But I just 
cd'ed into /tmp and there is a file mysql.sock in there... Do I need 
to move that somewhere else? I realize that this is starting to get 
off topic for this list... So Maybe I should take this to a mysql list 
since it looks like php isn't at fault?



I *think* the mysql config file is named: my.cnf
so run a slocate or find on your system to see where it is and look at 
the line:
socket  = 
/var/run/mysqld/mysqld.sock


You can also go into your php.ini file and check out the line:
mysql.default_socket =
and perhaps setting that to where it is located in your /tmp directory 
will do the trick...


-B




--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424
www.raoset.com
[EMAIL PROTECTED]

--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] I'm prepared to feel like an idiot... But I just simply need the answer :)

2007-08-01 Thread Daniel Brown
On 8/1/07, Jason Pruim [EMAIL PROTECTED] wrote:

 On Aug 1, 2007, at 9:55 AM, Michael Preslar wrote:

  @mysql_connect('localhost', 'user', 'password') or die(Cannot
  connect to DB! . mysql_error());
  ..
  cannot connect to DB!Can't connect to local MySQL server through
  socket '/var/mysql/mysql.sock' (2)qs:/volumes/raider/webserver/
  documents/tests/ticklers japruim$
 
  MySQL is running right? (I know, silly question, but have to make
  sure)
 
  If it is.. grep sock /etc/my.ini .. Bet the socket file its creating
  is in /tmp or /var/lib/mysql

 Okay, so the command didn't work.. couldn't find my.ini... But I just
 cd'ed into /tmp and there is a file mysql.sock in there... Do I need
 to move that somewhere else? I realize that this is starting to get
 off topic for this list... So Maybe I should take this to a mysql
 list since it looks like php isn't at fault?



 --

 Jason Pruim
 Raoset Inc.
 Technology Manager
 MQC Specialist
 3251 132nd ave
 Holland, MI, 49424
 www.raoset.com
 [EMAIL PROTECTED]

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



The cheapest fix, if you have root access, is just to symlink it like so:

ln -s /tmp/mysql.sock /var/mysql/mysql.sock

It'll at least get it running, but PHP should be set to look for
the MySQL socket in the right place via both the CLI and the Apache
module.

-- 
Daniel P. Brown
[office] (570-) 587-7080 Ext. 272
[mobile] (570-) 766-8107

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



Re: [PHP] I'm prepared to feel like an idiot... But I just simply need the answer :)

2007-08-01 Thread Jason Pruim
Okay, Now I got it figured out, it was a problem with php cli not  
being able to find the mysql.sock file. I didn't realize that there  
are 2 php.ini files, one for the web and the other for the CLI...  
I'll look into what needs to be changed in the php.ini file... For  
right now I took Dan's advice and symlinked it to get it up and running.


Thanks for the help!


--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424
www.raoset.com
[EMAIL PROTECTED]

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



Re: [PHP] I'm prepared to feel like an idiot... But I just simply need the answer :)

2007-08-01 Thread Sancar Saran
On Wednesday 01 August 2007 17:46:44 Brad Bonkoski wrote:
Hi,
Please Check php.ini of cli. They are different. Maybe there where problem in 
php.ini 

Regards

Sancar

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



Re: [PHP] Re: Pirate PHP books online?

2007-08-01 Thread Ryan A

 Can't please everyone all of the time. Maybe you
 didn't get the joke :B
 Certainly it had be ROFLMFAO.

Well..., to each his own :)

Have a nice day!
R

--
- The faulty interface lies between the chair and the keyboard.
- Creativity is great, but plagiarism is faster!
- Smile, everyone loves a moron. :-)


   

Need a vacation? Get great deals
to amazing places on Yahoo! Travel.
http://travel.yahoo.com/

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



[PHP] Compiling php 5.2.3 / Mac OS X 10.3.9 / mysql configure failed

2007-08-01 Thread Rahul Sitaram Johari

Ave,

Trying to configure, build  compile PHP 5.2.3 on a Mac OS X 10.3.9 from
scratch (Since there is no installer available for Panther). Installed all
dependencies. Latest mySQL 5 client/server is installed (Using the mySQL
Installer available at the mySQL website). I did not build  compile mySQL
and I don¹t wish to either ­ so looking for some other solution to this
problem. 

Getting the following error during ./configure:

configure: error: mysql configure failed. Please check config.log for more
information.

This is the mysql related portion from ³config.log²:

int main() {
dnet_addr()
; return 0; }
configure:58392: checking for MySQL support
configure:58438: checking for specified location of the MySQL UNIX socket
configure:58495: checking for MySQL UNIX socket location
configure:58685: checking for mysql_close in -lmysqlclient
configure:58704: gcc -o conftest -I/usr/include -g -O2  -no-cpp-precomp
-L/usr/local/mysql/lib -L/usr/local/mysql/lib -liconv -L/usr/lib
-L/opt/local/lib -L/opt/local/lib -L/usr/local/php5/lib
-L/usr/local/php5/lib conftest.c -lmysqlclient  -lsybdb -lldap -llber
-liconv -lintl -lfreetype -lpng -lz -ljpeg -lbz2 -lz -lssl -lcrypto -lm
-lxml2 -lz -liconv -lm -lxml2 -lz -liconv -lm 15
ld: table of contents for archive: /usr/local/php5/lib/libsybdb.a is out of
date; rerun ranlib(1) (can't load from it)
configure: failed program was:
#line 58693 configure
#include confdefs.h
/* Override any gcc2 internal prototype to avoid an error.  */
/* We use char because int might match the return type of a gcc2
builtin and then its argument prototype would still apply.  */
char mysql_close();

int main() {
mysql_close()
; return 0; }
configure:58925: checking for mysql_error in -lmysqlclient
configure:58944: gcc -o conftest -I/usr/include -g -O2  -no-cpp-precomp
-L/usr/local/mysql/lib -L/usr/local/mysql/lib -liconv -L/usr/lib
-L/opt/local/lib -L/opt/local/lib -L/usr/local/php5/lib
-L/usr/local/php5/lib -L/usr -L/usr conftest.c -lmysqlclient  -lz -lsybdb
-lldap -llber -liconv -lintl -lfreetype -lpng -lz -ljpeg -lbz2 -lz -lssl
-lcrypto -lm  -lxml2 -lz -liconv -lm -lxml2 -lz -liconv -lm 15
ld: table of contents for archive: /usr/local/php5/lib/libsybdb.a is out of
date; rerun ranlib(1) (can't load from it)
configure: failed program was:
#line 58933 configure
#include confdefs.h
/* Override any gcc2 internal prototype to avoid an error.  */
/* We use char because int might match the return type of a gcc2
builtin and then its argument prototype would still apply.  */
char mysql_error();

int main() {
mysql_error()
; return 0; }

Help would be appreciated.

~~~
Rahul Sitaram Johari
CEO, Twenty Four Seventy Nine Inc.

W: http://www.rahulsjohari.com
E: [EMAIL PROTECTED]

³I morti non sono piu soli ... The dead are no longer lonely²


[PHP] Loss of precision in intval()

2007-08-01 Thread Mark Summers
This sort of thing really isn't helpful...

?php

$a = 75.82 * 100;

echo intval($a);

?

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



Re: [PHP] Loss of precision in intval()

2007-08-01 Thread Eric Butera
On 8/1/07, Mark Summers [EMAIL PROTECTED] wrote:
 This sort of thing really isn't helpful...

 ?php

 $a = 75.82 * 100;

 echo intval($a);

 ?

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


What exactly were you expecting it to do? :)

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



Re: [PHP] Loss of precision in intval()

2007-08-01 Thread tg-php
Very weird and counter intuitive.  Looking at the php manual, I see this:

Converting to integer from floating point:

When converting from float to integer, the number will be rounded towards 
zero.

But you'd think the multiplication would happen before the rounding.

if you do:
$a = ceil(75.82 * 100);

you should get the proper answer.

This is what I used for testing:

?php
$x = 75.82;
$y = 100;

echo x is  . gettype($x) . br\n;
echo y is  . gettype($y) . br\n;

$a = ceil($x * $y);

echo a is  . gettype($a) . br\n;

echo intval(a) is  . gettype(intval($a)) . br\n;

echo $a .  ***  . intval($a);
?

Not sure that really helps, but seems to be some kind of order of precedence 
issue.

-TG

= = = Original message = = =

This sort of thing really isn't helpful...

?php

$a = 75.82 * 100;

echo intval($a);

?


___
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

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



Re: [PHP] Loss of precision in intval()

2007-08-01 Thread tg-php
Probably return 7582 instead of 7581.

= = = Original message = = =

On 8/1/07, Mark Summers [EMAIL PROTECTED] wrote:
 This sort of thing really isn't helpful...

 ?php

 $a = 75.82 * 100;

 echo intval($a);

 ?

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


What exactly were you expecting it to do? :)



___
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

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



Re: [PHP] Loss of precision in intval()

2007-08-01 Thread Satyam
It is most definitely not if what you want is the square root, or the 
hyperbolic cosine or any other of a zillion things.



- Original Message - 
From: Mark Summers [EMAIL PROTECTED]

To: php-general@lists.php.net
Sent: Wednesday, August 01, 2007 6:52 PM
Subject: [PHP] Loss of precision in intval()



This sort of thing really isn't helpful...

?php

$a = 75.82 * 100;

echo intval($a);

?

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



--
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.476 / Virus Database: 269.11.0/929 - Release Date: 31/07/2007 
17:26





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



Re: [PHP] Reading registry values

2007-08-01 Thread \Crash\ Dummy
 You might use http://www.php.net/reserved.variables SERVER_ADDR
 to get the address of the host you are running under if you wanted
to
 access it from PHP only.

Ah, but there is a catch. If you looked at my snapshot, you saw that
there are two addresses, and the server address will not necessarily
be the same as the internet address assigned by the DHCP server. In
fact, it most likely won't be.

In order to get the internet address from the server, I have to know
what it is already so I can set the server to use it. Catch 22. :-)
-- 
Crash
Please reply to the group. E-mail is blocked.

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



Re: [PHP] Loss of precision in intval()

2007-08-01 Thread Roberto Mansfield
Internally, 75.82 can't be stored exactly, so 75.82 * 100 is probably
7581.92 rather than the expected integer value of 7582. So intval is
behaving properly. Sounds like you want intval(round($a));



[EMAIL PROTECTED] wrote:
 Very weird and counter intuitive.  Looking at the php manual, I see this:
 
 Converting to integer from floating point:
 
 When converting from float to integer, the number will be rounded towards 
 zero.
 
 But you'd think the multiplication would happen before the rounding.
 
 if you do:
 $a = ceil(75.82 * 100);
 
 you should get the proper answer.
 
 This is what I used for testing:
 
 ?php
 $x = 75.82;
 $y = 100;
 
 echo x is  . gettype($x) . br\n;
 echo y is  . gettype($y) . br\n;
 
 $a = ceil($x * $y);
 
 echo a is  . gettype($a) . br\n;
 
 echo intval(a) is  . gettype(intval($a)) . br\n;
 
 echo $a .  ***  . intval($a);
 ?
 
 Not sure that really helps, but seems to be some kind of order of precedence 
 issue.
 
 -TG
 
 = = = Original message = = =
 
 This sort of thing really isn't helpful...
 
 ?php
 
 $a = 75.82 * 100;
 
 echo intval($a);
 
 ?
 
 
 ___
 Sent by ePrompter, the premier email notification software.
 Free download at http://www.ePrompter.com.

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



Re: [PHP] Loss of precision in intval()

2007-08-01 Thread Eric Butera
On 8/1/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
 Probably return 7582 instead of 7581.

 = = = Original message = = =

 On 8/1/07, Mark Summers [EMAIL PROTECTED] wrote:
  This sort of thing really isn't helpful...
 
  ?php
 
  $a = 75.82 * 100;
 
  echo intval($a);
 
  ?
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 What exactly were you expecting it to do? :)



 ___
 Sent by ePrompter, the premier email notification software.
 Free download at http://www.ePrompter.com.



http://us.php.net/manual/en/function.intval.php#63627

erics:~ eric$ php -r 'var_dump(printf(%.13f, (75.82 * 100)));'
7581.1int(18)

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



[PHP] Validating Email Conditional

2007-08-01 Thread CK

Hi,

My script is working, but valid returns true even if the user is  
bogus. What needs changing so both conditions have to match, the  
following attempt returned unexpected logical


 if (getmxrr($domaintld,$mxrecords))  if(fsockopen($domaintld,25, 
$errno,$errstr,30)) {

 $valid = true;
 }




The following works, but needs the conditional mentioned...

?php
$email = [EMAIL PROTECTED];
$valid=;

function validate_email($email)


{

   // Create the syntax of email with validation regular expression
   $regexp = ^([_a-z0-9-]+)(\.[_a-z0-9-]+)*@([a-z0-9-]+)(\.[a-z0-9-] 
+)*(\.[a-z]{2,4})$;


   // Presume that the email is invalid
   $valid = false;

   // Validate the syntax
   if (eregi($regexp, $email))
   {
  list($username,$domaintld) = split(@,$email);
  // Validate the domain
  if (getmxrr($domaintld,$mxrecords))
 $valid = true;
 }
// attempts a socket connection to mail server
  if(fsockopen($domaintld,25,$errno,$errstr,30)) {
$valid = true;
   } else {
$valid = false;
  }
 return $valid;
}

if (validate_email($email))
   echo Email is valid!;
else
   echo Email is invalid!;

?

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



[PHP] addSlashes Question

2007-08-01 Thread CK

Hi,

Engaged in cleanup project, attempting to understand the  
uncommented decisions of  predecessors.  Inserting the following  
contact form values into a DB:



$first = '.addslashes($_POST['firstname']).';
$last = '.addslashes($_POST['lastname']).';
$email = '.addslashes($_POST['email']).';
$address = '.addslashes($_POST['address']).';
$city = '.addslashes($_POST['city']).';
$state = '.addslashes($_POST['state']).';
$zip = '.addslashes($_POST['zip']).';
$comments = '.addslashes($_POST['comments']).';
$newsletter = '.addslashes($_POST['signup']).';
$contact = '.addslashes($_POST['contact']).';


I can understand addSlashes for the first and last name, but question  
the need in the other variables, please inform.


CK

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



RE: [PHP] addSlashes Question

2007-08-01 Thread Jay Blanchard
[snip]

 $first = '.addslashes($_POST['firstname']).';
 $last = '.addslashes($_POST['lastname']).';
 $email = '.addslashes($_POST['email']).';
 $address = '.addslashes($_POST['address']).';
 $city = '.addslashes($_POST['city']).';
 $state = '.addslashes($_POST['state']).';
 $zip = '.addslashes($_POST['zip']).';
 $comments = '.addslashes($_POST['comments']).';
 $newsletter = '.addslashes($_POST['signup']).';
 $contact = '.addslashes($_POST['contact']).';


I can understand addSlashes for the first and last name, but question  
the need in the other variables, please inform.
[/snip]

There is safety in numbers! While a lot of these fields may not ever
contain anything that would need to be escaped the name fields and
comments field would definitely need this. Also, if this is filled out
by 'external' users you do not want them to be able to enter anything
(like a SQL injection attack in the comments field) that might cause a
problem of some sort. Another option would be htmlentities()

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



Re: [PHP] Validating Email Conditional

2007-08-01 Thread Edward Kay



CK wrote:

Hi,

My script is working, but valid returns true even if the user is 
bogus. What needs changing so both conditions have to match, the 
following attempt returned unexpected logical


 if (getmxrr($domaintld,$mxrecords))  
if(fsockopen($domaintld,25,$errno,$errstr,30)) {

 $valid = true;
 }


You don't need to write the second 'if', just wrap the two conditionals 
in parentheses:


if ( getmxrr($domaintld,$mxrecords)  
fsockopen($domaintld,25,$errno,$errstr,30) )

   $valid = true;

You could equally use nested conditionals:

if (getmxrr($domaintld,$mxrecords)) {
  if (fsockopen($domaintld,25,$errno,$errstr,30))
 $valid = true;
}

There is no need for the second $valid = false in your code below, since 
you define that at the start.


Edward



The following works, but needs the conditional mentioned...

?php
$email = [EMAIL PROTECTED];
$valid=;

function validate_email($email)


{

   // Create the syntax of email with validation regular expression
   $regexp = 
^([_a-z0-9-]+)(\.[_a-z0-9-]+)*@([a-z0-9-]+)(\.[a-z0-9-]+)*(\.[a-z]{2,4})$; 



   // Presume that the email is invalid
   $valid = false;

   // Validate the syntax
   if (eregi($regexp, $email))
   {
  list($username,$domaintld) = split(@,$email);
  // Validate the domain
  if (getmxrr($domaintld,$mxrecords))
 $valid = true;
 }
// attempts a socket connection to mail server
  if(fsockopen($domaintld,25,$errno,$errstr,30)) {
$valid = true;
   } else {
  $valid = false;
  }
 return $valid;
}

if (validate_email($email))
   echo Email is valid!;
else
   echo Email is invalid!;

?

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

2007-08-01 Thread Jim Lucas

CK wrote:

Hi,

Engaged in cleanup project, attempting to understand the uncommented 
decisions of  predecessors.  Inserting the following contact form values 
into a DB:



$first = '.addslashes($_POST['firstname']).';
$last = '.addslashes($_POST['lastname']).';
$email = '.addslashes($_POST['email']).';
$address = '.addslashes($_POST['address']).';
$city = '.addslashes($_POST['city']).';
$state = '.addslashes($_POST['state']).';
$zip = '.addslashes($_POST['zip']).';
$comments = '.addslashes($_POST['comments']).';
$newsletter = '.addslashes($_POST['signup']).';
$contact = '.addslashes($_POST['contact']).';


I can understand addSlashes for the first and last name, but question 
the need in the other variables, please inform.


CK



More than likely what they were trying to do is prep/escape the data for 
insertion into the DB.

a better thing to use would be the actually DB escape function.

Mysql  http://us2.php.net/mysql_real_escape_string

Other DB implementations have similar functions

This will escape the data for insertion into a DB, but do it on all chars that needed to be escaped. 
 Where addSlashes() works on only a subset of most of the chars that need escaping.



--
Jim Lucas

   Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them.

Twelfth Night, Act II, Scene V
by William Shakespeare

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



Re: [PHP] Validating Email Conditional

2007-08-01 Thread Jim Lucas

CK wrote:

Hi,

My script is working, but valid returns true even if the user is bogus. 
What needs changing so both conditions have to match, the following 
attempt returned unexpected logical


 if (getmxrr($domaintld,$mxrecords))  
if(fsockopen($domaintld,25,$errno,$errstr,30)) {

 $valid = true;
 }



Looks like you are trying to nest an if.. inside the conditional of another if.

That doesn't work.

I think what you are wanting here is this

if (getmxrr($domaintld,$mxrecords) 
fsockopen($domaintld,25,$errno,$errstr,30) ) {





The following works, but needs the conditional mentioned...

?php
$email = [EMAIL PROTECTED];
$valid=;

function validate_email($email)


{

   // Create the syntax of email with validation regular expression
   $regexp = 
^([_a-z0-9-]+)(\.[_a-z0-9-]+)*@([a-z0-9-]+)(\.[a-z0-9-]+)*(\.[a-z]{2,4})$; 



   // Presume that the email is invalid
   $valid = false;

   // Validate the syntax
   if (eregi($regexp, $email))
   {
  list($username,$domaintld) = split(@,$email);
  // Validate the domain
  if (getmxrr($domaintld,$mxrecords))
 $valid = true;
 }
// attempts a socket connection to mail server
  if(fsockopen($domaintld,25,$errno,$errstr,30)) {
$valid = true;
   } else {
  $valid = false;
  }
 return $valid;
}

if (validate_email($email))
   echo Email is valid!;
else
   echo Email is invalid!;

?




--
Jim Lucas

   Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them.

Twelfth Night, Act II, Scene V
by William Shakespeare

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



Re: [PHP] addSlashes Question

2007-08-01 Thread Robert Cummings
On Wed, 2007-08-01 at 13:20 -0700, CK wrote:
 Hi,
 
 Engaged in cleanup project, attempting to understand the  
 uncommented decisions of  predecessors.  Inserting the following  
 contact form values into a DB:
 
 
  $first = '.addslashes($_POST['firstname']).';
  $last = '.addslashes($_POST['lastname']).';
  $email = '.addslashes($_POST['email']).';
  $address = '.addslashes($_POST['address']).';
  $city = '.addslashes($_POST['city']).';
  $state = '.addslashes($_POST['state']).';
  $zip = '.addslashes($_POST['zip']).';
  $comments = '.addslashes($_POST['comments']).';
  $newsletter = '.addslashes($_POST['signup']).';
  $contact = '.addslashes($_POST['contact']).';
 
 
 I can understand addSlashes for the first and last name, but question  
 the need in the other variables, please inform.

ALWAYS escape user submitted data. Just because you expect a certain
input doesn't mean some Mr. Malicious posted it to your form. That said,
addSlashes() is insecure for database queries. You should use the
database specific escape function to properly escape content that is DB
bound.

Cheers,
Rob.
-- 
...
SwarmBuy.com - http://www.swarmbuy.com

Leveraging the buying power of the masses!
...

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



Re: [PHP] Loss of precision in intval()

2007-08-01 Thread David Duong

Roberto Mansfield wrote:

Internally, 75.82 can't be stored exactly, so 75.82 * 100 is probably
7581.92 rather than the expected integer value of 7582. So intval is
behaving properly. Sounds like you want intval(round($a));



[EMAIL PROTECTED] wrote:

Very weird and counter intuitive.  Looking at the php manual, I see this:

Converting to integer from floating point:

When converting from float to integer, the number will be rounded towards 
zero.

But you'd think the multiplication would happen before the rounding.

if you do:
$a = ceil(75.82 * 100);

you should get the proper answer.

This is what I used for testing:

?php
$x = 75.82;
$y = 100;

echo x is  . gettype($x) . br\n;
echo y is  . gettype($y) . br\n;

$a = ceil($x * $y);

echo a is  . gettype($a) . br\n;

echo intval(a) is  . gettype(intval($a)) . br\n;

echo $a .  ***  . intval($a);
?

Not sure that really helps, but seems to be some kind of order of precedence 
issue.

-TG

= = = Original message = = =

This sort of thing really isn't helpful...

?php

$a = 75.82 * 100;

echo intval($a);

?


___
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

Better yet: $a + 0, or (int)$a.

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



[PHP] Form Validation and DB Query

2007-08-01 Thread CK

Hi,

 Being thrust into cleaning after another has me timid.  Could some  
kind soul look over the following solution for form validation and DB  
query? Any suggestions on security and streamlining is humbly requested.



CK


?php

   $firstname =$_POST['firstname'];
$lastname = $_POST['lastname']);
$email = $_POST['email']);
$address = $_POST['address']);
$city = $_POST['city']);
$state = $_POST['state']);
$zip = $_POST['zip']);
$comments = $_POST['comments']);
$newsletter = $_POST['signup']);
$contact = $_POST['contact']);
$dt = '.date('Y-m-d H:i:s');

$message = First Name: .$firstname.\n;
$message .= Last Name: .$lastname.\n;
$message .= Email: .$email.\n;
$message .= Address: .$address.\n;
$message .= City: .$city.\n;
$message .= State: .$state.\n;
$message .= Zip: .$zip.\n;
$message .= Comments: .$comments.\n;
$message .= Newsletter: .$newsletter.\n;
$message .= Contact: .$contact.\n;




function validate_form($email,$firstname,$lastname)
{
if(strlen($firstname)0){
$firstname=stripslashes($firstname);
}else{//If no name was entered.
$firstname=NULL;
echo 'pemYou forgot to enter your first name./em/p';
}   
if(strlen($lastname)0){
$lastname=stripslashes($fm_lastname);
}else{//If no name was entered.
$lastname=NULL;
echo 'pemYou forgot to enter  your last name./em/p';
}


   // Create the syntax of email with validation regular expression
   $regexp = ^([_a-z0-9-]+)(\.[_a-z0-9-]+)*@([a-z0-9-]+)(\.[a-z0-9-] 
+)*(\.[a-z]{2,4})$;


   // Presume that the email is invalid
   $valid = false;

   // Validate the syntax
   if (eregi($regexp, $email))
   {
  list($username,$domaintld) = split(@,$email);
  // Validate the domain
  if (getmxrr($domaintld,$mxrecords))
 $valid = true;
 }
// attempts a socket connection to mail server
  if(@fsockopen($domaintld,25,$errno,$errstr,15)) {
$valid = true;
   } else {
$valid = false;
echo 'pemPlease check your email and try again./em/p';
  }
 return $valid;
}

if (validate_form($email,$firstname,$lastname))
@ $db = mysql_connect('mysql_host', 'mysql_user', 'mysql_password);
if (mysql_errno()) {
  echo 'perror connecting to database/p';
  exit;
}
if (!mysql_select_db(mysql_user)) {
  echo pThere is a system error - please try later/p;
  exit;
}

$query = insert into users values (NULL, .$firstname., . 
$lastname., .$email., .$address., .$city., .$state., . 
$zip., .$comments., .$newsletter., .$contact., .$dt.);

mysql_real_escape_string($firstname, $query),
mysql_real_escape_string($lastname, $query),
mysql_real_escape_string($email, $query),
mysql_real_escape_string($address, $query),
mysql_real_escape_string($city, $query),
mysql_real_escape_string($state, $query),
mysql_real_escape_string($zip, $query),
mysql_real_escape_string($comments, $query),
mysql_real_escape_string($newsletter, $query),
mysql_real_escape_string($contact, $query),
mysql_real_escape_string($dt, $query),
//echo p.$query./p;
$result = mysql_query($query, $db);
if (!$result) {
  echo p.mysql_error()./p;
  exit;
} else {
  $to = [EMAIL PROTECTED];
  $subject = CTS Contact;
  mail($to, $subject, $message);
  }
}



}   
?

[PHP] Question about passing date in sql...

2007-08-01 Thread Payne

Guys,

Got a quick question.  I got a sql statement works when I pass it from 
the cli. but if I try in php I get nothing.


This is the statement.

Select ip, date, time, CONCAT(city, ', ',country) as location from ips 
where country !=' ' and date='`date +%Y%m%d`' order by country asc;


I know it has to do with date='`date +%Y%m%d`', because if I remove it 
works.


Any clue as to why?

Payne

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



Re: [PHP] Question about passing date in sql...

2007-08-01 Thread Brad Bonkoski

Payne wrote:

Guys,

Got a quick question.  I got a sql statement works when I pass it from 
the cli. but if I try in php I get nothing.


This is the statement.

Select ip, date, time, CONCAT(city, ', ',country) as location from ips 
where country !=' ' and date='`date +%Y%m%d`' order by country asc;


I know it has to do with date='`date +%Y%m%d`', because if I remove it 
works.


Any clue as to why?

Payne


why not use the PHP function to format the date?

http://www.php.net/date
-B

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



Re: [PHP] Question about passing date in sql...

2007-08-01 Thread Michael Preslar
 I know it has to do with date='`date +%Y%m%d`', because if I remove it
 works.

Are you trying to use perl's back tic operator in php here?

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



Re: [PHP] Question about passing date in sql...

2007-08-01 Thread Stut

Michael Preslar wrote:

I know it has to do with date='`date +%Y%m%d`', because if I remove it
works.


Are you trying to use perl's back tic operator in php here?


PHP also supports the that.

However, I think the OP's problem is that it's inside other quotes and 
is therefore not being executed. But, as someone else pointed out, you 
should be using the PHP date function to get the date from within PHP.


-Stut

--
http://stut.net/

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



Re: [PHP] Validating Email Conditional

2007-08-01 Thread Robin Vickery
On 01/08/07, CK [EMAIL PROTECTED] wrote:
 Hi,

 My script is working,
[...]
 $regexp = ^([_a-z0-9-]+)(\.[_a-z0-9-]+)*@([a-z0-9-]+)(\.[a-z0-9-]
 +)*(\.[a-z]{2,4})$;

If your script is using that regular expression to validate email addresses
then your script is most definitely not working.

-robin

(who is fed up with websites that reject perfectly good email
addresses for no good reason)

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



Re: [PHP] Loss of precision in intval()

2007-08-01 Thread Mark Summers
I like to think that I'm reasonably aware of the limitations of floating 
point (famous last words).


To my mind, the ridiculousness (probably not a word) of the example is 
highlighted by the fact that 75.81 and 75.83 work perfectly.


Roberto Mansfield wrote:

Internally, 75.82 can't be stored exactly, so 75.82 * 100 is probably
7581.92 rather than the expected integer value of 7582. So intval is
behaving properly. Sounds like you want intval(round($a));



[EMAIL PROTECTED] wrote:
  

Very weird and counter intuitive.  Looking at the php manual, I see this:

Converting to integer from floating point:

When converting from float to integer, the number will be rounded towards 
zero.

But you'd think the multiplication would happen before the rounding.

if you do:
$a = ceil(75.82 * 100);

you should get the proper answer.

This is what I used for testing:

?php
$x = 75.82;
$y = 100;

echo x is  . gettype($x) . br\n;
echo y is  . gettype($y) . br\n;

$a = ceil($x * $y);

echo a is  . gettype($a) . br\n;

echo intval(a) is  . gettype(intval($a)) . br\n;

echo $a .  ***  . intval($a);
?

Not sure that really helps, but seems to be some kind of order of precedence 
issue.

-TG

= = = Original message = = =

This sort of thing really isn't helpful...

?php

$a = 75.82 * 100;

echo intval($a);

?


___
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.



  


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



[PHP] Re: audio recorder

2007-08-01 Thread Dan
Your best bet is to use flash.  Flash has the ability to access user's 
microphones built in.  And since flash is cross platform it works on 
everything.  Also it's pretty simple to do. 
http://www.adobe.com/support/flash/action_scripts/actionscript_dictionary/actionscript_dictionary479.html 
explains a bit of Microphone.get.  You will want to use this with a Flash 
Communications server. I think that should let you save the audio.


One thing that you may not have thought of though.  Do users really want to 
be using your flash or whatever script to record their audio?  Wouldn't it 
be nice if they could record it using their own recorder, for example on 
windows there's sound recorder built right in.  Then they could have a few 
takes and upload the best one.  And all you would have to do is handle the 
mp3 or wav upload.


- Dan

John Pillion [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]

Not exactly a php question. but I'm doing the project in php, so does that
count? ;-)



A client of mine wants a simple audio recorder for users to record a short
clip/message for other users. anyone recommend any simple audio recorder
applets or similar that can easily be integrated with php?



Thanks!



J




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



Re: [PHP] Validating Email Conditional

2007-08-01 Thread Davi
Em Quarta 01 Agosto 2007 19:56, Robin Vickery escreveu:
 On 01/08/07, CK [EMAIL PROTECTED] wrote:
  Hi,
 
  My script is working,

 [...]

  $regexp = ^([_a-z0-9-]+)(\.[_a-z0-9-]+)*@([a-z0-9-]+)(\.[a-z0-9-]
  +)*(\.[a-z]{2,4})$;

 If your script is using that regular expression to validate email addresses
 then your script is most definitely not working.

 -robin

 (who is fed up with websites that reject perfectly good email
 addresses for no good reason)

I'm wrong or if I try to use my mail address ([EMAIL PROTECTED]) it 
will be rejected?
My e-mail address isn't in format [EMAIL PROTECTED]
-- 
Davi Vidal
[EMAIL PROTECTED]
[EMAIL PROTECTED]
--

Por favor não faça top-posting, coloque a sua resposta abaixo desta linha.
Eu não respondo top-post/HTML post. Obrigado.
Please don't do top-posting, put your reply below the following line.
I don't reply to top-post/HTML post. Thank you.



pgpiV6gyO987G.pgp
Description: PGP signature


Re: [PHP] Profile / Debug w/o server modification?

2007-08-01 Thread Instruct ICC

From: Richard Lynch [EMAIL PROTECTED]
Your dev box should only match in software versions (okay, and any
really funky specialized hardware like a hardware random number
generator MAYBE).



Regarding duplicating the box versus software:
I'm working on a C++ project on a Mac Pro and a MacBook Pro.


Phew!

When I archived my sources and makefiles rather than reproducing them from 
memory, it built the same successfully on both.  As I would hope.


_
Puzzles, trivia teasers, word scrambles and more. Play for your chance to 
win! http://club.live.com/home.aspx?icid=CLUB_hotmailtextlink


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



[PHP] [pcre] backreferences to all matches of a repeated subexpression

2007-08-01 Thread Jack Bates
I'm trying to pull all the components out of strings structured like:
word followed by any number of ( dot word or square bracketed string )

This is an example: foo.bar[ab.cd].baz

From the above example, I want: array('foo', 'bar', 'ab.cd', 'baz');

A regular expression to match these strings, including parenthesis
around the parts I want to pull out:

preg_match('/(^\w+)(?:\.(\w+)|\[([^]]+)\])*/', $subject, $matches);

However applied to the above example:

$matches[1] = 'foo'; // First subexpression
$matches[2] = 'baz'; // Last value of second subexpression
$matches[3] = 'ab.cd'; // Last value of third subexpression

I'm not sure how to get an array of all subexpression matches, in the
order matches appear in the subject, instead of the order expressions
appear in the pattern.

I think I might be able to do something using the Perl (?{code})
construction, e.g. ...(?:\.(\w+)(?{$parts[] = \2})|\[([^]]+)(?{$parts[]
= \3})\])*... but I haven't thought about it too much because PHP
doesn't support this construction.

Any ideas much appreciated. Thanks, Jack

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



[PHP] mail function

2007-08-01 Thread Animesh Joshi
I've installed IIS (Internet information services on my windows XP machine. 
I've also installed php 5.0 from www.php.net. I'm trying to use the mail() 
function in a simple php script which uses a html form. However, i'm not able 
to send the mail using the mail($to, $subject, $message, $headers); function. I 
wonder what's wrong. Please help, i'm new to php.

Animesh Joshi