Re: [PHP] Which query is more correct?

2009-11-23 Thread LAMP

Rick Pasotto wrote:

On Fri, Nov 20, 2009 at 04:41:58PM -0600, LAMP wrote:
  

Hi,
I need to pull all records from the table Registrants they are NOT
in the table ToBeRecleared

Registrants.Reg_ID is PK
ToBeRecleared.tbrc_Reg_ID is PK

Which query is more correct?

SELECT r.*
FROM registrants r
where r.reg_status=1 AND r.reg_id NOT IN (SELECT tbrc_reg_id FROM
toberecleared)


SELECT r.*
FROM registrants r
where r.reg_status=1 AND (SELECT count(*) FROM toberecleared where
tbrc_reg_id=r.reg_id) = 0

I checked explain of bot queries - but can't "read" them.  :-)



SELECT t1.*
FROM registrants t1
LEFT JOIN ToBeRecleared t2 on t1.reg_id = t2.tbrc_reg_id
where t2.tbrc_reg_id is NULL

  

thanks!
:-)


Re: [PHP] Change styling depending on var value

2009-11-23 Thread Phil Matt

Mari Masuda wrote:


This may be a dumb question, but did you actually fetch the db query's results 
and put them in $row before trying to use $row?  In MySQL you could do 
something like:

$query = "select * from my_table";
$result = mysql_query($query);
$row = mysql_fetch_array($result);  //this statement would need to be inside of 
a loop if there is more than one result

Thanks, Mari. That was it: I usually declare the variables first, then 
on with the rest of the code. I had inserted the $row conditional values 
right after the vars, before the rest of the query...just plain dumb.


Cheers --- Phil

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



[PHP] Re: PHP and XML

2009-11-23 Thread Nathan Rixham
Juan Marcelo Rodríguez Monti wrote:
> Hi people,
> I have some doubts about this topic that I'm gonna explain.
> 
> I have a few sites in flash, and I was requested to write a PHP frontend
> to send news. I have this already done and it works perfect. It's a LAMP
> App to send and edit news, post video, images and so on.
> 
> Then, I need to put all this news into the Flash site. So, I need to use
> XML. I'm not gonna discuss about Flash, because this is a PHP List,
> however I would like to talk about PHP and XML.
> 
> What do you recommend me to produce XML from those news of the SQL
> database?. What do you suggest to output XML from the existing content
> to then put those XML files into Flash.
> 
> The posted news are saved in a MySQL database. I don't know if do I need
> to output from PHP then parse the output and convert it to XML, or if Do
> I need to get the array from the MySQL and directly output this to an
> XML file to then get from this file from Flash.
> 
> Thanks,
> Juan.
> 

flash remoting: you could use amf instead; its faster and easier to use.

on the php side just use http://amfphp.org/ or suchlike

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



[PHP] function not returning query

2009-11-23 Thread Allen McCabe
Hi, thanks for reading, I hope you can help:

In my main file for an orders page I have the following code:


if (isset($_GET['filterby']))
 {
  $resultOrders = adminFilterQuery();
  $numberOfOrders = mysql_num_rows($resultOrders);
 }
 else
 {
  $resultOrders = mysql_query("SELECT * FROM afy_order;") or
die(mysql_error("Could not query the database!"));
  $numberOfOrders = mysql_num_rows($resultOrders);
 }


adminFilterQuery() is a custom function that is supposed to return a
mysql_query, here are the last few lines of this function:


$query = "SELECT * FROM afy_order WHERE school_id = '{$school}' ORDER BY
{$order_by_param};";
$result = mysql_query($query);
return $result;

l am getting this error when I try to filter my query using a form in tandem
with the quey building function:

*Warning*: mysql_num_rows(): supplied argument is not a valid MySQL result
resource

where the line is the one where I use the mysql_num_rows function.

What am I missing here?

Thanks!


Re: [PHP] function not returning query

2009-11-23 Thread Phpster

Likely your query failed due to an error.

Try adding an or die(mysql_error()) to the end of your mysql_query  
statement to see what that error maybe


Bastien

Sent from my iPod

