php-general Digest 5 May 2012 22:35:42 -0000 Issue 7802

Topics (messages 317793 through 317804):

Re: Calculating driving distance between UK postcodes
        317793 by: tamouse mailing lists

Re: function
        317794 by: tamouse mailing lists
        317797 by: Jim Giner
        317801 by: tamouse mailing lists
        317802 by: tamouse mailing lists

Re: PHP & Emacs
        317795 by: tamouse mailing lists

Re: Retrieve pages from an ASP driven site
        317796 by: tamouse mailing lists

Re: Running through an enormous SQL file
        317798 by: Brian Dunning
        317800 by: tamouse mailing lists

Re: get content rss feed
        317799 by: tamouse mailing lists

Re: code deployment through php
        317803 by: tamouse mailing lists

Re: PHP & Database Problems -- Code Snippets
        317804 by: Matijn Woudt

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
        php-gene...@lists.php.net


----------------------------------------------------------------------
--- Begin Message ---
On Fri, May 4, 2012 at 9:18 AM, Terry Ally (Gmail) <terrya...@gmail.com> wrote:
> Google works in Javascript extensively - not a language with which I
> have in-depth experience hence my reason for asking for PHP solution.
>
> For example the following will get me a JSON output with the distance in
> Kms and time. I don't know how to get PHP to read this information and
> extract just the distance. I need the distance so that I can calculate cost
> of a trip.
>
> <form id="google" action="
> http://maps.googleapis.com/maps/api/distancematrix/json"; method="get">
> <input type="text" name="origins" value="" />
> <input type="text" name="destinations" value="" />
> <input type="hidden" name="sensor" value="false">
> <input type="hidden" name="submitted" value="1">
> <br><a type="submit"
> onClick="document.getElementById('google').submit()"><strong><strong>Get
> Distance</strong></strong></a>
> </form>

Using Google Maps API is pretty straight-forward. You don't need to
set up a form or a use a POST to get the info. This page should
describes how to use a standard GET query to get the info you want:

< https://developers.google.com/maps/documentation/distancematrix/ >

Setting up the proper URL to call, you can activate it using
file_get_contents provided you have allow_url_fopen set to true in
php.ini. (Do make sure to check for possible errors returned.)

You can get the response back as either JSON or XML, both of which PHP
can parse into useful data structures:

< http://us.php.net/manual/en/function.json-decode.php >

< http://us.php.net/manual/en/book.simplexml.php >

--- End Message ---
--- Begin Message ---
On Thu, May 3, 2012 at 9:12 PM, Ron Piggott
<ron.pigg...@actsministries.org> wrote:
> I need to access a FUNCTION I programmed within a different FUNCTION.  Are 
> these able to be passed like a variable?  Or are they able to become like a 
> $_SESSION variable in nature?  How am I able to do this?
>
> I am essentially programming:
>
> ===
> function name( $flag1, $flag2 ) {
>
> # some PHP
>
> echo name_of_a_different_function( $flag1 , $flag2 );
>
> }
> ===
>
> The error I am receiving is “Call to undefined function 
> name_of_a_different_function”

Where is name_of_a_different_function defined? If it is somewhere in
the same file as name, that shouldn't be a problem, provided it is
defined in the same namespace/scope as name. If it is defined in a
different file, you need to include that file before you make the echo
statement.

For example:

function func1 ($flag1, $flag2) {

   # blah blah

   echo func2($flag1, $flag2);
}

function func2 ($flag1, $flag2) {

   #blah blah

   return "some string value";
}

in the same file should be just fine. It doesn't really matter what
order func1 and func2 are declared in.

However, if func2 is defined in some_other_file.php, you need to
include it in this_file.php (where func1 is defined) first:

this_file.php:
include('some_other_file.php');

function func1 ($flag1, $flag2) {

   #blah blah

   echo func2 ($flag1, $flag2);
}


some_other_file.php:
function func2 ($flag1, $flag2) {

   #blah blah

   return "some string value";
}

If func2 is a method for an object/class, you'll have to access it
that way in func1:

this_file.php:
include('MyClass.php');
function func1 ($flag1, $flag2) {

   # blah blah, instantiate object?
   $myobj = new MyClass();

   echo $myobj->func2 ($flag1, $flag2);
}

MyClass.php:
class MyClass
{
   function func2 ($flag1, $flag2) {

      #blah blah
      return "some string value";
   }
}

