Re: [PHP] running php script as a user?

2009-07-21 Thread Maximiliano Churichi
sudo -u user command

2009/7/15 Adam Williams :
> I have a page where a user authenticates, fills in some information in an
> HTML form, and then when clicking on the submit button, will need to execute
> a php schell script as that user to write some data to their /home/username
> directory.  Since apache web server runs as the user nobody, how will I have
> that script execute as that user so that it can write data to their home
> directory?
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>



-- 
Maximiliano Churichi


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



Re: [PHP] PHP and FoxPro

2009-07-21 Thread Floyd Resler

Matt,
	Thanks for the information.  I'll look into using ODBTP.  I noticed  
you mentioned the problem with memos.  I currently have that problem  
with the set up we're using and it is a pain!


Thanks!
Floyd

On Jul 20, 2009, at 3:22 PM, Matt Neimeyer wrote:

We currently use the Easysoft ODBC Bridge to connect to a remote  
FoxPro
database.  The problem is that the bridge, after a while, starts  
consuming a
ton of system resources and we have to reboot the machine.   
Afterwards, it
can take upwards to two hours before everything is running quickly  
again.
We need another solution.  Does anyone know of a any other way to  
connect

to a remote FoxPro database (or any ODBC source that isn't a database
server)?


We've had a LOT a luck using ODBTP. Which can be found at
http://odbtp.sourceforge.net

Here's the rough outline...

1. Install Visual FoxPro odbc driver (or whatever drivers you want) on
a Windows machine.
2. Install the ODBTP Server on the windows machine
3. Install a PHP module in your php. (Common ones included in the  
download)

4. Once you connect the functions are ALMOST exactly the same in usage
as the mysql_xyz functions.

A couple gotchas:

1. If you need to compile the PHP ODBTP module from source on x64 (OS
X Leopard at least) it can be a pain.
2. The VFP 6.0 ODBC driver (not sure about higher versions) does not
allow more than 250 odd characters to be inserted at a single time so
memo's can be a PAIN.
3. It does require a port be opened on the Windows machine's
firewall... (Uses TCP/IP for communication)
4. By default the ODBTP server can use up to 32 threads. The VFP ODBC
driver is by nature single threaded. We've never had a problem with
that directly but I assume it is what causes threads to slowly hang
and disappear... eventually a message comes up "Unable to create
thread". At that point you simply need to restart the ODBTP service in
the Windows Services Control Panel. The bigger the tables and the more
heavily used it is the more often this will happen.

Other than that... Works like a charm. Looking forward, once you bite
the bullet and convert to MySQL (at least for us) you can almost
change odbtp_ to mysql_ and be up and running. (Assuming you limit
yourself to "pure" SQL and not invoke VFP functions.)

Matt




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



[PHP] Traffic throttling

2009-07-21 Thread Michelle Konzack
Hello,

since I have not the file store in my webspace  for  security  reason,  I
use a php5 script to push it out.  It even support "resumeing".

some times ago, there was someone who told me to send out the  files  in
chunks of, e.g. 1 kByte, which let me know to count the REAL  traffic  a
client produce...

OK, now the script works perfectly and I am able to  delay  the  sending
between two chunks, but what I need is a milisecond timer, because 1s is
definitively to long.

Is there something in php5 I can use?

Thanks, Greetings and nice Day/Evening
Michelle Konzack
Systemadministrator
Tamay Dogan Network
Debian GNU/Linux Consultant

-- 
Linux-User #280138 with the Linux Counter, http://counter.li.org/
# Debian GNU/Linux Consultant #
 Michelle Konzack
   c/o Vertriebsp. KabelBW
   Blumenstrasse 2
Jabber linux4miche...@jabber.ccc.de   77694 Kehl/Germany
IRC #Debian (irc.icq.com) Tel. DE: +49 177 9351947
ICQ #328449886Tel. FR: +33  6  61925193


signature.pgp
Description: Digital signature


Re: [PHP] Traffic throttling

2009-07-21 Thread Stuart
2009/7/21 Michelle Konzack :
> since I have not the file store in my webspace  for  security  reason,  I
> use a php5 script to push it out.  It even support "resumeing".
>
> some times ago, there was someone who told me to send out the  files  in
> chunks of, e.g. 1 kByte, which let me know to count the REAL  traffic  a
> client produce...
>
> OK, now the script works perfectly and I am able to  delay  the  sending
> between two chunks, but what I need is a milisecond timer, because 1s is
> definitively to long.
>
> Is there something in php5 I can use?

http://php.net/usleep

-Stuart

-- 
http://stut.net/

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



Re: [PHP] Traffic throttling

2009-07-21 Thread דניאל דנון
I am not sure I understood you, But...
Use microtime(true/false) to get the time,
And usleep to sleep milliseconds

On Tue, Jul 21, 2009 at 6:31 PM, Michelle Konzack <
linux4miche...@tamay-dogan.net> wrote:

> Hello,
>
> since I have not the file store in my webspace  for  security  reason,  I
> use a php5 script to push it out.  It even support "resumeing".
>
> some times ago, there was someone who told me to send out the  files  in
> chunks of, e.g. 1 kByte, which let me know to count the REAL  traffic  a
> client produce...
>
> OK, now the script works perfectly and I am able to  delay  the  sending
> between two chunks, but what I need is a milisecond timer, because 1s is
> definitively to long.
>
> Is there something in php5 I can use?
>
> Thanks, Greetings and nice Day/Evening
>Michelle Konzack
>Systemadministrator
>Tamay Dogan Network
>Debian GNU/Linux Consultant
>
> --
> Linux-User #280138 with the Linux Counter, http://counter.li.org/
> # Debian GNU/Linux Consultant #
>  Michelle Konzack
>    c/o Vertriebsp. KabelBW
>    Blumenstrasse 2
> Jabber linux4miche...@jabber.ccc.de   77694 Kehl/Germany
> IRC #Debian (irc.icq.com) Tel. DE: +49 177 9351947
> ICQ #328449886Tel. FR: +33  6  61925193
>



-- 
Use ROT26 for best security


[PHP] Re: Traffic throttling

2009-07-21 Thread Michelle Konzack
Hello Stuart,

Am 2009-07-21 16:39:30, schrieb Stuart:
> http://php.net/usleep

Thank you, that it was.

Greetings and nice Day/Evening
Michelle Konzack
Systemadministrator
Tamay Dogan Network
Debian GNU/Linux Consultant

-- 
Linux-User #280138 with the Linux Counter, http://counter.li.org/
# Debian GNU/Linux Consultant #
 Michelle Konzack
   c/o Vertriebsp. KabelBW
   Blumenstrasse 2
Jabber linux4miche...@jabber.ccc.de   77694 Kehl/Germany
IRC #Debian (irc.icq.com) Tel. DE: +49 177 9351947
ICQ #328449886Tel. FR: +33  6  61925193


signature.pgp
Description: Digital signature


Re: [PHP] putting variables in a variable

2009-07-21 Thread Mark Kelly
Ross,

If I understand correctly what you want to do, you're almost there...

You need:

$myimage1 = "image1.jpg";
$myimage2 = "image2.jpg";
$myimage3 = "image3.jpg";

$body .="

  

  
  

  
  

  

";

Cheers,

Mark


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



[PHP] Search Query on two tables not working

2009-07-21 Thread Miller, Terion
Why isn't this working for searching?

   // Run query on submitted values. Store results in $SESSION and redirect to 