On Nov 23, 2009, at 7:22 PM, Allen McCabe  wrote:


Hi, thanks for reading, I hope you can help:

In my main file for an orders page I have the following code:


if (isset($_GET['filterby']))
{
 $resultOrders = adminFilterQuery();
 $numberOfOrders = mysql_num_rows($resultOrders);
}
else
{
 $resultOrders = mysql_query("SELECT * FROM afy_order;") or
die(mysql_error("Could not query the database!"));
 $numberOfOrders = mysql_num_rows($resultOrders);
}


adminFilterQuery() is a custom function that is supposed to return a
mysql_query, here are the last few lines of this function:


$query = "SELECT * FROM afy_order WHERE school_id = '{$school}'  
ORDER BY

{$order_by_param};";
$result = mysql_query($query);
return $result;

l am getting this error when I try to filter my query using a form  
in tandem

with the quey building function:

*Warning*: mysql_num_rows(): supplied argument is not a valid MySQL  
result

resource

where the line is the one where I use the mysql_num_rows function.

What am I missing here?

Thanks!


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



[PHP] Query based on Server offset TimeStamp

2009-11-23 Thread Don Wieland

Hello,

I have a mySQL database server in Florida USA (EST) and I want to do a  
query on a record in California, USA (PST) 3 hours earlier using PST  
instead of EST.


I would like to add to my CORE page that offset of the timezone so I  
can use it in a query like:


Select * FROM aTable WHERE ServerOffsetTimeStap >= Row_Start_TimeStamp  
AND ServerOffsetTimeStap <= Row_End_TimeStamp


How would I do this?

Appreciate any help you can offer. Thanks!


Don Wieland
D W   D a t a   C o n c e p t s
~
d...@dwdataconcepts.com
Direct Line - (949) 305-2771

Integrated data solutions to fit your business needs.

Need assistance in dialing in your FileMaker solution? Check out our  
Developer Support Plan at:

http://www.dwdataconcepts.com/DevSup.html

Appointment 1.0v9 - Powerful Appointment Scheduling for FileMaker Pro  
9 or higher

http://www.appointment10.com

For a quick overview -
http://www.appointment10.com/Appt10_Promo/Overview.html


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



[PHP] Re: My experience with the "Forms Generation and Validation" class

2009-11-23 Thread Manuel Lemos
Hello Anonymous complainer,

on 11/22/2009 09:23 AM LinuxManMikeC said the following:
> Just like to share my real world experience with Manuel Lemos'
> "formsgeneration" library.
> http://www.phpclasses.org/formsgeneration
> 
> At work early this summer we had a project under a tight deadline that
> needed unified form creation, processing, and error reporting.  I had
> seen Manuel promoting his formsgeneration class on the mailing list
> and thought I'd look into it to help keep the project within the
> deadline.  I read some positive reviews and comments, the demos looked
> promising, and the interface seemed good enough.  Little did I know
> the headaches I was in for.  I found the configuration structures and
> interface to be extremely cumbersome, not to mention terribly
> documented.  The interface seems quite inefficient and in most cases
> its easier just to throw together a form and validation code by hand.
> Usage was often convoluted, and due to the poor documentation I spent
> half my effort trying to decipher the interface.  And it was difficult
> to customize in several areas.  While it can work well enough in
> several simple cases, in my opinion it is too cumbersome for any
> significant form processing project, especially in the business world.
>  I ended up wasting a week of work using the formsgeneration class and
> had to redo the project making my own form utility code from scratch
> as I went (which took just as much time and actually worked as
> intended).  Granted I did make the mistake of not giving myself enough
> evaluation time before the project.  I just want caution others to
> carefully evaluate this code before deciding to use it in their
> projects, especially since Manuel seems so eager to promote his code
> (and his web site) whenever the opportunity arises.  And in general,
> to be cautious and take your time when evaluating any 3rd party code
> for production use.

There seems to be a misunderstanding. I am not eager to promote my code.
I just look forward to have my classes tested by as many people as
possible, so I get as many bug reports and feature improvements as possible.