--- End Message ---
--- Begin Message ---
But the OP says "function is defined inside a different function".  Your 
theories to a solution don't fit that problem.
"tamouse mailing lists" <tamouse.li...@gmail.com> wrote in message 
news:cahuc_t-416_-lpcn3mo8qqxwrh4pnq5fmwouhwpdk+hmkgh...@mail.gmail.com...
On Thu, May 3, 2012 at 9:12 PM, Ron Piggott
<ron.pigg...@actsministries.org> wrote:

Where is name_of_a_different_function defined? If it is somewhere in
the same file as name, that shouldn't be a problem, provided it is
defined in the same namespace/scope as name. If it is defined in a
different file, you need to include that file before you make the echo
statement.

For example:

function func1 ($flag1, $flag2) {

   # blah blah

   echo func2($flag1, $flag2);
}

function func2 ($flag1, $flag2) {

   #blah blah

   return "some string value";
}

in the same file should be just fine. It doesn't really matter what
order func1 and func2 are declared in.

However, if func2 is defined in some_other_file.php, you need to
include it in this_file.php (where func1 is defined) first:

this_file.php:
include('some_other_file.php');

function func1 ($flag1, $flag2) {

   #blah blah

   echo func2 ($flag1, $flag2);
}


some_other_file.php:
function func2 ($flag1, $flag2) {

   #blah blah

   return "some string value";
}

If func2 is a method for an object/class, you'll have to access it
that way in func1:

this_file.php:
include('MyClass.php');
function func1 ($flag1, $flag2) {

   # blah blah, instantiate object?
   $myobj = new MyClass();

   echo $myobj->func2 ($flag1, $flag2);
}

MyClass.php:
class MyClass
{
   function func2 ($flag1, $flag2) {

      #blah blah
      return "some string value";
   }
}

But the OP says "function is defined inside a different function".  Your 
theories to a solution don't fit that problem.

(Sorry you all had to read thru so much stuff just to get to my one-line 
response.) 



--- End Message ---
--- Begin Message ---
On Fri, May 4, 2012 at 9:18 PM, Jim Giner <jim.gi...@albanyhandball.com> wrote:
> But the OP says "function is defined inside a different function".  Your
> theories to a solution don't fit that problem.
[snip]
> But the OP says "function is defined inside a different function".  Your
> theories to a solution don't fit that problem.
>
> (Sorry you all had to read thru so much stuff just to get to my one-line
> response.)

There's no need to include something if it turns out to be irrelevant.

--- End Message ---
--- Begin Message ---
On Thu, May 3, 2012 at 9:12 PM, Ron Piggott
<ron.pigg...@actsministries.org> wrote:
> I need to access a FUNCTION I programmed within a different FUNCTION.  Are 
> these able to be passed like a variable?  Or are they able to become like a 
> $_SESSION variable in nature?  How am I able to do this?
>
> I am essentially programming:
>
> ===
> function name( $flag1, $flag2 ) {
>
> # some PHP
>
> echo name_of_a_different_function( $flag1 , $flag2 );
>
> }
> ===
>
> The error I am receiving is “Call to undefined function 
> name_of_a_different_function”

Thanks to Jim, I understand a bit more, however, I still do not see
where name_of_a_different_function is being defined. Rather than
suppose something, please post the function where
name_of_a_different_function is defined.

--- End Message ---
--- Begin Message ---
On Fri, May 4, 2012 at 7:43 AM, Gerardo Benitez
<gerardobeni...@gmail.com> wrote:
> Hi Mihamina,
>
> I think that a few number of people use Emacs to write Php, in fact for
> proffesionals porpuse the people use a IDE for Php, like Netbeams, Eclipse
> PDT or Zend Studio.
>
> Regards,
> Gerardo
>
> On Wed, May 2, 2012 at 8:21 AM, Mihamina Rakotomandimby
> <miham...@rktmb.org>wrote:
>
>> Hi all,
>>
>> For curiosity, are there people here using Emacs to code in PHP?
>> What modes do you add? cedet, ecb,...
>>
>> I see (just for the example) that Drupal has a short documentation page
>> for Emacs http://drupal.org/node/59868
>>
>> Have you got some in your bookmarks for general PHP coding?
>>
>> --
>> RMA.
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>
>
> --
> Gerardo Benitez
> -------------------------
> Programador Web Freelance