restaurants.php$sql = "SELECT name, address, inDate, inType, notes, 
critical, cviolations, noncritical FROM restaurants, inspections WHERE 
restaurants.name <> '' AND restaurant.ID = inspection.ID";if ($searchName)  
  { $sql .= "AND restaurants.name LIKE '%". mysql_real_escape_string($name) 
."%' ";if(count($name2) == 1){$sql .= "AND restaurants.name 
LIKE '%". mysql_real_escape_string($name2[1]) ."%' ";}else{
foreach($name2 as $namePart){$sql .= "AND restaurants.name LIKE 
'%". mysql_real_escape_string($namePart) ."%' ";}}}if 
($searchAddress) {$sql .= "AND restaurants.address LIKE '%". 
mysql_real_escape_string($address) ."%' ";}   $sql .= "ORDER BY 
restaurants.name;";$result = mysql_query($sql);

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



Re: [PHP] Search Query on two tables not working

2009-07-21 Thread Andrew Ballard
On Tue, Jul 21, 2009 at 12:26 PM, Miller,
Terion wrote:
> Why isn't this working for searching?

Check your concatenation in the query. You need some white space
padding your SQL segments, otherwise the text all starts to run
together.

 (I had to reformat it. For some reason, most of the code snippets you
post end up all run together on a single line, at least in Gmail.)

 ''
AND restaurant.ID = inspection.ID";

  if ($searchName){
// ADDED SPACE HERE
  $sql .= " AND restaurants.name LIKE '%".
mysql_real_escape_string($name) ."%' ";
  if(count($name2) == 1){
// ADDED SPACE HERE
  $sql .= " AND restaurants.name LIKE '%".
mysql_real_escape_string($name2[1]) ."%' ";
  }else{
  foreach($name2 as $namePart){
// ADDED SPACE HERE
  $sql .= " AND restaurants.name LIKE '%".
mysql_real_escape_string($namePart) ."%' ";
  }
  }
  }

  if ($searchAddress) {
// ADDED SPACE HERE
  $sql .= " AND restaurants.address LIKE '%".
mysql_real_escape_string($address) ."%' ";
  }
// ADDED SPACE HERE
  $sql .= " ORDER BY restaurants.name;";
  $result = mysql_query($sql);


Andrew

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



Re: [PHP] Search Query on two tables not working

2009-07-21 Thread Dan Shirah
>
> Why isn't this working for searching?
>
>   // Run query on submitted values. Store results in $SESSION and redirect
> to restaurants.php$sql = "SELECT name, address, inDate, inType,
> notes, critical, cviolations, noncritical FROM restaurants, inspections
> WHERE restaurants.name <> '' AND restaurant.ID = inspection.ID";if
> ($searchName){ $sql .= "AND restaurants.name LIKE '%".
> mysql_real_escape_string($name) ."%' ";if(count($name2) == 1){
>  $sql .= "AND restaurants.name LIKE '%".
> mysql_real_escape_string($name2[1]) ."%' ";}else{
>  foreach($name2 as $namePart){$sql .= "AND
> restaurants.name LIKE '%". mysql_real_escape_string($namePart) ."%' ";
>}}}if ($searchAddress) {$sql .= "AND
> restaurants.address LIKE '%". mysql_real_escape_string($address) ."%' ";
>  }   $sql .= "ORDER BY restaurants.name;";
>  $result = mysql_query($sql);
>
I'm not sure about MySQL, but in Informix my queries will crash when trying
to just append the ORDER BY clause by itself.

$sql .= "ORDER BY restaurants.name;";

Also, you have a semi colon before and after the ending quote.

TRY

$sql .= "AND 1 = 1
ORDER BY restaurants.name";


Re: [PHP] Search Query on two tables not working

2009-07-21 Thread Miller, Terion



On 7/21/09 11:47 AM, "Dan Shirah"  wrote:

Why isn't this working for searching?

  // Run query on submitted values. Store results in $SESSION and redirect to 
restaurants.php$sql = "SELECT name, address, inDate, inType, notes, 
critical, cviolations, noncritical FROM restaurants, inspections WHERE 
restaurants.name   <> '' 
AND restaurant.ID = inspection.ID";if ($searchName){ $sql .= "AND 
restaurants.name   LIKE 
'%". mysql_real_escape_string($name) ."%' ";if(count($name2) == 1){ 
   $sql .= "AND restaurants.name 
  LIKE '%". 
mysql_real_escape_string($name2[1]) ."%' ";}else{
foreach($name2 as $namePart){$sql .= "AND restaurants.name 
  LIKE '%". 
mysql_real_escape_string($namePart) ."%' ";}}}if 
($searchAddress) {$sql .= "AND restaurants.address LIKE '%". 
mysql_real_escape_string($address) ."%' ";}   $sql .= "ORDER BY 
restaurants.name  ;";   
 $result = mysql_query($sql);
I'm not sure about MySQL, but in Informix my queries will crash when trying to 
just append the ORDER BY clause by itself.

$sql .= "ORDER BY restaurants.name 
 ;";

Also, you have a semi colon before and after the ending quote.

TRY

$sql .= "AND 1 = 1
ORDER BY restaurants.name  ";







Got the query to this point now:

Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result 
resource in 
/var/www/vhosts/getpublished.news-leader.com/httpdocs/ResturantInspections/processRestaurantSearch.php
 on line 119

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



Re: [PHP] Search Query on two tables not working

2009-07-21 Thread Miller, Terion



On 7/21/09 12:04 PM, "Ashley Sheridan"  wrote:

On Tue, 2009-07-21 at 12:59 -0400, Miller, Terion wrote:
>
>
> On 7/21/09 11:47 AM, "Dan Shirah"  wrote:
>
> Why isn't this working for searching?
>
>   // Run query on submitted values. Store results in $SESSION and redirect to 
> restaurants.php$sql = "SELECT name, address, inDate, inType, notes, 
> critical, cviolations, noncritical FROM restaurants, inspections WHERE 
> restaurants.name 
> 
>   <> '' AND restaurant.ID = inspection.ID";if ($searchName){ $sql 
> .= "AND restaurants.name 
> 
>   LIKE '%". mysql_real_escape_string($name) ."%' ";if(count($name2) 
> == 1){$sql .= "AND restaurants.name 
> 
>   LIKE '%". mysql_real_escape_string($name2[1]) ."%' ";}else{ 
>foreach($name2 as $namePart){$sql .= "AND restaurants.name 
> 
>   LIKE '%". mysql_real_escape_string($namePart) ."%' ";}}}
> if ($searchAddress) {$sql .= "AND restaurants.address LIKE '%". 
> mysql_real_escape_string($address) ."%' ";}   $sql .= "ORDER 
> BY restaurants.name 
> 
>  ;";$result = mysql_query($sql);
> I'm not sure about MySQL, but in Informix my queries will crash when trying 
> to just append the ORDER BY clause by itself.
>
> $sql .= "ORDER BY restaurants.name 
> 
>  ;";
>
> Also, you have a semi colon before and after the ending quote.
>
> TRY
>
> $sql .= "AND 1 = 1
> ORDER BY restaurants.name 
> 
>  ";
>
>
>
>
>
>
>
> Got the query to this point now:
>
> Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result 
> resource in 
> /var/www/vhosts/getpublished.news-leader.com/httpdocs/ResturantInspections/processRestaurantSearch.php
>  on line 119
>
That means your query is invalid. Try printing the query out and posting
it here so that we can see it.

Thanks
Ash
www.ashleysheridan.co.uk



I Got this error when I echo'd the sql $results ;
You have an error in your SQL syntax; check the manual that corresponds to your 
MySQL server version for the right syntax to use near 'restaurants.name LIKE 
'%A%' AND restaurants.name LIKE '%A%' ORDER BY restaurants' at line 1

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



Re: [PHP] Search Query on two tables not working

2009-07-21 Thread Miller, Terion
Turned off the redirects on the whole script and tried to the the query to echo 
and these are the errors I got:

Notice: Undefined offset: 1 in 
/var/www/vhosts/getpublished.news-leader.com/httpdocs/ResturantInspections/processRestaurantSearch.php
 on line 89

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result 
resource in 
/var/www/vhosts/getpublished.news-leader.com/httpdocs/ResturantInspections/processRestaurantSearch.php
 on line 119


On 7/21/09 11:32 AM, "Kevin Smith"  wrote:

Can you supply the actual generated SQL, I can potentially see a
problem, but need to see the final SQL statement.

Miller, Terion wrote:
> Why isn't this working for searching?
>
> // Run query on submitted values. Store results in $SESSION and redirect 
> to restaurants.php$sql = "SELECT name, address, inDate, inType, 
> notes, critical, cviolations, noncritical FROM restaurants, inspections WHERE 
> restaurants.name<>  '' AND restaurant.ID = inspection.ID";if 
> ($searchName){ $sql .= "AND restaurants.name LIKE '%". 
> mysql_real_escape_string($name) ."%' ";if(count($name2) == 1){
> $sql .= "AND restaurants.name LIKE '%". 
> mysql_real_escape_string($name2[1]) ."%' ";}else{
> foreach($name2 as $namePart){$sql .= "AND restaurants.name 
> LIKE '%". mysql_real_escape_string($namePart) ."%' ";}}}
> if ($searchAddress) {$sql .= "AND restaurants.address LIKE '%". 
> mysql_real_escape_string($address) ."%' ";}   $sql .= "ORDER 
> BY restaurants.name;";$result = mysql_query($sql);
>
>





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



Re: [PHP] Search Query on two tables not working

2009-07-21 Thread Dan Shirah
On Tue, Jul 21, 2009 at 12:41 PM, Miller, Terion <
tmil...@springfi.gannett.com> wrote:

> Turned off the redirects on the whole script and tried to the the query to
> echo and these are the errors I got:
>
> Notice: Undefined offset: 1 in /var/www/vhosts/
> getpublished.news-leader.com/httpdocs/ResturantInspections/processRestaurantSearch.phpon
>  line 89
>
> Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result
> resource in /var/www/vhosts/
> getpublished.news-leader.com/httpdocs/ResturantInspections/processRestaurantSearch.phpon
>  line 119
>
>
> On 7/21/09 11:32 AM, "Kevin Smith"  wrote:
>
> Can you supply the actual generated SQL, I can potentially see a
> problem, but need to see the final SQL statement.
>
> print_r($sql);


Re: [PHP] Search Query on two tables not working

2009-07-21 Thread Miller, Terion
Here it is...I see where it's doing the restaurant.name LIKE statement 2x which 
is prob messing it up right...but in the code why is it doing that twice..

SELECT name, address, inDate, inType, notes, critical, cviolations, noncritical 
FROM restaurants, inspections WHERE restaurants.name <> '' AND restaurant.ID = 
inspection.IDAND restaurants.name LIKE '%A%' AND restaurants.name LIKE '%A%' 
ORDER BY restaurants.name;


On 7/21/09 12:11 PM, "Dan Shirah"  wrote:

print_r($sql);


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



Re: [PHP] Search Query on two tables not working

2009-07-21 Thread Ashley Sheridan
On Tue, 2009-07-21 at 10:07 -0700, Miller, Terion wrote:
> 
> 
> On 7/21/09 12:04 PM, "Ashley Sheridan"  wrote:
> 
> On Tue, 2009-07-21 at 12:59 -0400, Miller, Terion wrote:
> >
> >
> > On 7/21/09 11:47 AM, "Dan Shirah"  wrote:
> >
> > Why isn't this working for searching?
> >
> >   // Run query on submitted values. Store results in $SESSION and redirect 
> > to restaurants.php$sql = "SELECT name, address, inDate, inType, 
> > notes, critical, cviolations, noncritical FROM restaurants, inspections 
> > WHERE restaurants.name 
> > 
> >   <> '' AND restaurant.ID = inspection.ID";if ($searchName){ 
> > $sql .= "AND restaurants.name 
> > 
> >   LIKE '%". mysql_real_escape_string($name) ."%' ";if(count($name2) 
> > == 1){$sql .= "AND restaurants.name 
> > 
> >   LIKE '%". mysql_real_escape_string($name2[1]) ."%' ";}else{   
> >  foreach($name2 as $namePart){$sql .= "AND 
> > restaurants.name 
> > 
> >   LIKE '%". mysql_real_escape_string($namePart) ."%' ";}}}  
> >   if ($searchAddress) {$sql .= "AND restaurants.address LIKE '%". 
> > mysql_real_escape_string($address) ."%' ";}   $sql .= 
> > "ORDER BY restaurants.name 
> > 
> >  ;";$result = mysql_query($sql);
> > I'm not sure about MySQL, but in Informix my queries will crash when trying 
> > to just append the ORDER BY clause by itself.
> >
> > $sql .= "ORDER BY restaurants.name 
> > 
> >  ;";
> >
> > Also, you have a semi colon before and after the ending quote.
> >
> > TRY
> >
> > $sql .= "AND 1 = 1
> > ORDER BY restaurants.name 
> > 
> >  ";
> >
> >
> >
> >
> >
> >
> >
> > Got the query to this point now:
> >
> > Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result 
> > resource in 
> > /var/www/vhosts/getpublished.news-leader.com/httpdocs/ResturantInspections/processRestaurantSearch.php
> >  on line 119
> >
> That means your query is invalid. Try printing the query out and posting
> it here so that we can see it.
> 
> Thanks
> Ash
> www.ashleysheridan.co.uk
> 
> 
> 
> I Got this error when I echo'd the sql $results ;
> You have an error in your SQL syntax; check the manual that corresponds to 
> your MySQL server version for the right syntax to use near 'restaurants.name 
> LIKE '%A%' AND restaurants.name LIKE '%A%' ORDER BY restaurants' at line 1
> 
Yes, but that's not your query. The problem is with your query. If you
echo the query, we can see where it might be falling over.

Thanks
Ash
www.ashleysheridan.co.uk


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



Re: [PHP] Search Query on two tables not working

2009-07-21 Thread Andrew Ballard
On Tue, Jul 21, 2009 at 1:20 PM, Miller,
Terion wrote:
> Here it is...I see where it's doing the restaurant.name LIKE statement 2x 
> which is prob messing it up right...but in the code why is it doing that 
> twice..
>
> SELECT name, address, inDate, inType, notes, critical, cviolations, 
> noncritical FROM restaurants, inspections WHERE restaurants.name <> '' AND 
> restaurant.ID = inspection.IDAND restaurants.name LIKE '%A%' AND 
> restaurants.name LIKE '%A%' ORDER BY restaurants.name;
>
>

It's not the multiple LIKE statements. It is the concatenation, like I
said the last time. There is no white space between "inspection.ID"
and "AND".

You may indeed have problems with some of those repeated conditions on
restaurants.name, but if so they will be performance issues resulting
from table scans, and not the errors you are reporting.

Andrew

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



Re: [PHP] Search Query on two tables not working

2009-07-21 Thread Ashley Sheridan
On Tue, 2009-07-21 at 12:59 -0400, Miller, Terion wrote:
> 
> 
> On 7/21/09 11:47 AM, "Dan Shirah"  wrote:
> 
> Why isn't this working for searching?
> 
>   // Run query on submitted values. Store results in $SESSION and redirect to 
> restaurants.php$sql = "SELECT name, address, inDate, inType, notes, 
> critical, cviolations, noncritical FROM restaurants, inspections WHERE 
> restaurants.name   <> '' 
> AND restaurant.ID = inspection.ID";if ($searchName){ $sql .= "AND 
> restaurants.name   LIKE 
> '%". mysql_real_escape_string($name) ."%' ";if(count($name2) == 1)
> {$sql .= "AND restaurants.name 
>   LIKE '%". 
> mysql_real_escape_string($name2[1]) ."%' ";}else{
> foreach($name2 as $namePart){$sql .= "AND restaurants.name 
>   LIKE '%". 
> mysql_real_escape_string($namePart) ."%' ";}}}if 
> ($searchAddress) {$sql .= "AND restaurants.address LIKE '%". 
> mysql_real_escape_string($address) ."%' ";}   $sql .= "ORDER 
> BY restaurants.name  ;";  
>   $result = mysql_query($sql);
> I'm not sure about MySQL, but in Informix my queries will crash when trying 
> to just append the ORDER BY clause by itself.
> 
> $sql .= "ORDER BY restaurants.name 
>  ;";
> 
> Also, you have a semi colon before and after the ending quote.
> 
> TRY
> 
> $sql .= "AND 1 = 1
> ORDER BY restaurants.name  
> ";
> 
> 
> 
> 
> 
> 
> 
> Got the query to this point now:
> 
> Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result 
> resource in 
> /var/www/vhosts/getpublished.news-leader.com/httpdocs/ResturantInspections/processRestaurantSearch.php
>  on line 119
> 
That means your query is invalid. Try printing the query out and posting
it here so that we can see it.

Thanks
Ash
www.ashleysheridan.co.uk


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



Re: [PHP] Search Query on two tables not working

2009-07-21 Thread Ashley Sheridan
On Tue, 2009-07-21 at 13:24 -0400, Andrew Ballard wrote:
> On Tue, Jul 21, 2009 at 1:20 PM, Miller,
> Terion wrote:
> > Here it is...I see where it's doing the restaurant.name LIKE statement 2x 
> > which is prob messing it up right...but in the code why is it doing that 
> > twice..
> >
> > SELECT name, address, inDate, inType, notes, critical, cviolations, 
> > noncritical FROM restaurants, inspections WHERE restaurants.name <> '' AND 
> > restaurant.ID = inspection.IDAND restaurants.name LIKE '%A%' AND 
> > restaurants.name LIKE '%A%' ORDER BY restaurants.name;
> >
> >
> 
> It's not the multiple LIKE statements. It is the concatenation, like I
> said the last time. There is no white space between "inspection.ID"
> and "AND".
> 
> You may indeed have problems with some of those repeated conditions on
> restaurants.name, but if so they will be performance issues resulting
> from table scans, and not the errors you are reporting.
> 
> Andrew
> 

It's always better putting in extra whitespace at both ends of each part
of the query you are concatenating if you're unsure. Like Andrew said,
MySQL will balk if you have none between keywords, but I've never heard
it complaining about an extra space or two!

Thanks
Ash
www.ashleysheridan.co.uk


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



[PHP] Converting SQL Dialects

2009-07-21 Thread Matt Neimeyer
Has anyone come across / written a script that will convert one
"flavor" or Dialect of SQL to another?

I need to convert Visual FoxPro 6.0 style WHERE clauses to MySQL.

For the most part the problems are converting VFP functions to the
equivalent SQL. For example, Visual FoxPro has a function inlist()
that is used like inlist(X,1,2,3) which converts to the MySQL query "X
IN (1,2,3)". That's easy enough (relatively speaking) but VFP also has
stuff like "EMPTY(X)" where any of Null, the Empty String (for Char),
-00-00 (or the VFP equivalent anyways for dates), False (for
Boolean), 0 (for Numeric) are considered empty without needing to
know the data type. So that starts getting a lot more complex since I'd
need to check the data type of the field in the "right" table... to be
able to convert it to something like (X is null OR X="") or (X is null
OR x=0) etc...

These are for customer "stored" queries... I've already manually
converted "system" queries and I'm frustrated to the point of giving
up and adding a column "untested" and let the end user figure it out
but that seems bad from the standpoint of "lazy" and "poor customer
experience".

Thanks!

Matt

P.S. I'm also going to post this to the MySQL general list but my fear
is that they MIGHT say "We only know MySQL so we can't help you with
that other DBMS" I'm hoping that by posting here someone might say
"well it's not to MySQL but I ran script XYZ to convert my VFP to
PostgreSQL..." or similar.

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



Re: [PHP] Converting SQL Dialects

2009-07-21 Thread Ashley Sheridan
On Tue, 2009-07-21 at 13:46 -0400, Matt Neimeyer wrote:
> Has anyone come across / written a script that will convert one
> "flavor" or Dialect of SQL to another?
> 
> I need to convert Visual FoxPro 6.0 style WHERE clauses to MySQL.
> 
> For the most part the problems are converting VFP functions to the
> equivalent SQL. For example, Visual FoxPro has a function inlist()
> that is used like inlist(X,1,2,3) which converts to the MySQL query "X
> IN (1,2,3)". That's easy enough (relatively speaking) but VFP also has
> stuff like "EMPTY(X)" where any of Null, the Empty String (for Char),
> -00-00 (or the VFP equivalent anyways for dates), False (for
> Boolean), 0 (for Numeric) are considered empty without needing to
> know the data type. So that starts getting a lot more complex since I'd
> need to check the data type of the field in the "right" table... to be
> able to convert it to something like (X is null OR X="") or (X is null
> OR x=0) etc...
> 
> These are for customer "stored" queries... I've already manually
> converted "system" queries and I'm frustrated to the point of giving
> up and adding a column "untested" and let the end user figure it out
> but that seems bad from the standpoint of "lazy" and "poor customer
> experience".
> 
> Thanks!
> 
> Matt
> 
> P.S. I'm also going to post this to the MySQL general list but my fear
> is that they MIGHT say "We only know MySQL so we can't help you with
> that other DBMS" I'm hoping that by posting here someone might say
> "well it's not to MySQL but I ran script XYZ to convert my VFP to
> PostgreSQL..." or similar.
> 

I'm not sure it's as easy as you think it might be. As you get more into
the various flavours of SQL, you notice their little idiosyncrasies that
only exist within that one particular language branch. As such, it's
often a task best left to people to try and convert from one to the
other, rather than leave it to a machine. How complex are the queries
that you are trying to convert anyway?

Thanks
Ash
www.ashleysheridan.co.uk


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



Re: [PHP] Search Query on two tables not working (RESOLVED)

2009-07-21 Thread Miller, Terion

Yep, sure was the spacesOMG...will I ever get it...

On 7/21/09 12:29 PM, "Ashley Sheridan"  wrote:

On Tue, 2009-07-21 at 13:24 -0400, Andrew Ballard wrote:
> On Tue, Jul 21, 2009 at 1:20 PM, Miller,
> Terion wrote:
> > Here it is...I see where it's doing the restaurant.name LIKE statement 2x 
> > which is prob messing it up right...but in the code why is it doing that 
> > twice..
> >
> > SELECT name, address, inDate, inType, notes, critical, cviolations, 
> > noncritical FROM restaurants, inspections WHERE restaurants.name <> '' AND 
> > restaurant.ID = inspection.IDAND restaurants.name LIKE '%A%' AND 
> > restaurants.name LIKE '%A%' ORDER BY restaurants.name;
> >
> >
>
> It's not the multiple LIKE statements. It is the concatenation, like I
> said the last time. There is no white space between "inspection.ID"
> and "AND".
>
> You may indeed have problems with some of those repeated conditions on
> restaurants.name, but if so they will be performance issues resulting
> from table scans, and not the errors you are reporting.
>
> Andrew
>

It's always better putting in extra whitespace at both ends of each part
of the query you are concatenating if you're unsure. Like Andrew said,
MySQL will balk if you have none between keywords, but I've never heard
it complaining about an extra space or two!

Thanks
Ash
www.ashleysheridan.co.uk




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



Re: [PHP] PHP and FoxPro

2009-07-21 Thread Matt Neimeyer
What I did to handle memos... and it's a HACK... was to create a
function DoMemo that took as arguments the table, the primary key
field of the table, the value of said pk, the field to update, and the
string.

Take the first 200 characters of the string.
Replace all newlines in that substring with "+CHR(13)+" (Or CHR(13)+CHR(10)?)
Then do something like: UPDATE table SET field=First200 WHERE pk=pkvalue

Then take the next 200 characters of the string.
Replace all newlines as above
Do something like: UPDATE table SET field=ALLTRIM(field)+Next200 WHERE
pk=pkvalue

Repeat until you've "consumed" the entire string. This works because
you never put in more that 250 odd characters at a time. It can still
fail though if you have enough newlines to push your 200 characters up
over the 250 odd character limit.

It DOES work if you use RECNO() as the pk field and the appropriate
recno() that you would get if you did something like SELECT recno() AS
myrecno,* FROM sometable (I use the myrecno because otherwise you get
some weird exp_1 field name)

It just popped into my head... I wonder if something like this would work...

UPDATE sometable SET a=1,a=a+1,a=a+1,a=a+1 WHERE x=y

You might be able to limit the total number of calls to the database
that way... If I wasn't in the process of migrating to MySQL I might
give it a whirl... :)

Hope this helps whatever you decide to do.

On Tue, Jul 21, 2009 at 8:27 AM, Floyd Resler wrote:
> Matt,
>        Thanks for the information.  I'll look into using ODBTP.  I noticed
> you mentioned the problem with memos.  I currently have that problem with
> the set up we're using and it is a pain!
>
> Thanks!
> Floyd
>
> On Jul 20, 2009, at 3:22 PM, Matt Neimeyer wrote:
>
>>> We currently use the Easysoft ODBC Bridge to connect to a remote FoxPro
>>> database.  The problem is that the bridge, after a while, starts
>>> consuming a
>>> ton of system resources and we have to reboot the machine.  Afterwards,
>>> it
>>> can take upwards to two hours before everything is running quickly again.
>>> We need another solution.  Does anyone know of a any other way to connect
>>> to a remote FoxPro database (or any ODBC source that isn't a database
>>> server)?
>>
>> We've had a LOT a luck using ODBTP. Which can be found at
>> http://odbtp.sourceforge.net
>>
>> Here's the rough outline...
>>
>> 1. Install Visual FoxPro odbc driver (or whatever drivers you want) on
>> a Windows machine.
>> 2. Install the ODBTP Server on the windows machine
>> 3. Install a PHP module in your php. (Common ones included in the
>> download)
>> 4. Once you connect the functions are ALMOST exactly the same in usage
>> as the mysql_xyz functions.
>>
>> A couple gotchas:
>>
>> 1. If you need to compile the PHP ODBTP module from source on x64 (OS
>> X Leopard at least) it can be a pain.
>> 2. The VFP 6.0 ODBC driver (not sure about higher versions) does not
>> allow more than 250 odd characters to be inserted at a single time so
>> memo's can be a PAIN.
>> 3. It does require a port be opened on the Windows machine's
>> firewall... (Uses TCP/IP for communication)
>> 4. By default the ODBTP server can use up to 32 threads. The VFP ODBC
>> driver is by nature single threaded. We've never had a problem with
>> that directly but I assume it is what causes threads to slowly hang
>> and disappear... eventually a message comes up "Unable to create
>> thread". At that point you simply need to restart the ODBTP service in
>> the Windows Services Control Panel. The bigger the tables and the more
>> heavily used it is the more often this will happen.
>>
>> Other than that... Works like a charm. Looking forward, once you bite
>> the bullet and convert to MySQL (at least for us) you can almost
>> change odbtp_ to mysql_ and be up and running. (Assuming you limit
>> yourself to "pure" SQL and not invoke VFP functions.)
>>
>> Matt
>>
>
>

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



Re: [PHP] Converting SQL Dialects

2009-07-21 Thread Matt Neimeyer
Um... It depends? :) These are customer entered queries and vary based
on the end user and the customizations they have. It could be as
simple as WHERE inlist(SalesPerson,"Bob","Bill","Fred") OR it could be
something 12 lines long that pulls in criteria from multiple tables
each of those with their own criteria.

And by easy I meant simply that I would feel comfortable hacking
together something to handle inlist(x,1,2,3) and change it to "X in
(1,2,3)" it's the "rest" that worries me.

Having slept on it, I'm probably going to write something that
converts IN, checks for a list of "forbidden" words and then flags the
resulting updated query if it contains any of those words. This way I
can catch some of the low hanging fruit.

My hope is that if X% of queries don't contain foxpro specific
functions, and IN auto-conversions covers another X% of upgrades, and
auto-convert FunctionX (whatever it is...) gives us another X% of
upgrades... that this will result in a hopefully small number of saved
queries that are flagged for manual upgrading. (And not be so painful
in development that it still nets us saved time)

Matt

On Tue, Jul 21, 2009 at 1:54 PM, Ashley
Sheridan wrote:
> On Tue, 2009-07-21 at 13:46 -0400, Matt Neimeyer wrote:
>> Has anyone come across / written a script that will convert one
>> "flavor" or Dialect of SQL to another?
>>
>> I need to convert Visual FoxPro 6.0 style WHERE clauses to MySQL.
>>
>> For the most part the problems are converting VFP functions to the
>> equivalent SQL. For example, Visual FoxPro has a function inlist()
>> that is used like inlist(X,1,2,3) which converts to the MySQL query "X
>> IN (1,2,3)". That's easy enough (relatively speaking) but VFP also has
>> stuff like "EMPTY(X)" where any of Null, the Empty String (for Char),
>> -00-00 (or the VFP equivalent anyways for dates), False (for
>> Boolean), 0 (for Numeric) are considered empty without needing to
>> know the data type. So that starts getting a lot more complex since I'd
>> need to check the data type of the field in the "right" table... to be
>> able to convert it to something like (X is null OR X="") or (X is null
>> OR x=0) etc...
>>
>> These are for customer "stored" queries... I've already manually
>> converted "system" queries and I'm frustrated to the point of giving
>> up and adding a column "untested" and let the end user figure it out
>> but that seems bad from the standpoint of "lazy" and "poor customer
>> experience".
>>
>> Thanks!
>>
>> Matt
>>
>> P.S. I'm also going to post this to the MySQL general list but my fear
>> is that they MIGHT say "We only know MySQL so we can't help you with
>> that other DBMS" I'm hoping that by posting here someone might say
>> "well it's not to MySQL but I ran script XYZ to convert my VFP to
>> PostgreSQL..." or similar.
>>
>
> I'm not sure it's as easy as you think it might be. As you get more into
> the various flavours of SQL, you notice their little idiosyncrasies that
> only exist within that one particular language branch. As such, it's
> often a task best left to people to try and convert from one to the
> other, rather than leave it to a machine. How complex are the queries
> that you are trying to convert anyway?
>
> Thanks
> Ash
> www.ashleysheridan.co.uk
>
>

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



Re: [PHP] Converting SQL Dialects

2009-07-21 Thread Andrew Ballard
On Tue, Jul 21, 2009 at 2:13 PM, Matt Neimeyer wrote:
> Um... It depends? :) These are customer entered queries and vary based
> on the end user and the customizations they have. It could be as
> simple as WHERE inlist(SalesPerson,"Bob","Bill","Fred") OR it could be
> something 12 lines long that pulls in criteria from multiple tables
> each of those with their own criteria.
>
> And by easy I meant simply that I would feel comfortable hacking
> together something to handle inlist(x,1,2,3) and change it to "X in
> (1,2,3)" it's the "rest" that worries me.
>
> Having slept on it, I'm probably going to write something that
> converts IN, checks for a list of "forbidden" words and then flags the
> resulting updated query if it contains any of those words. This way I
> can catch some of the low hanging fruit.
>
> My hope is that if X% of queries don't contain foxpro specific
> functions, and IN auto-conversions covers another X% of upgrades, and
> auto-convert FunctionX (whatever it is...) gives us another X% of
> upgrades... that this will result in a hopefully small number of saved
> queries that are flagged for manual upgrading. (And not be so painful
> in development that it still nets us saved time)
>
> Matt

You might even be able to convert EMPTY(X) to COALESCE(X, '') = ''.
MySQL seems to be pretty forgiving with its implicit type-casting.

Andrew

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



Re: [PHP] PHP and FoxPro

2009-07-21 Thread Floyd Resler

Matt,
	Thanks for the tip on handling memos.  I always thought, "If I could  
just append to the end of the existing string..." but never figured  
out how to do it.  I'll give your method a shot.


Thanks!
Floyd

On Jul 21, 2009, at 2:04 PM, Matt Neimeyer wrote:


What I did to handle memos... and it's a HACK... was to create a
function DoMemo that took as arguments the table, the primary key
field of the table, the value of said pk, the field to update, and the
string.

Take the first 200 characters of the string.
Replace all newlines in that substring with "+CHR(13)+" (Or  
CHR(13)+CHR(10)?)
Then do something like: UPDATE table SET field=First200 WHERE  
pk=pkvalue


Then take the next 200 characters of the string.
Replace all newlines as above
Do something like: UPDATE table SET field=ALLTRIM(field)+Next200 WHERE
pk=pkvalue

Repeat until you've "consumed" the entire string. This works because
you never put in more that 250 odd characters at a time. It can still
fail though if you have enough newlines to push your 200 characters up
over the 250 odd character limit.

It DOES work if you use RECNO() as the pk field and the appropriate
recno() that you would get if you did something like SELECT recno() AS
myrecno,* FROM sometable (I use the myrecno because otherwise you get
some weird exp_1 field name)

It just popped into my head... I wonder if something like this would  
work...


UPDATE sometable SET a=1,a=a+1,a=a+1,a=a+1 WHERE x=y

You might be able to limit the total number of calls to the database
that way... If I wasn't in the process of migrating to MySQL I might
give it a whirl... :)

Hope this helps whatever you decide to do.

On Tue, Jul 21, 2009 at 8:27 AM, Floyd Resler  
wrote:

Matt,
   Thanks for the information.  I'll look into using ODBTP.  I  
noticed
you mentioned the problem with memos.  I currently have that  
problem with

the set up we're using and it is a pain!

Thanks!
Floyd

On Jul 20, 2009, at 3:22 PM, Matt Neimeyer wrote:

We currently use the Easysoft ODBC Bridge to connect to a remote  
FoxPro

database.  The problem is that the bridge, after a while, starts
consuming a
ton of system resources and we have to reboot the machine.   
Afterwards,

it
can take upwards to two hours before everything is running  
quickly again.
We need another solution.  Does anyone know of a any other way to  
connect
to a remote FoxPro database (or any ODBC source that isn't a  
database

server)?


We've had a LOT a luck using ODBTP. Which can be found at
http://odbtp.sourceforge.net

Here's the rough outline...

1. Install Visual FoxPro odbc driver (or whatever drivers you  
want) on

a Windows machine.
2. Install the ODBTP Server on the windows machine
3. Install a PHP module in your php. (Common ones included in the
download)
4. Once you connect the functions are ALMOST exactly the same in  
usage

as the mysql_xyz functions.

A couple gotchas:

1. If you need to compile the PHP ODBTP module from source on x64  
(OS

X Leopard at least) it can be a pain.
2. The VFP 6.0 ODBC driver (not sure about higher versions) does not
allow more than 250 odd characters to be inserted at a single time  
so

memo's can be a PAIN.
3. It does require a port be opened on the Windows machine's
firewall... (Uses TCP/IP for communication)
4. By default the ODBTP server can use up to 32 threads. The VFP  
ODBC

driver is by nature single threaded. We've never had a problem with
that directly but I assume it is what causes threads to slowly hang
and disappear... eventually a message comes up "Unable to create
thread". At that point you simply need to restart the ODBTP  
service in
the Windows Services Control Panel. The bigger the tables and the  
more

heavily used it is the more often this will happen.

Other than that... Works like a charm. Looking forward, once you  
bite

the bullet and convert to MySQL (at least for us) you can almost
change odbtp_ to mysql_ and be up and running. (Assuming you limit
yourself to "pure" SQL and not invoke VFP functions.)

Matt









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



[PHP] Re: RFC/Survey for Our Newer Folks (Including Lurkers)

2009-07-21 Thread Shawn McKenzie
Daniel P. Brown wrote:
> Ladies and Gentlemen:
> 

Daniel P. Brown:

I originally found it here: http://www.php.net/mailing-lists.php when I
was looking for responsive help, and have always accessed it via a
newsgroup on news.php.net instead of as a mailing list.  The news server
times out quite a bit though.  It is doing it today frequently.

-- 
Thanks!
-Shawn
http://www.spidean.com

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



Re: [PHP] A prepared statements question

2009-07-21 Thread Shawn McKenzie
Jim Lucas wrote:
> Jason Carson wrote:
>>> Hello everyone,
>>>
>>> I am having a problem getting my prepared statements working. Here is my
>>> setup...
>>>
>>> index.php -> authenticate.php -> admin.php
>>>
>>> 1)index.php has a login form on it so when someone enters their username
>>> the form redirects to another page I call authenticate.php.
>>>
>>> 2)In the authenticate.php file I want to use prepared statements to
>>> interact with the MySQL database. I want to compare the username
>>> submitted
>>> from the form with the username in the database.
>>>
>>> 3)If the login username was legitimate then you are forwarded to
>>> admin.php
>>>
>>> Its step 2 I am having problems with. Here is what I have but I don't
>>> think it makes any sense and it doesn't work.
>>>
>>>
>>> $link = mysqli_connect($hostname, $dbusername, $password, $database);
>>> $stmt = mysqli_prepare($link, "SELECT * FROM administrators WHERE
>>> adminusers=?");
>>> mysqli_stmt_bind_param($stmt, 's', $username);
>>> $result = mysqli_stmt_execute($stmt);
>>>
>>> $count=mysqli_num_rows($result);
>>>
>>> if($count==1){
>>> header("location:admin.php");
>>> } else {
>>> echo "Failure";
>>> }
>>>
>>> Any help is appreciated.
>>>
>>>
>>> -- 
>>> PHP General Mailing List (http://www.php.net/)
>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>
>>>
>> For anyone reading this thread, here is the final code that I used...
>>
>> $link = mysqli_connect($hostname, $username, $password, $database);
>> $stmt = mysqli_prepare($link, "SELECT * FROM administrators WHERE
>> adminusers=?);
>> mysqli_stmt_bind_param($stmt, "s", $adminuser);
>> mysqli_stmt_execute($stmt);
>> mysqli_stmt_store_result($stmt);
>> $count = mysqli_stmt_num_rows($stmt);
>>
>> if($count==1){
>> header("location:admin.php");
>> } else {
>> echo "Failure";
>> }
>>
>>
> 
> I hope not, because you have a parse error on your second line,
> mysqli_prepare()
> 
> Might want to close your double-quoted string
> 
> -- 
> Jim Lucas

Not to mention that I don't see $adminuser defined anywhere.  If its
from a form and register_globals are off, maybe $_POST['adminuser'].

-- 
Thanks!
-Shawn
http://www.spidean.com

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



[PHP] Re: How to set find pathes for PHP CLI?

2009-07-21 Thread Shawn McKenzie
Tir wrote:
> I have many scripts that I need execute with PHP CLI. They are located in a 
> few directories. I don't want to write full path to script every time when I 
> start it. Therefore I've added this paths to the PATH environment variable. 
> But PHP don't find my scripts. How could i set paths on which PHP would find 
> my script when i call e.g. "php -f my_script.php"? 
> 
> 

You can't do this.  The path only applies to executables.  If your
scripts looked like this (and they are marked executable):

#!/usr/bin/php


Then running: $/path/to/myscript.php will run your script.  The php
executable is not going to search your path for the script.

-- 
Thanks!
-Shawn
http://www.spidean.com

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



[PHP] Doubt regarding session_destroy() in PHP 5

2009-07-21 Thread Guruprasad

Hi all,
I have a doubt with creating and destroying sessions in PHP using 
session_destroy(). Supposing there is a PHP-based website hosted on a 
web server. Now I add another site that I developed using PHP on that 
web server using virtualhost. I destroy a session in my website using 
session_destroy() which will destroy all the session variables 
associated with my website.


What will happen if I have the other website in another tab with similar 
session variable names? Will the session variables of that website be 
destroyed too? Or will the session variables be associated with the 
session id so that only the appropriate website's session variables will 
get destroyed?


Thanks in advance.

Regards,
Guruprasad

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



Re: [PHP] Doubt regarding session_destroy() in PHP 5

2009-07-21 Thread Devendra Jadhav
Yes. You are right. Session variables are associated with the session id so
only that appropriate website's session variables will get destroyed.
You can try it in your local system.

On Wed, Jul 22, 2009 at 12:42 AM, Guruprasad  wrote:

> Hi all,
> I have a doubt with creating and destroying sessions in PHP using
> session_destroy(). Supposing there is a PHP-based website hosted on a web
> server. Now I add another site that I developed using PHP on that web server
> using virtualhost. I destroy a session in my website using session_destroy()
> which will destroy all the session variables associated with my website.
>
> What will happen if I have the other website in another tab with similar
> session variable names? Will the session variables of that website be
> destroyed too? Or will the session variables be associated with the session
> id so that only the appropriate website's session variables will get
> destroyed?
>
> Thanks in advance.
>
> Regards,
> Guruprasad
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Devendra Jadhav


Re: [PHP] Doubt regarding session_destroy() in PHP 5

2009-07-21 Thread Phpster



On Jul 21, 2009, at 3:12 PM, Guruprasad  wrote:


Hi all,
I have a doubt with creating and destroying sessions in PHP using  
session_destroy(). Supposing there is a PHP-based website hosted on  
a web server. Now I add another site that I developed using PHP on  
that web server using virtualhost. I destroy a session in my website  
using session_destroy() which will destroy all the session variables  
associated with my website.


What will happen if I have the other website in another tab with  
similar session variable names? Will the session variables of that  
website be destroyed too? Or will the session variables be  
associated with the session id so that only the appropriate  
website's session variables will get destroyed?




Each session has it's own id and therefore each session will just have  
it's own data destroyed





Thanks in advance.

Regards,
Guruprasad

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



Bastien

Sent from my iPod


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



Re: [PHP] Doubt regarding session_destroy() in PHP 5

2009-07-21 Thread Floyd Resler
Keep in mind that sessions are based on the domain.  I've run into  
situations where someone will be working in several different sites  
that we host.  Each site is accessed via http://domain/site.  Each  
site has it's own database, users, etc.  However, because they all  
hang off the same domain, they get one session.  That can really mess  
things up for the users as they go from site to site.  I got around  
this by using MySQL-based sessions.  It keeps things nice and separated.


Take care,
Floyd

On Jul 21, 2009, at 4:14 PM, Devendra Jadhav wrote:

Yes. You are right. Session variables are associated with the  
session id so

only that appropriate website's session variables will get destroyed.
You can try it in your local system.

On Wed, Jul 22, 2009 at 12:42 AM, Guruprasad   
wrote:



Hi all,
I have a doubt with creating and destroying sessions in PHP using
session_destroy(). Supposing there is a PHP-based website hosted on  
a web
server. Now I add another site that I developed using PHP on that  
web server
using virtualhost. I destroy a session in my website using  
session_destroy()
which will destroy all the session variables associated with my  
website.


What will happen if I have the other website in another tab with  
similar

session variable names? Will the session variables of that website be
destroyed too? Or will the session variables be associated with the  
session

id so that only the appropriate website's session variables will get
destroyed?

Thanks in advance.

Regards,
Guruprasad

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





--
Devendra Jadhav



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



Re: [PHP] Doubt regarding session_destroy() in PHP 5

2009-07-21 Thread L.Guruprasad

Hi,
Floyd Resler wrote:
Keep in mind that sessions are based on the domain.  I've run into 
situations where someone will be working in several different sites that 
we host.  Each site is accessed via http://domain/site.  Each site has 
it's own database, users, etc.  However, because they all hang off the 
same domain, they get one session.  That can really mess things up for 
the users as they go from site to site.  I got around this by using 
MySQL-based sessions.  It keeps things nice and separated.


Take care,
Floyd


Will this be causing issues when http://1.a.b and http://2.a.b are the 
two PHP sites running on the same web server using virtualhosts?


Regards,
Guruprasad

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



[PHP] Back again with query problems and row problems

2009-07-21 Thread Miller, Terion
Okay I'm back guys...not sure what happened it was working..now it's all hung 
up...
Here are the errors:

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result 
resource in 
/var/www/vhosts/getpublished.news-leader.com/httpdocs/ResturantInspections/restaurants.php
 on line 464

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result 
resource in 
/var/www/vhosts/getpublished.news-leader.com/httpdocs/ResturantInspections/restaurants.php
 on line 488



Here is the full code snippet:

No values were submitted for the 
search.";  // Unset it so a reload 
of page doesn't redisplay the error  
unset($_SESSION['noVarsSent']);  // 
unset($_SESSION['results']);}   

 // Check if full list of restaurants has been created and stored 
yet// Store full results in $_SESSION to 
limit database hits
if(!isset($_SESSION['fullRestaurantList']))
{  // List not grabbed yet, so run query 
and store in $_SESSION  
//check for rangeif 
(!(isset($rangenum)))  {
  $rangenum = 1;  } 
 // Grab all restaurants in alphabetical order  
$sql = "SELECT ID, name, address, inDate, 
inType, notes, critical, cviolations, noncritical FROM restaurants, inspections 
WHERE restaurants.name != '' AND restaurants.ID = inspections.ID ORDER BY 
name;";  $result = mysql_query($sql);   
 //trying to 
grab it by ranges from the db? $rows = 
mysql_num_rows($sql);  $page_rows = 100;
  $last_row = ceil($rows/$page_rows);   
 if ($rangenum 
< 1){  
$rangenum = 1;  }   
   elseif ($rangenum > $last_row)  
{  $rangenum = $last_row;   
   }
//This sets the range to display in our query   
   $max = 'limit ' .($rangenum - 1) * $page_rows .',' 
.$page_rows;

// Process all results into $_SESSION array 
   $position = 1;   
 while ($row = 
mysql_fetch_array($result))  {  
$_SESSION['fullRestaurantList'][$position] = $row;  
$position++;
  }
$_SESSION['totalNumberOfRestaurants'] = $position;  
}  
?>

It's like 15min til 4pm here in Missouri and I am so out the door at 4..because 
this has been one long frustrating day..and this girl needs a beer.or two.
Talk to you all tomorrow!
Terion

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



Re: [PHP] Doubt regarding session_destroy() in PHP 5

2009-07-21 Thread Devendra Jadhav
By default sub-domains do not share sessions but you can make them to share
the session

On Wed, Jul 22, 2009 at 1:54 AM, L.Guruprasad  wrote:

> Hi,
> Floyd Resler wrote:
>
>> Keep in mind that sessions are based on the domain.  I've run into
>> situations where someone will be working in several different sites that we
>> host.  Each site is accessed via http://domain/site.  Each site has it's
>> own database, users, etc.  However, because they all hang off the same
>> domain, they get one session.  That can really mess things up for the users
>> as they go from site to site.  I got around this by using MySQL-based
>> sessions.  It keeps things nice and separated.
>>
>> Take care,
>> Floyd
>>
>
> Will this be causing issues when http://1.a.b and http://2.a.b are the two
> PHP sites running on the same web server using virtualhosts?
>
> Regards,
> Guruprasad
>



-- 
Devendra Jadhav


Re: [PHP] Doubt regarding session_destroy() in PHP 5

2009-07-21 Thread Lenin
On Wed, Jul 22, 2009 at 3:24 AM, L.Guruprasad  wrote:

> Hi,
> Floyd Resler wrote:
>
>> Keep in mind that sessions are based on the domain.  I've run into
>> situations where someone will be working in several different sites that we
>> host.  Each site is accessed via http://domain/site.  Each site has it's
>> own database, users, etc.  However, because they all hang off the same
>> domain, they get one session.  That can really mess things up for the users
>> as they go from site to site.  I got around this by using MySQL-based
>> sessions.  It keeps things nice and separated.
>>
>> Take care,
>> Floyd
>>
>
> Will this be causing issues when http://1.a.b and http://2.a.b are the two
> PHP sites running on the same web server using virtualhosts?
>
As Floyd suggested keeping your sessions in the DB will give you better
session management and security as well.


Re: [PHP] Back again with query problems and row problems

2009-07-21 Thread Jim Lucas
Miller, Terion wrote:
> Okay I'm back guys...not sure what happened it was working..now it's all hung 
> up...
> Here are the errors:
> 
> Warning: mysql_num_rows(): supplied argument is not a valid MySQL result 
> resource in 
> /var/www/vhosts/getpublished.news-leader.com/httpdocs/ResturantInspections/restaurants.php
>  on line 464
> 
> Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result 
> resource in 
> /var/www/vhosts/getpublished.news-leader.com/httpdocs/ResturantInspections/restaurants.php
>  on line 488
> 
> 
> 
> Here is the full code snippet:
> 
>
>   
>   
>   
>   
>   // Check if 
> page is set to show all
> if(isset($_GET['show']) && $_GET['show'] == 'all')
> {  unset($_SESSION['results']);   
>unset($_SESSION['searchname']);
>   unset($_SESSION['address']);
>   
 }  
  // Check if there was an empty search sent
if(isset($_SESSION['noVarsSent'])){ 
 echo "No values were submitted for 
the search.";  // Unset it so a 
reload of page doesn't redisplay the error  
unset($_SESSION['noVarsSent']);  // 
unset($_SESSION['results']);}   

 // Check if full list of restaurants has been created and stored 
yet// Store full results in $_SESSION to 
limit database hits
if(!isset($_SESSION['fullRestaurantList']))   
 {  // List not grabbed yet, so run 
query and store in $_SESSION
  //check for rangeif 
(!(isset($rangenum)))  {
  $rangenum = 1;  } 
 // Grab all restaurants in alphabetical order  
$sql = "SELECT ID, name, address, inDate, 
inType, notes, critical, cviolations, noncritical FROM restaurants, inspections 
WHERE restaurants.name != '' AND restaurants.ID = inspections.ID ORDER BY 
name;";  $result = mysql_query($sql);   
 //trying to 
grab it by ranges from the db? $rows = 
mysql_num_rows($sql);   
   $page_rows = 100;  $last_row = 
ceil($rows/$page_rows); 
   if ($rangenum < 1){  
$rangenum = 1;  
}  elseif ($rangenum > $last_row)   
   {  $rangenum 
= $last_row;  } 
   //This sets the range to display 
in our query  $max = 'limit ' .($rangenum - 
1) * $page_rows .',' .$page_rows;   

 // Process all results into $_SESSION array

$position = 1;  
  while ($row = mysql_fetch_array($result)) 
 {  
$_SESSION['fullRestaurantList'][$position] = $row;  
$position++;  } 
   

[PHP] newbie - Is there a calendar module for date entry?

2009-07-21 Thread c...@hosting4days.com

newbie ...

- is there a calendar module for date fields?

- so that a small calendar pops up - then you can click on a date,   
to add to a field - like google or yahoo calendars has...?


BTW: I saw this - but it doesn't seem to be the right thing ( more  
meant for Converter issues) for what I'm looking for...


http://us2.php.net/manual/en/intro.calendar.php


--
Thanks - RevDave
Cool @ hosting4days . com
[db-lists 09]




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



Re: [PHP] newbie - Is there a calendar module for date entry?

2009-07-21 Thread Jonathan Tapicer
On Tue, Jul 21, 2009 at 10:06 PM,
c...@hosting4days.com wrote:
> newbie ...
>
> - is there a calendar module for date fields?
>
> - so that a small calendar pops up - then you can click on a date,  to add
> to a field - like google or yahoo calendars has...?
>
> BTW: I saw this - but it doesn't seem to be the right thing ( more meant for
> Converter issues) for what I'm looking for...
>
> http://us2.php.net/manual/en/intro.calendar.php
>
>
> --
> Thanks - RevDave
> Cool @ hosting4days . com
> [db-lists 09]
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