The fact is that I developed this and many other packages for my own
purposes. Nowadays I could not live without them because they make me
several orders of magnitude more productive than if I had to do it edit
HTML code mannually as you said you did.

Anyway, maybe this surprises you, but I like criticism. Especially
constructive criticisms from people that are able to give specific
examples of what they do not like, instead of making vague claims as you
did.

I like constructive criticism because it helps me making my code better,
more useful to others and ultimately to myself. That is why I publish my
work as Open Source.

Unfortunately you did make any constructive criticism. There seems to be
no way to improve my work because you were not specific to what exactly
you find cumbersome, even less what you would different to make it less
cumbersome.

I never claimed it would be perfect for everybody. What is good and
productive for some, maybe hard and difficult for others, especially if
you try to learn all by yourself and never ask for help.

The class has a support forum where you can ask questions and always get
a response so you never get stuck.

http://www.phpclasses.org/discuss/package/1/

Anyway, I don't know if you ever asked for help because you are using an
anonymous identity here. Actually, I wonder why you bother to write a
special message anonymously just campaign against the forms class. It
makes me wonder if you have other reasons to do it that you may not be
revealing unrelated with the class.

Anyway, I am not upset. I am just sorry that you made many criticisms
without giving real examples to demonstrate your points. That way it
will not be helpful to anybody.


-- 

Regards,
Manuel Lemos

Find and post PHP jobs
http://www.phpclasses.org/jobs/

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/

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



Re: [PHP] function not returning query

2009-11-23 Thread Philip Thompson
On Nov 23, 2009, at 6:22 PM, Allen McCabe wrote:

> Hi, thanks for reading, I hope you can help:
> 
> In my main file for an orders page I have the following code:
> 
> 
> if (isset($_GET['filterby']))
> {
>  $resultOrders = adminFilterQuery();
>  $numberOfOrders = mysql_num_rows($resultOrders);
> }
> else
> {
>  $resultOrders = mysql_query("SELECT * FROM afy_order;") or
> die(mysql_error("Could not query the database!"));
>  $numberOfOrders = mysql_num_rows($resultOrders);
> }

You reduce this part by one line by putting the following after the else 
statement and removing the other 2:

$numberOfOrders = mysql_num_rows ($resultOrders);

Also, these queries don't need a semi-colon (;) to end the query. PHP handles 
this part. Remove them.


> adminFilterQuery() is a custom function that is supposed to return a
> mysql_query, here are the last few lines of this function:
> 
> 
> $query = "SELECT * FROM afy_order WHERE school_id = '{$school}' ORDER BY
> {$order_by_param};";
> $result = mysql_query($query);
> return $result;
> 
> l am getting this error when I try to filter my query using a form in tandem
> with the quey building function:
> 
> *Warning*: mysql_num_rows(): supplied argument is not a valid MySQL result
> resource
> 
> where the line is the one where I use the mysql_num_rows function.
> 
> What am I missing here?
> 
> Thanks!

Do you get this warning with both queries? Make sure that your queries are 
using a valid mysql connection. You may also consider using a database class to 
perform the repetitive tasks so that you really only have to be concerned with 
the queries you're writing...?

query('SELECT * FROM afy_order');
$numRows = $db->numRows($result);
?>

Of course this is just a simple example, but you get the idea. Hope that stirs 
your brain!

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



Re: [PHP] Query based on Server offset TimeStamp

2009-11-23 Thread Philip Thompson
On Nov 23, 2009, at 7:37 PM, Don Wieland wrote:

> Hello,
> 
> I have a mySQL database server in Florida USA (EST) and I want to do a query 
> on a record in California, USA (PST) 3 hours earlier using PST instead of EST.
> 
> I would like to add to my CORE page that offset of the timezone so I can use 
> it in a query like:
> 
> Select * FROM aTable WHERE ServerOffsetTimeStap >= Row_Start_TimeStamp AND 
> ServerOffsetTimeStap <= Row_End_TimeStamp
> 
> How would I do this?
> 
> Appreciate any help you can offer. Thanks!

When I store timestamps, I store them in GMT time. This way, no matter when you 
pull it out of the database, you *know* when it was stored - even in a 
different timezone. To achieve this...



