php-general Digest 23 Dec 2008 22:14:12 -0000 Issue 5862

Topics (messages 285002 through 285022):

Re: Create PHP form from MySQL table structure
        285002 by: Ronnie MacGregor
        285003 by: Jay Blanchard
        285005 by: Richard Heyes
        285008 by: tedd
        285011 by: Jay Blanchard
        285012 by: Eric Butera
        285016 by: Ronnie MacGregor
        285018 by: Ronnie MacGregor
        285019 by: Ronnie MacGregor

Configuring interfaces through php
        285004 by: Heysem Kaya
        285009 by: Nathan Nobbe

Re: eof bof in php
        285006 by: tedd
        285021 by: German Geek

Assignment (Was Re: [PHP] More microptimisation (Was Re: [PHP] Variable as an 
index)
        285007 by: tedd

Re: shell_exec seems to hang other web requests while running convert
        285010 by: Nathan Nobbe

Where I can find the PHP5 grammar/specification?
        285013 by: Juan Kinunt
        285014 by: Nathan Nobbe

Segmentation fault in php5-imap
        285015 by: Dan Osipov
        285017 by: Nathan Nobbe
        285020 by: Dan Osipov

Help with a Search Function
        285022 by: Terion Miller

Administrivia:

To subscribe to the digest, e-mail:
        [email protected]

To unsubscribe from the digest, e-mail:
        [email protected]

To post to the list, e-mail:
        [email protected]


----------------------------------------------------------------------
--- Begin Message ---
On Sun, 21 Dec 2008 12:24:30 -0500
tedd said :

> Interesting.
> 
> I am sure that one can write a script to find all the fields in a 
> table and create a form from that.

Yes I could write my own, but was trying to avoid re-inventing the wheel.

> However, I don't know of any utility that does that.
> Hope that helps,
 
Well ... it eliminates one person from my enquiries <bg>.

-- 
Ronnie MacGregor
Scotland

Ronnie at
dBASEdeveloper
dot co dot uk

www.dBASEdeveloper.co.uk




--- End Message ---
--- Begin Message ---
[snip]
Yes I could write my own, but was trying to avoid re-inventing the
wheel.
[/snip]

Here is a quick and dirty function that I have used for a couple of
years now, complete with comments;

function formCreate($database, $table, $action, $excludeCols,
$recordID){
        /* 
         * This function is used to create forms on the fly based on
tables within 
         * the database. The minimal arguments are database name and
table name.
         * Additional arguements may be supplied to indicate columns to
be excluded
         * from form and an action (CRUD) to be performed once the form
         * is filled out. If wanting to do an update, read or delete you
can specify
         * a record to retrieve to populate the form. Default values
will be provided 
         * for arguements not included.
         */
         /* database connection in global variable */
         global $dc;
         /* number of arguments sent to function */
         $numArgs = func_num_args();
         /* test to make sure that you have the minimal two arguements
*/
         if(2 > $numArgs){
                /* not enough arguments */
                $errMsg = "not enough arguments supplied, please supply
database and table name";
                return($errMsg);
         } else {
                /* 
                 * Supply default values for optional arguments if they
are not set.
                 * An interesting note here: the action can be anything
that the user
                 * specifies, it is not strictly limited to CRUD and it
will be output
                 * in a hidden form field; 
                 * <input type="hidden" name="action" value="whatever
action is called"> 
                 * That way when the user clicks 'Submit' the programmer
can have a 
                 * switch action in his or her processing script to
handle this form. 
                 */
                 if(!isset($action))          { $action = 'read'; }
                 if(!isset($recordID))        { $recordID = ''; }
                 if(!isset($excludeCols)){
                        $excludeCols = '';
                 } else {
                        /* create an array of excluded columns */
                        $arrExcludeCols = explode(",", $excludeCols);
                 }
                
                /* describe the table */
                $sqlDesc = "DESCRIBE `".$database."`.`".$table."` ";
                if(!($dbInfo = mysql_query($sqlDesc, $dc))){
                        return mysql_error();
                } else {
                        while($tableInfo = mysql_fetch_array($dbInfo)){
                                /* 
                                 * regular expression - we need the data
that exists between the
                                 * parentheses in the Type column of the
database being described
                                 * so that we can use for length values
of form fields
                                 */
                                 if(!(in_array($tableInfo['Field'],
$arrExcludeCols))){
                                        if(preg_match (
"/\((\d{1,}.*?)\)/", $tableInfo[1], $regs )){
                                                /* handle numerical
values in parentheses to create form element lengths */
                                                echo
"<label>".$tableInfo['Field']."</label>";
                                                echo "<input
type=\"text\" name=\"".$tableInfo['Field']."\" size=\"".$regs[1]."\"
maxlength=\"".$regs[1]."\"><br />\n";
                                        } elseif("text" ==
$tableInfo[1]) {
                                                /* handle text columns
*/
                                                echo
"<label>".$tableInfo['Field']."</label>";
                                                echo "<textarea
name=\"".$tableInfo['Field']."\" cols=\"80\" rows=\"10\"></textarea><br
/>\n";
                                        } elseif("enum" ==
substr($tableInfo[1], 0, 4)){
                                                /* handle enumerated
columns and create drop downs */
                                                echo
"<label>".$tableInfo['Field']."</label>&nbsp;";
                                                /*
                                                 * regular expression -
we need the data that
                                                 * exists between the
single quotes in the Type column of the
                                                 * database being
described so that we can use for option 
                                                 * values in a drop-down
on the form
                                                 */
                                                preg_match_all(
"/'(.*)'/U", $tableInfo[1], $matches);
                                                echo "<select
name=\"".$tableInfo['Field']."\">\n";
                                                echo
"<option></option>\n";
                                                for($i = 0; $i <
count($matches[1]); $i++){
                                                        echo
"<option>".$matches[1][$i]."</option>\n";
                                                }
                                                echo "</select><br
/>\n";
                                        }//end if preg
                                }//end if in_array
                        }//end while tableInfo
                        /* set up the hidden action field */
                        echo "<input type=\"hidden\" name=\"action\"
value=\"".$action."\">\n";
                        /* provide a submit and reset button */
                        echo "<input type=\"submit\" name=\"submit\"
value=\"Submit\">&nbsp;&nbsp;";
                        echo "<input type=\"reset\" name=\"reset\"
value=\"Clear\"><br />\n";
                        return;
                }// end if dbInfo
        }// end if numArgs
}//end function formCreate

--- End Message ---
--- Begin Message ---
> ...

In a similar vain to phpMyEdit (or whatever it's called), is my MySQL
Table Editor. It's aimed at maintaining a table, but without allowing
users to destroy your table.... Which helps.

http://www.phpguru.org/static/TableEditorComparison.html
http://www.phpguru.org/static/TableEditor.html

-- 
Richard Heyes

HTML5 Graphing for FF, Chrome, Opera and Safari:
http://www.rgraph.org (Updated December 20th)

--- End Message ---
--- Begin Message ---
Here is a quick and dirty function that I have used for a couple of
years now, complete with comments;


-snip-


Nice piece of code -- thanks for providing that.

Cheers,

tedd
--
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com

--- End Message ---
--- Begin Message ---
[snip]
Nice piece of code -- thanks for providing that.
[/snip]

You're welcome. It could stand a few small improvements, but I pretty
much use it every day.

--- End Message ---
--- Begin Message ---
On Sun, Dec 21, 2008 at 5:35 AM, R B MacGregor
<[email protected]> wrote:
> Hi folks
>
> Anybody got any recommendations for a utility which would create a quick head
> start by creating the php/html code for a basic form using the field structure
> of a MySQL table ?
>
> Thanks for any suggestions.
>
> --
> Ronnie MacGregor
> Scotland
>
> Ronnie at
> dBASEdeveloper
> dot co dot uk
>
> www.dBASEdeveloper.co.uk
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

a lot of frameworks have scaffolding or crud screens they can make for
you to do this. (cake, akelos, yii, code igniter)

http://codeigniter.com/user_guide/general/scaffolding.html
http://book.cakephp.org/view/311/Scaffolding
http://www.yiiframework.com/doc/guide/quickstart.first-app#implementing-crud-operations

--- End Message ---
--- Begin Message ---
On Tue, 23 Dec 2008 06:38:29 -0600
Jay Blanchard said :

> Here is a quick and dirty function that I have used for a couple of
> years now, complete with comments;

This looks very promising, .... thanks for sharing.

-- 
Ronnie MacGregor
Scotland

Ronnie at
dBASEdeveloper
dot co dot uk

www.dBASEdeveloper.co.uk




--- End Message ---
--- Begin Message ---
On Tue, 23 Dec 2008 11:38:22 -0500
Eric Butera said :

> 
> a lot of frameworks have scaffolding or crud screens they can make for
> you to do this. (cake, akelos, yii, code igniter)
> 
> http://codeigniter.com/user_guide/general/scaffolding.html
> http://book.cakephp.org/view/311/Scaffolding
> http://www.yiiframework.com/doc/guide/quickstart.first-app#implementing-crud-operations
> 

Thanks .... interesting material.

-- 
Ronnie MacGregor
Scotland

Ronnie at
dBASEdeveloper
dot co dot uk

www.dBASEdeveloper.co.uk




--- End Message ---
--- Begin Message ---
On Tue, 23 Dec 2008 13:15:04 +0000
Richard Heyes said :

> In a similar vain to phpMyEdit (or whatever it's called), is my MySQL
> Table Editor. It's aimed at maintaining a table, but without allowing
> users to destroy your table.... Which helps.
> 
> http://www.phpguru.org/static/TableEditorComparison.html
> http://www.phpguru.org/static/TableEditor.html

Yes ... looks similar to phpMyEdit. Thanks for the links. 

-- 
Ronnie MacGregor
Scotland

Ronnie at
dBASEdeveloper
dot co dot uk

www.dBASEdeveloper.co.uk




--- End Message ---
--- Begin Message ---
Hi,
I would like to configure the interfaces from a web page. What I should do is 
(AFAIK) writing reading /etc/network/interfaces and writing it. Rebooting 
networking after writing process.

How can I do it in a practical way?

Heysem

--- End Message ---
--- Begin Message ---
On Tue, Dec 23, 2008 at 6:07 AM, Heysem Kaya <[email protected]>wrote:

> Hi,
> I would like to configure the interfaces from a web page. What I should do
> is (AFAIK) writing reading /etc/network/interfaces and writing it. Rebooting
> networking after writing process.
>
> How can I do it in a practical way?


you can do this via the exec family of functions.

shell_exec('/etc/init.d/net.eth0 restart');

however, youll want to consider 3 things (at least),
1. the user the webserver is running as will need permission to do this.
that is best arranged via sudo.
2. giving the webserver user such permission increases your security risk on
that box
3. if the software fails to restart the interface, you might not get a
response back from the server ;)

-nathan

--- End Message ---
--- Begin Message ---
At 2:21 PM -0500 12/22/08, Anthony Gentile wrote:
I would argue it is better practice as:

<h1><?php echo 'Hello World'; ?></h1>

than

<?php
echo "<h1>Hello World</h1>";
?>
Anthony Gentile


Certainly, but all you have done here is to move your <?php ?> to different places.

There is a threshold one reaches in deciding where is the "best" place to put the "<?php ... ?>" -- it's a personal choice.

With me, a one liner is sufficient for me to use:

<h1><?php echo 'Hello World'; ?></h1>

For more than that, I usually:

?>

html

<?php

I use heredoc for email text, but not for html. I do this primarily because I like the way my editor works for showing paired tags and braces. It makes it easy for me to check tag pairing.

Cheers,

tedd


--
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com

--- End Message ---
--- Begin Message ---
Totally agree. Whenever i can i put html outside of php tags mainly because
the code gets more readable because in eclipse u get syntax highlighting
etc.

Tim-Hinnerk Heuer

http://www.ihostnz.com


On Wed, Dec 24, 2008 at 4:13 AM, tedd <[email protected]> wrote:

> At 2:21 PM -0500 12/22/08, Anthony Gentile wrote:
>
>> I would argue it is better practice as:
>>
>> <h1><?php echo 'Hello World'; ?></h1>
>>
>> than
>>
>> <?php
>> echo "<h1>Hello World</h1>";
>> ?>
>> Anthony Gentile
>>
>>
> Certainly, but all you have done here is to move your <?php ?> to different
> places.
>
> There is a threshold one reaches in deciding where is the "best" place to
> put the "<?php ... ?>" -- it's a personal choice.
>
> With me, a one liner is sufficient for me to use:
>
> <h1><?php echo 'Hello World'; ?></h1>
>
> For more than that, I usually:
>
> ?>
>
> html
>
> <?php
>
> I use heredoc for email text, but not for html. I do this primarily because
> I like the way my editor works for showing paired tags and braces. It makes
> it easy for me to check tag pairing.
>
>
> Cheers,
>
> tedd
>
>
> --
> -------
> http://sperling.com  http://ancientstones.com  http://earthstones.com
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message ---
At 9:10 AM +1100 12/23/08, Clancy wrote:
Schlossnagle (in "Advanced PHP Programming") advises:

$i = 0; while ($i < $j)
        {
        ........
        ++$i;
        }

rather than:

$i = 0; while ($i < $j)
        {
        .......
        $i++;
        }

as the former apparently uses less memory references. However I find it very hard to

Two things:

1. One statement, one line.
2. The code between the two examples is different; produces different results; and thus is rather pointless in making a definitive comparison.

Assignment, demonstrate a correct way to test ++i vs i++.

Cheers,

tedd

--
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com

--- End Message ---
--- Begin Message ---
On Tue, Dec 23, 2008 at 1:18 AM, German Geek <[email protected]> wrote:

> We can live with the fact that it will take a little longer to process the
> images. The image processing is only done by 2 people, about once a month,
> just to save them time (they would do it with photoshop otherwise and it is
> really boring and time consuming).


oic


> In fact, i might set up an automatic email when its finished. :-)


nice


> In the future it might become an issue when people can edit their own
> ebooks. This project dates back to 1999, so a lot of it is legacy (a binary
> page definition data format...). We're thinking of moving to swf pages
> instead of images, as they currently are, that will reduce the time to be
> taken to convert a pdf by thousands and would increase the quality and
> reduce download times for end users, but it will take time to develop which
> is not at hand atm.
>


> We have been thinking about scaling issues as well for quite some time
> now...
> It was hard enough to get them to move to Linux, since i work in a .NET
> shop...
> Setting up load balancing is not a trivial task though and expensive to
> host.


it'll take up another 1u, but we run the older alteon load balancers which
can be had pretty cheaply from ebay,

http://shop.ebay.com/?_from=R40&_trksid=m38.l1313&_nkw=alteon&_sacat=See-All-Categories


> I'm the main software developer on this project and am too busy adding
> features and debugging ActionScript, C++ and PHP code to do that as well.


good times.

thanks for elaborating, sounds like things are well in hand.  and a merry
christmas to you too ;D

-nathan

--- End Message ---
--- Begin Message ---
Hi!
I'm looking for the PHP 5 grammar specification. I'm studying the
possibility of implementing an abstract interpretation tool with flex/bison
in order to find security vulnerabilities (Injection vulnerabilities, XSS)
in the code in a static manner. I know Pixy but I would like to study
another possibility.
Where I can find the grammar? What do you think about this idea?

--- End Message ---
--- Begin Message ---
On Tue, Dec 23, 2008 at 11:19 AM, Juan Kinunt <[email protected]> wrote:

> Hi!
> I'm looking for the PHP 5 grammar specification. I'm studying the
> possibility of implementing an abstract interpretation tool with flex/bison
> in order to find security vulnerabilities (Injection vulnerabilities, XSS)
> in the code in a static manner. I know Pixy but I would like to study
> another possibility.
> Where I can find the grammar? What do you think about this idea?
>

this question may be better suited to the internals list.

-nathan

--- End Message ---
--- Begin Message ---
Hello,

I have a CLI PHP script I'm running on a Debian Etch server every 15 minutes, that downloads messages from NNTP server using PHP imap functions. The script is working fine on several Windows systems, and other Linux servers, but has been continuously throwing a segfault error on this particular machine.

I've recompiled PHP 5.2.8 from source, upgraded all packages, recompiled libc-client2002edebian, etc. I'm at loss at what I can do to debug this issue further. Can someone recommend what I should check?

Dan


--- End Message ---
--- Begin Message ---
On Tue, Dec 23, 2008 at 12:34 PM, Dan Osipov <[email protected]>wrote:

> Hello,
>
> I have a CLI PHP script I'm running on a Debian Etch server every 15
> minutes, that downloads messages from NNTP server using PHP imap functions.
> The script is working fine on several Windows systems, and other Linux
> servers, but has been continuously throwing a segfault error on this
> particular machine.
>
> I've recompiled PHP 5.2.8 from source, upgraded all packages, recompiled
> libc-client2002edebian, etc. I'm at loss at what I can do to debug this
> issue further. Can someone recommend what I should check?


have you checked the versions of the imap libraries on those systems to
ensure theyre consistent across the board?  not sure exactly what to look at
here since i dont have a debian machine on hand but im guessing the php
binary depends on some other binary being there, which there will be several
versions of, surely.

is there a standalone package for the imap extension in debian?

also, are the other linux boxes also running debian?

-nathan

--- End Message ---
--- Begin Message --- Everything matches. The only thing that's different is that the server that's having the problem has been running the script every 15 mins for the past 2 months - which leads me to believe there might be a memory leak somewhere...

Although complete recompiling should reset something, right?

I found this:
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=502996
But the patch didn't work. The library is required by php5-imap (which is a standalone package).

Thanks!
Dan

Nathan Nobbe wrote:
On Tue, Dec 23, 2008 at 12:34 PM, Dan Osipov <[email protected]>wrote:

Hello,

I have a CLI PHP script I'm running on a Debian Etch server every 15
minutes, that downloads messages from NNTP server using PHP imap functions.
The script is working fine on several Windows systems, and other Linux
servers, but has been continuously throwing a segfault error on this
particular machine.

I've recompiled PHP 5.2.8 from source, upgraded all packages, recompiled
libc-client2002edebian, etc. I'm at loss at what I can do to debug this
issue further. Can someone recommend what I should check?


have you checked the versions of the imap libraries on those systems to
ensure theyre consistent across the board?  not sure exactly what to look at
here since i dont have a debian machine on hand but im guessing the php
binary depends on some other binary being there, which there will be several
versions of, surely.

is there a standalone package for the imap extension in debian?

also, are the other linux boxes also running debian?

-nathan



--- End Message ---
--- Begin Message ---
Hey Everyone, been steaming right along for a couple days but now I'm stuck
on writing a search function, could you all take a look at it and see what
it could be, I will mark the line throwing the error in red, I did try just
commenting out that line and searching for a record by OrderID that I know
is there but it does not return anything , I am trying to search several
tables in one db:

Code:
<?php
session_start();
include("inc/dbconn_open.php");

if (empty($_SESSION['AdminLogin']) OR $_SESSION['AdminLogin'] <> 'OK' ){
    header ("Location: LogOut.php");
}

if (isset($_GET['AdminID']) && !empty($_GET['AdminID'])){
    $AdminID = $_GET['AdminID'];
} elseif (isset($_POST['AdminID']) && !empty($_POST['AdminID'])){
    $AdminID = $_POST['AdminID'];
} else {
    header ("Location: LogOut.php");
}

    $query = "SELECT SearchWorkOrder FROM admin WHERE AdminID='$AdminID'";
    $result = mysql_query ($query);
    $row = mysql_fetch_object ($result);
    if ($row->SearchWorkOrder == "NO") {
        header ("Location:
Welcome.php?AdminID='.$_SESSION[AdminLogin]'&msg=Sorry, you do not have
access to that page.");
    }

if (isset($_POST['WorkOrderID'])) {$WorkOrderID = $_POST['WorkOrderID'];}
else {$WorkOrderID = '';}
if (isset($_POST['WorkOrderName'])) {$WorkOrderName =
$_POST['WorkOrderName'];} else {$WorkOrderName = '';}
if (isset($_POST['CustomerName'])) {$CustomerName = $_POST['CustomerName'];}
else {$CustomerName = '';}
if (isset($_POST['CustomerEmail'])) {$CustomerEmail =
$_POST['CustomerEmail'];} else {$CustomerEmail = '';}
if (isset($_POST['SalesRep'])) {$SalesRep = $_POST['SalesRep'];} else
{$SalesRep = '';}
if (isset($_POST['SalesRepEmail'])) {$SalesRepEmail =
$_POST['SalesRepEmail'];} else {$SalesRepEmail = '';}

if (isset($_POST['SortBy'])) {$SortBy = $_POST['SortBy'];} else {$SortBy =
'WorkOrderID DESC';}
if (isset($_POST['Page'])) {$Page = $_POST['Page'];} else {$Page = 1;}

$PerPage = 30;
$StartPage = ($Page - 1) * $PerPage;
$OrderID = '';


    // All Orders
    $sql = "SELECT WorkOrderID FROM workorders WHERE WorkOrderID <>'' ";
    if (!empty($WorkOrderName)) {
        $sql .= "AND Advertiser LIKE '%". $WorkOrderName ."%' ";
    }
    if (!empty($WorkOrderID)) {
        $sql .= "AND WorkOrderID LIKE '%". $WorkOrderID ."%' ";
    }
    $result = mysql_query ($sql);
    while ($row = mysql_fetch_object ($result)) {
        $OrderID = $OrderID .", ". $row->WorkOrderID;
    }



    // Work Orders
    if (!empty($CustomerName) || !empty($CustomerEmail) || !empty($SalesRep)
|| !empty($SalesRepEmail)) {
        $sql = "SELECT WorkOrderID FROM workorderform WHERE WorkOrderID<>''
";
        if (!empty($CustomerName)) {
            $sql .= "AND Advertiser LIKE '%". $CustomerName ."%' ";
        }
        if (!empty($CustomerEmail)) {
            $sql .= "AND AdContactEmail LIKE '%". $CustomerEmail ."%' ";
        }
        if (!empty($SalesRep)) {
            $sql .= "AND Salesperson LIKE '%". $SalesRep ."%' ";
        }
        if (!empty($SalesRepEmail)) {
            $sql .= "AND SalespersonEmail LIKE '%". $SalesRepEmail ."%' ";
        }
        $result = mysql_query ($sql);
        while ($row = mysql_fetch_object ($result)) {
            $OrderID = $OrderID .", ". $row->WorkOrderID;
        }
    }

    // Homescape Builder Profile
    if (!empty($CustomerName) || !empty($CustomerEmail) || !empty($SalesRep)
|| !empty($SalesRepEmail)) {
        $sql = "SELECT WorkOrderID FROM hs_builder_profile WHERE
WorkOrderID<>'' ";
        if (!empty($CustomerName)) {
            $sql .= "AND OrganizationName LIKE '%". $CustomerName ."%' ";
        }
        if (!empty($CustomerEmail)) {
            $sql .= "AND LeadEmail LIKE '%". $CustomerEmail ."%' ";
        }
        if (!empty($SalesRep)) {
            $sql .= "AND Salesperson LIKE '%". $SalesRep ."%' ";
        }
        if (!empty($SalesRepEmail)) {
            $sql .= "AND SalespersonEmail LIKE '%". $SalesRepEmail ."%' ";
        }
        $result = mysql_query ($sql);
        while ($row = mysql_fetch_object ($result)) {
            $OrderID = $OrderID .", ". $row->WorkOrderID;
        }
    }

    // Homescape Builder Spec Home
    if (!empty($CustomerName) || !empty($SalesRep) ||
!empty($SalesRepEmail)) {
        $sql = "SELECT WorkOrderID FROM hs_spec_home WHERE WorkOrderID<>''
";
        if (!empty($CustomerName)) {
            $sql .= "AND CommunityName LIKE '%". $CustomerName ."%' ";
        }
        if (!empty($SalesRep)) {
            $sql .= "AND Salesperson LIKE '%". $SalesRep ."%' ";
        }
        if (!empty($SalesRepEmail)) {
            $sql .= "AND SalespersonEmail LIKE '%". $SalesRepEmail ."%' ";
        }
        $result = mysql_query ($sql);
        while ($row = mysql_fetch_object ($result)) {
            $OrderID = $OrderID .", ". $row->WorkOrderID;
        }
    }

    // Planet Discover Coupon
    if (!empty($CustomerName) || !empty($SalesRep) ||
!empty($SalesRepEmail)) {
        $sql = "SELECT WorkOrderID FROM pd_coupon WHERE WorkOrderID<>'' ";
        if (!empty($CustomerName)) {
            $sql .= "AND BusinessName LIKE '%". $CustomerName ."%' ";
        }
        if (!empty($SalesRep)) {
            $sql .= "AND Salesperson LIKE '%". $SalesRep ."%' ";
        }
        if (!empty($SalesRepEmail)) {
            $sql .= "AND SalespersonEmail LIKE '%". $SalesRepEmail ."%' ";
        }
        $result = mysql_query ($sql);
        while ($row = mysql_fetch_object ($result)) {
            $OrderID = $OrderID .", ". $row->WorkOrderID;
        }
    }

    // Planet Discover Enhanced Listing
    if (!empty($CustomerName) || !empty($CustomerEmail) || !empty($SalesRep)
|| !empty($SalesRepEmail)) {
        $sql = "SELECT WorkOrderID FROM pd_enhanced WHERE WorkOrderID<>'' ";
        if (!empty($CustomerName)) {
            $sql .= "AND BusinessName LIKE '%". $CustomerName ."%' ";
        }
        if (!empty($CustomerEmail)) {
            $sql .= "AND Email LIKE '%". $CustomerEmail ."%' ";
        }
        if (!empty($SalesRep)) {
            $sql .= "AND Salesperson LIKE '%". $SalesRep ."%' ";
        }
        if (!empty($SalesRepEmail)) {
            $sql .= "AND SalespersonEmail LIKE '%". $SalesRepEmail ."%' ";
        }
        $result = mysql_query ($sql);
        while ($row = mysql_fetch_object ($result)) {
            $OrderID = $OrderID .", ". $row->WorkOrderID;
        }
    }

    // Planet Discover Right Side Text Ad
    if (!empty($CustomerName) || !empty($SalesRep) ||
!empty($SalesRepEmail)) {
        $sql = "SELECT WorkOrderID FROM pd_textad WHERE WorkOrderID<>'' ";
        if (!empty($CustomerName)) {
            $sql .= "AND Customer LIKE '%". $CustomerName ."%' ";
        }
        if (!empty($SalesRep)) {
            $sql .= "AND Salesperson LIKE '%". $SalesRep ."%' ";
        }
        if (!empty($SalesRepEmail)) {
            $sql .= "AND SalespersonEmail LIKE '%". $SalesRepEmail ."%' ";
        }
        $result = mysql_query ($sql);
        while ($row = mysql_fetch_object ($result)) {
            $OrderID = $OrderID .", ". $row->WorkOrderID;
        }
    }

    if (substr($OrderID, -2) == ", ") {
        $OrderID = substr($OrderID, 0, -2);
    }

    if (substr($OrderID, 0, 2) == ", ") {
        $OrderID = substr($OrderID, 2);
    }


    $sql = "SELECT WorkOrderID FROM workorders WHERE WorkOrderID IN
($OrderID)";
    $result = mysql_query ($sql);
   * $Total = ceil(mysql_num_rows($result)/$PerPage);
 *
    $sql = "SELECT WorkOrderID, DATE_FORMAT(CreatedDate,'%m/%e/%y') AS
SubmitDate, Location, AdminID, FormName, Status FROM ";
    $sql .= "workorders WHERE WorkOrderID IN ($OrderID) ORDER BY $SortBy
LIMIT $StartPage, $PerPage";
    $result = mysql_query ($sql);


If ($Page > 0) {$PagePrev = ($Page - 1);} else {$PagePrev = '';}
If ($Page < $Total) {$PageNext = ($Page + 1);} else {$PageNext = '';}
?>

the error is this one: *Warning*: mysql_num_rows(): supplied argument is not
a valid MySQL result resource in *
C:\Inetpub\Xampp\htdocs\SNLeader\WOSystemN\ViewOrders.php* on line *182

Thanks in advance
*

--- End Message ---

Reply via email to