That is javascript thing, not PHP.

The Yahoo UI has a nice one, here you have an example:
http://developer.yahoo.com/yui/examples/calendar/calcontainer_clean.html,
and here the module reference:
http://developer.yahoo.com/yui/calendar/

Jonathan

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



Re: [PHP] Converting SQL Dialects

2009-07-21 Thread Paul M Foster
On Tue, Jul 21, 2009 at 06:54:35PM +0100, Ashley Sheridan wrote:

> On Tue, 2009-07-21 at 13:46 -0400, Matt Neimeyer wrote:
> > Has anyone come across / written a script that will convert one
> > "flavor" or Dialect of SQL to another?
> >
> > I need to convert Visual FoxPro 6.0 style WHERE clauses to MySQL.
> >
> > For the most part the problems are converting VFP functions to the
> > equivalent SQL. For example, Visual FoxPro has a function inlist()
> > that is used like inlist(X,1,2,3) which converts to the MySQL query "X
> > IN (1,2,3)". That's easy enough (relatively speaking) but VFP also has
> > stuff like "EMPTY(X)" where any of Null, the Empty String (for Char),
> > -00-00 (or the VFP equivalent anyways for dates), False (for
> > Boolean), 0 (for Numeric) are considered empty without needing to
> > know the data type. So that starts getting a lot more complex since I'd
> > need to check the data type of the field in the "right" table... to be
> > able to convert it to something like (X is null OR X="") or (X is null
> > OR x=0) etc...
> >
> > These are for customer "stored" queries... I've already manually
> > converted "system" queries and I'm frustrated to the point of giving
> > up and adding a column "untested" and let the end user figure it out
> > but that seems bad from the standpoint of "lazy" and "poor customer
> > experience".
> >
> > Thanks!
> >
> > Matt
> >
> > P.S. I'm also going to post this to the MySQL general list but my fear
> > is that they MIGHT say "We only know MySQL so we can't help you with
> > that other DBMS" I'm hoping that by posting here someone might say
> > "well it's not to MySQL but I ran script XYZ to convert my VFP to
> > PostgreSQL..." or similar.
> >
> 
> I'm not sure it's as easy as you think it might be. As you get more into
> the various flavours of SQL, you notice their little idiosyncrasies that
> only exist within that one particular language branch. As such, it's
> often a task best left to people to try and convert from one to the
> other, rather than leave it to a machine. How complex are the queries
> that you are trying to convert anyway?

I have to agree with Ash here. I was a FoxPro 2.6a DOS programmer (just
at the beginning of VFP). We hired a programmer who did a lot of his
queries in FoxPro's crippled version of SQL, but the rest of us just
used regular FoxPro for queries. Remembering what FoxPro SQL was like,
and now having worked with MySQL and PostgreSQL, I wouldn't wish the
conversion of one SQL dialect to another on anyone.

Paul

-- 
Paul M. Foster

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