Maybe this will make it a little easier to query accordingly...? Hope this 
stirs your brain.

~Philip

PS... Others may profess that you use UTC instead of GMT, but that's a 
different thread.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] function not returning query

2009-11-23 Thread Allen McCabe
Okay, suddenly I got it to filter the results, but I still can't figure out
where this part of the query is coming from, at the end of the query string
in the URL, I have this "filter.x=0&filter.y=0".

No where in my form do I have a field named filter.x or filter.y. I DO
however, have 3 forms (I don't want to mess with AJAX), my set up looks like
this:

Filter by:
User - [username dropdown  v] Order by [database fields  v] Asc/Desc
[Ascend  v] - Go
School - [school dropdown  v] Order by [database fields  v] Asc/Desc
[Ascend  v] - Go
Show - [show dropdown  v] Order by [database fields  v] Asc/Desc [Ascend  v]
- Go

There are actually two order by fields, but this gives you the idea. Each of
the three lines is a separate form, each with a unique name all with a "get"
method, but all three Go buttons are named "filter", I didn't think to try
changing it until now, but is this perhaps where the filter.x and filter.y
are coming from? I have never seen this before in a query.

Oh, now the filter that was working spontaneously gives me the error I have
been getting all along, this is so frustrating.

To those who asked, yes I am connected to the database; I forgot to mention
that the else part of my if statement works, as long as I don't try to
filter my results it works.

Here is an example of the URL that my filter function (via one of the 3
forms) outputs:
http://lpacmarketing.hostzi.com/afy/orders/default.php?filterby=school&schoolid=36&orderby1=order_id&asc_desc_order1=Descend&orderby2=pmt_recd_date&asc_desc_order2=Descend&filter.x=13&filter.y=8&filter=Go

On Mon, Nov 23, 2009 at 8:03 PM, Philip Thompson wrote:

> On Nov 23, 2009, at 6:22 PM, Allen McCabe wrote:
>
> > Hi, thanks for reading, I hope you can help:
> >
> > In my main file for an orders page I have the following code:
> >
> >
> > if (isset($_GET['filterby']))
> > {
> >  $resultOrders = adminFilterQuery();
> >  $numberOfOrders = mysql_num_rows($resultOrders);
> > }
> > else
> > {
> >  $resultOrders = mysql_query("SELECT * FROM afy_order;") or
> > die(mysql_error("Could not query the database!"));
> >  $numberOfOrders = mysql_num_rows($resultOrders);
> > }
>
> You reduce this part by one line by putting the following after the else
> statement and removing the other 2:
>
> $numberOfOrders = mysql_num_rows ($resultOrders);
>
> Also, these queries don't need a semi-colon (;) to end the query. PHP
> handles this part. Remove them.
>
>
> > adminFilterQuery() is a custom function that is supposed to return a
> > mysql_query, here are the last few lines of this function:
> >
> >
> > $query = "SELECT * FROM afy_order WHERE school_id = '{$school}' ORDER BY
> > {$order_by_param};";
> > $result = mysql_query($query);
> > return $result;
> >
> > l am getting this error when I try to filter my query using a form in
> tandem
> > with the quey building function:
> >
> > *Warning*: mysql_num_rows(): supplied argument is not a valid MySQL
> result
> > resource
> >
> > where the line is the one where I use the mysql_num_rows function.
> >
> > What am I missing here?
> >
> > Thanks!
>
> Do you get this warning with both queries? Make sure that your queries are
> using a valid mysql connection. You may also consider using a database class
> to perform the repetitive tasks so that you really only have to be concerned
> with the queries you're writing...?
>
>  class database {
>public function query ($sql) {
>$result = mysql_query ($sql);
>if ($result === false) {
>die ('Uh oh!');
>}
>return $result;
>}
>
>public function numRows ($result) {
>return mysql_num_rows ($result);
>}
> }
> $db = new database();
> $result = $db->query('SELECT * FROM afy_order');
> $numRows = $db->numRows($result);
> ?>
>
> Of course this is just a simple example, but you get the idea. Hope that
> stirs your brain!
>
> ~Philip