I use Emacs for editing practically everything. I use a
[php-mode.el](http://php-mode.sourceforge.net/) that is derived from
cc-mode, and works pretty well (except for one annoyance in that it
doesn't recognize octothorpes (#) for comment beginners :P). [Multiple
Major Modes](http://emacswiki.org/emacs/MultipleModes) is also pretty
helpful so you can edit files that mix PHP, HTML, JS, and CSS (which
is NOT a best practice, but sometimes necessary).

The [Emacs Wiki](http://emacswiki.org) seems to be the best place for
finding things in general, but is still not really as good as just
doing a google/bing/ddg search on what you're looking for. *Lots* of
people write about emacs, and there are generous tidbits all over.

Another thing I use heavily are snippets. The best package I've found
for this is the (Yet Another Snippets
mode)[https://github.com/capitaomorte/yasnippet] which speeds up
development quite a bit.

I have a (very limited) info page on Emacs on my wiki:
http://wiki.tamaratemple.com/Technology/Emacs (this is not
advertising; my server is small and won't handle a huge number of
hits; please don't /. it!)

--- End Message ---
--- Begin Message ---
On Wed, May 2, 2012 at 11:37 PM, EPA WC <epawc...@gmail.com> wrote:
> Hi List,
>
> I am trying to write a crawler to go through web pages at
> http://www.freebookspot.es/CompactDefault.aspx?Keyword=. But I am not
> quite familiar with how asp uses _doPostBack function with the "next"
> button below the book list to advance to the next page. I hope someone
> who knows ASP well can help out here. I need to know how to retrieve
> next page with PHP code.
>
> Kind regards,
> Tom


Looking at that page source, I think this might be a bit problematic.

Notice that practically the whole page is inside a form. When you get
down to the "Next> " button, that is going to sumbmit the form with
it's appropriate fields set. If you look at the beginning of the form,
you'll see some interesting fields, one in particular, __VIEWSTATE is
pretty clearly an encoded value of some sort.

When your crawler parses the page, it will have to stash the field
values that the form sets in order to process the form correctly to
get the next page of entries by simulating a POST-data submit. This is
(probably?) most easily handled via libcurl.

Unsolicited advice: Many sites do not appreciate scraping activity;
make sure your crawler obeys robots.txt rules, and do not overtax the
site with crawler activity.

--- End Message ---
--- Begin Message ---
How would you launch that from PHP?

On May 4, 2012, at 6:11 PM, tamouse mailing lists wrote:

> Is there any need to use PHP with this at all? If it's already in SQL,
> can't you just feed it to mysql?


--- End Message ---
--- Begin Message ---
Please put replies at BOTTOM

On Fri, May 4, 2012 at 9:24 PM, Brian Dunning <br...@briandunning.com> wrote:
> How would you launch that from PHP?
>
> On May 4, 2012, at 6:11 PM, tamouse mailing lists wrote:
>
>> Is there any need to use PHP with this at all? If it's already in SQL,
>> can't you just feed it to mysql?


It's a standard command you would launch via [exec or
shell_exec](http://us.php.net/manual/en/book.exec.php)

--- End Message ---
--- Begin Message ---
On Wed, May 2, 2012 at 7:00 AM, Doeke Wartena <clankil...@gmail.com> wrote:
> I try to get the content from the following rss feed
> http://www.adafruit.com/blog/feed/
>
> I want to store it in a database in order to use it for a school assignment.
> If i look in my browser to the feed then i see content and description,
> however if i try to get them with php then description is this:
>
> [description] => SimpleXMLElement Object
>        (
>        )
>
>
> and content is gone.
>
>
> ----------
> $db = dbConnect();
>
> $xml =  getFileContents("http://www.adafruit.com/blog/feed/";);
> $xmlTree = new SimpleXMLElement($xml);
>
> for($i = count($xmlTree->channel->item)-1; $i >= 0; $i--) {
> $item = $xmlTree->channel->item[$i];
>  echo "<pre>";
> print_r($item);
> echo "</pre>";
> }
>
> dbClose($db);
>
> ?>
> ----------
>
> this is 1 part of the print_r:
>
> SimpleXMLElement Object
> (
>    [title] => Birth of the ARM: Acorn Archimedes Promo from 1987
>    [link] => 
> http://www.adafruit.com/blog/2012/04/28/birth-of-the-arm-acorn-archimedes-promo-from-1987/
>    [comments] =>
> http://www.adafruit.com/blog/2012/04/28/birth-of-the-arm-acorn-archimedes-promo-from-1987/#comments
>    [pubDate] => Sat, 28 Apr 2012 04:01:35 +0000
>    [category] => Array
>        (
>            [0] => SimpleXMLElement Object
>                (
>                )
>
>            [1] => SimpleXMLElement Object
>                (
>                )
>
>        )
>
>    [guid] => http://www.adafruit.com/blog/?p=30498
>    [description] => SimpleXMLElement Object
>        (
>        )
>
> )
>
> I guess content is gone cause it's like this:
>
> <content:encoded>
>
> And description is gone cause it's like this:
>
> <![CDATA[
>
> But how can i avoid this problem (i'm quite new)?
>
> bye


Hi, Doeke, welcome to PHP!

RSS feed processing can be it's own special form of hell, as feed
providers often include a whole set of extra namespaces. Luckily, this
doesn't necessarily cause that much of a concern because you can
include them as well.

First, notice the beginning of the sample RSS feed:

<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
        xmlns:content="http://purl.org/rss/1.0/modules/content/";
        xmlns:wfw="http://wellformedweb.org/CommentAPI/";
        xmlns:dc="http://purl.org/dc/elements/1.1/";
        xmlns:atom="http://www.w3.org/2005/Atom";
        xmlns:sy="http://purl.org/rss/1.0/modules/syndication/";
        xmlns:slash="http://purl.org/rss/1.0/modules/slash/";
        >

You will need to be able to tell your XML parser about all those extra
name spaces in order for it to return useful info. Look at the manual
for the 
[SimpleXMLElement::getDocNamespaces](http://us.php.net/manual/en/simplexmlelement.getdocnamespaces.php),
which will tell you what it's using.

You'll notice that one of the name spaces above is "content", and if
you look inthe RSS feed, you'll see a
<content:encoded>....</content:encoded> in each feed item. You need to
retrieve this by specifying the content namespace for the element
"encoded" in the item.

To do that, you'll need to register the namespace with the XPath using
[SimpleXMLElement::registerXPathNamespace](http://us.php.net/manual/en/simplexmlelement.registerxpathnamespace.php).
Once you do that, you'll be able to retrieve the content:encoded
element via the xpath method.

--- End Message ---
--- Begin Message ---
On Wed, May 2, 2012 at 5:23 AM, rene7705 <rene7...@gmail.com> wrote:
> On Wed, May 2, 2012 at 11:47 AM, rene7705 <rene7...@gmail.com> wrote:
>
>> I can't use anything like git on my shared hoster. But I suppose I could
>> use something like git at home, and use a sync script like I posted in my
>> OP on the shared hoster.
>>
>>
>>
> Maybe you git gurus can help me along a bit further.
>
> I've managed to install msysgit and get it to work on my windows dev box,
> so far so good.
>
> Now, I'm wondering how to set up my repositories. The last cvs I used was
> Microsoft's visual source control back in the 90's, so I'm very rusty. At
> the same time, I'd prefer not to experiment too much..
>
> I've got a tree structure in a folder called simply "code", that I have in
> several locations on my windows box.
>
> Each site that I develop for has a folder in .../htdocs/sites/somedomain.com,
> and many of these sites will need a copy of the common "code" folder in
> them. I can restrict myself to developing in one domain's subdir only.
> The non-common code for each domain is designed to run from any
> $_SERVER['SERVER_NAME'] and any sub-directory it happens to be in. In other
> words, http://my-dev-box.biz/sites/somedomain.com/ will show the same thing
> from windowze as http://somedomain.com will from shared hosted linux.
>
> I would also like to version control the non-common code for each domain.
>
> And I would like to store the entire repository on my windows box at home
> in 2 or 3 specific locations (on seperate disks encrypted with truecrypt.org,
> and also a truecrypted usb disk, if and when that's plugged in).
>
> For distributing the common code to the shared hosted live server (my
> workflow is to check finalized changes on my win box against all my sites
> that used the common code base, before deploying to the shared hoster live
> server), I can simply FTP one finalized copy and use the simplest of rm -rf
> and cp -r commands in a short script to distribute the changes. I could
> even do without the PHP filesync code I posted earlier (altho it was fun to
> build! :)
>
> That darn hoster of mine won't support git on shared hosting, only on much
> more expensive virtual dedicated and dedicated plans :(
> But I've also found
> http://serverfault.com/questions/26836/setting-up-a-git-repo-on-my-godaddy-hosting-plan
>  and
> http://www.lyraphase.com/wp/uncategorized/how-to-build-git-for-a-host-with-no-compiler/
> that
> show me how I might get git running on my (kinda lame now) shared hosting
> account.
>
> Maybe a stupid question, but would perhaps copying the common code around
> with a simple script be faster than multiple pushes by git?


Using git, you can set up either publicly hosted repositories on
github.com or gitorious.org or perhaps other public repo places. If
you don't want you code to be publicly available, you can set up
private repositories as well.

Not being familiar with Windows implementations much at all, I can't
tell you specifically what to do with msysgit, so these will be more
generic instructions.

I'm going to assume you don't have a host somewhere with ssh access.
In this case you'll most likely want/need to set up your repository on
your local system. (Note that it isn't *strictly* necessary to have a
repository -- you can clone a new tree from the existing code tree,
however having a repository can ensure a clean code set in case your
working tree gets out of sync somehow.)

(These instructions are modified from
http://tumblr.intranation.com/post/766290565/how-set-up-your-own-private-git-server-linux
)

First, create a directory you want to hold all of your local
repositories (such as C:\User\rene\MyRepositories). Then create a
subdirectory off that to hold your server/application common code
(C:\Users\rene\MyRepositories\commoncode).

Make that directory (..\commoncode) a *bare* repository. (Not sure how
that's done with msysgit, but the basic git command is: "git init
--bare C:\Users\rene\MyRepositories\commoncode")

Then you add the repository as a remote to the working tree: git
remote add origin C:\Users\rene\MyRepositories\commoncode

Now you can push commits to your repository with the following sequence:

git add <files you want to commit>
git commit
git push origin master

Now, to *deploy*, you can do the following:

Somewhere outside your working tree, create a directory called "deploy":

mkdir C:\Users\rene\deploy

Then clone your the repository of your commond code:

git clone C:\Users\rene\MyRepositories\commoncode cleancode-20120404

Then you can ftp the contents of cleancode-20120404 to your server as needed.

Sorry to be unable to tell you the exact steps with msysgit, but I
hope you can interpolate from the commands above.

--- End Message ---
--- Begin Message ---
On Thu, May 3, 2012 at 4:20 PM, Ethan Rosenberg <eth...@earthlink.net> wrote:
> At 06:47 PM 5/2/2012, Matijn Woudt wrote:
>>
>> On Wed, May 2, 2012 at 11:43 PM, Ethan Rosenberg <eth...@earthlink.net>
>> wrote: > Dear list - > > Sorry for the attachment. Â Here are code snippets
>> --- Ethan, I don't want to sound rude, but it appears to me you don't have
>> any understanding of what you're doing. It might help if you understand what
>> the code is doing... Let me explain. > > GET THE DATA FROM INTAKE3: > > Â  Â
>> function handle_data() > Â  Â { > Â  Â  Â  global $cxn; > Â  Â  Â  $query =
>> "select * from Intake3 where  1"; > > > >   Â  Â
>>  if(isset($_Request['Sex'])&& trim($_POST['Sex']) != '' ) $_Request does not
>> exists, you're looking for $_REQUEST. And why are you mixing $_REQUEST and
>> $_POST here? > Â  Â  Â  { > Â  Â  Â  Â  Â  Â if ($_REQUEST['Sex'] === "0") >
>> Â  Â  Â  Â  Â  Â { > Â  Â  Â  Â  Â  Â  Â  $sex = 'Male'; > Â  Â  Â  Â  Â  Â
>> } > Â  Â  Â  Â  Â  Â else > Â  Â  Â  Â  Â  Â { > Â  Â  Â  Â  Â  Â  Â  $sex =
>> 'Female'; > Â  Â  Â  Â  Â  Â } > Â  Â  Â  } > > Â  Â } What is the point of
>> the handle_data function above? It doesn't do anything. > Â  Â
>> $allowed_fields = array > Â  Â  Â  ( Â 'Site' =>$_POST['Site'], 'MedRec' =>
>> $_POST['MedRec'], 'Fname' => > $_POST['Fname'], 'Lname' => $_POST['Lname'] ,
>> > Â  Â  Â  Â  Â  Â  'Phone' => $_POST['Phone'] , 'Sex' => $_POST['Sex'] Â ,
>> 'Height' > => $_POST['Height'] Â ); > > Â  Â if(empty($allowed_fields)) > Â
>>  Â { > Â  Â  Â  Â  Â echo "ouch"; > Â  Â } > > Â  Â $query = "select * from
>> Intake3  where  1 "; > >   Â foreach ( $allowed_fields as $key => $val )
>> > Â  Â { > Â  Â  Â  if ( (($val != '')) ) > > Â  Â { > Â  Â  Â  $query .= "
>> AND ($key  = '$val') "; >   Â } >   Â  Â  $result1 = mysqli_query($cxn,
>> $query); > Â  Â } First, this will allow SQL injections, because you insert
>> the values directly from the browser. Second, you should move the last line
>> ($result1=...), outside of the foreach loop, now you're executing the query
>> multiple times. Third, you should check if $result1 === FALSE, in case the
>> query fails > > Â  Â $num = mysqli_num_rows($result1); > Â  Â if(($num =
>> mysqli_num_rows($result1)) == 0) Doing the same thing twice? > Â  Â { > ?> >
>> Â  Â <br /><br /><center><b><p style="color: red; font-size:14pt;" >No
>> Records > Retrieved #1</center></b></style></p> > <?php > Â  Â exit(); > Â
>>  Â } > > DISPLAY THE INPUT3 DATA: > >>>> THIS SEEMS TO BE THE ROUTINE THAT
>> IS FAILING <<< > > Â  Â <center><b>Search Results</b></center><br /> > > Â
>>  Â <center><table border="4" cellpadding="5" cellspacing="55" Â rules="all"
>> > Â frame="box"> > Â  Â <tr class=\"heading\"> > Â  Â <th>Site</th> > Â  Â
>> <th>Medical Record</th> > Â  Â <th>First Name</th> > Â  Â <th>Last Name</th>
>> > Â  Â <th>Phone</td> > Â  Â <th>Height</td> > Â  Â <th>Sex</td> > Â  Â
>> <th>History</td> > Â  Â </tr> > > <?php > > Â  Â  Â  while ($row1 =
>> mysqli_fetch_array($result1, MYSQLI_BOTH)) > Â  Â  Â  { > Â  Â  Â  Â  Â  Â
>> print_r($_POST); Doesn't really make sense to print $_POST here.. > Â  Â  Â
>>  Â  Â  Â  Â  global $MDRcheck; > Â  Â  Â  Â  Â  Â  Â  $n1++; > Â  Â  Â  Â  Â
>>  Â  Â  echo "<br />n1 <br />";echo $n1; > Â  Â  Â  Â  Â  Â { > Â  Â  Â  Â  Â
>>  Â  Â  if (($n1 > 2) && ($MDRcheck == $row1[1])) > Â  Â  Â  Â  Â  Â  Â  { >
>> Â  Â  Â  Â  Â  Â  Â  Â  Â  Â echo ">2== Â "; > Â  Â  Â  Â  Â  Â  Â  Â  Â  Â
>> echo $MDRcheck; > Â  Â  Â  Â  Â  Â  Â  Â  Â  Â echo "<td> $row1[0] </td>\n";
>> > Â  Â  Â  Â  Â  Â  Â  Â  Â  Â echo "<td> $row1[1] </td>\n"; > Â  Â  Â  Â  Â
>>  Â  Â  Â  Â  Â echo "<td> $row1[2] </td>\n"; > Â  Â  Â  Â  Â  Â  Â  Â  Â  Â
>> echo "<td> $row1[3] </td>\n"; > Â  Â  Â  Â  Â  Â  Â  Â  Â  Â echo "<td>
>> $row1[4] </td>\n"; > Â  Â  Â  Â  Â  Â  Â  Â  Â  Â echo "<td> $row1[5]
>> </td>\n"; > Â  Â  Â  Â  Â  Â  Â  Â  Â  Â echo "<td> $row1[6] </td>\n"; > Â
>>  Â  Â  Â  Â  Â  Â  Â  Â  Â echo "<td> $row1[7] </td>\n"; > Â  Â  Â  Â  Â  Â
>>  Â  Â  Â  Â echo "</tr>\n"; > Â  Â  Â  Â  Â  Â  Â  } > Â  Â  Â  Â  Â  Â  Â
>>  elseif (($n1 > 2) && ($MDRcheck != $row1[1])) > Â  Â  Â  Â  Â  Â  Â  { > Â
>>  Â  Â  Â  Â  Â  Â  Â  Â  Â echo ">2!= Â "; > > Â  Â  Â  Â  Â  Â  Â  Â  Â  Â
>> echo $MDRcheck; > > > Â  Â  Â  Â  Â  Â  Â  Â  Â  Â continue; continue
>> doesn't do anything here. > Â  Â  Â  Â  Â  Â  Â  } > Â  Â  Â  Â  Â  Â  Â
>>  elseif ($n1 == 2) > Â  Â  Â  Â  Â  Â  Â  { > > Â  Â  Â  Â  Â  Â  Â  Â  Â  Â
>> define( "MDR" , Â $row1[1]); > Â  Â  Â  Â  Â  Â  Â  Â  Â  Â echo "<br />row1
>> <br>";echo $row1[1]; > Â  Â  Â  Â  Â  Â  Â  Â  Â  Â echo "<tr>\n"; > > Â  Â
>>  Â  Â  Â  Â  Â  Â  Â  Â $_GLOBALS['mdr']= $row1[1]; > Â  Â  Â  Â  Â  Â  Â  Â
>>  Â  Â $_POST['MedRec'] = $row1[1]; You're not supposed to set variables in
>> $_POST... > Â  Â  Â  Â  Â  Â  Â  Â  Â  Â $MDRold = $_GLOBALS['mdr']; It
>> appears you want the old value of mdr, if so, then you should do this before
>> you set it again 2 lines above.. > Â  Â  Â  Â  Â  Â  Â  Â  Â  Â echo "<td>
>> $row1[0] </td>\n"; > Â  Â  Â  Â  Â  Â  Â  Â  Â  Â echo "<td> $row1[1]
>> </td>\n"; > Â  Â  Â  Â  Â  Â  Â  Â  Â  Â echo "<td> $row1[2] </td>\n"; > Â
>>  Â  Â  Â  Â  Â  Â  Â  Â  Â echo "<td> $row1[3] </td>\n"; > Â  Â  Â  Â  Â  Â
>>  Â  Â  Â  Â echo "<td> $row1[4] </td>\n"; > Â  Â  Â  Â  Â  Â  Â  Â  Â  Â
>> echo "<td> $row1[5] </td>\n"; > Â  Â  Â  Â  Â  Â  Â  Â  Â  Â echo "<td>
>> $row1[6] </td>\n"; > Â  Â  Â  Â  Â  Â  Â  Â  Â  Â echo "<td> $row1[7]
>> </td>\n"; > Â  Â  Â  Â  Â  Â  Â  Â  Â  Â echo "</tr>\n"; > Â  Â  Â  Â  Â  Â
>>  Â  } > > Â  Â  Â  Â  Â  Â } > Â  Â  Â  } > > ?> You say this routine is
>> probably the one that is failing.. but what is going wrong? And how the heck
>> are we supposed to know what this function should do? > > SELECT AND DISPLAY
>> DATA FROM VISIT3 DATABASE > > <?php > Â  Â $query2 = "select * from Visit3
>> where  1 AND (Site = 'AA')  AND (MedRec = > $_GLOBALS[mdr])"; You're using
>> mdr as a constant here, this will generate a warning, but sadly enough it
>> works. > Â  Â $result2 = mysqli_query($cxn, $query2); You should check if
>> $result2 === FALSE, in case the query fails. > Â  Â $num =
>> mysqli_num_rows($result2); You're counting the rows here, but you don't do
>> anything with the result? > << Snip the rest of this crappy code >> > > I
>> hope this helps. > > Ethan > > I think I made my point. I guess if I
>> continued on the rest of the code there will be tons of other bugs. Try to
>> understand what you're doing. Break things down in smaller pieces, check if
>> they work, then write another piece. If something breaks, you know where it
>> was because you just added that part. - Matijn
>
>
>
> Martijn -
>
> Thank you for your insights into my poorly written code.  I am very much of
> a newbie, and therefore am asking for help.
>
> Would you please look at the routine that is failing.  I stripped out all
> the echo and print_r statements, but I had a large number of them in the
> code.  Everything that I can think of has been tried  to no avail. Any help
> that you can render would be deeply appreciated.
>
> Thanks again,
>
> Ethan
>

Ethan,

You're code got messed up I guess. Though, it seems there's still way
too much code to review here. You should try to bring your problem
down to 10-20 lines of code, then we can probably easily spot the
error in the code.

- Matijn

--- End Message ---

Reply via email to