php-general Digest 1 Feb 2008 20:25:49 -0000 Issue 5269
Topics (messages 268519 through 268542):
Re: mysqli_embedded_server_start
268519 by: Robert Cummings
268520 by: Per Jessen
268530 by: Kyohere Luke
Re: PEAR website and MSIE 6
268521 by: Zoltán Németh
268522 by: Robert Cummings
268528 by: Richard Heyes
268537 by: Greg Donald
Re: how dod you get to do multiple mysql queries concurrently?
268523 by: Zoltán Németh
268524 by: Paul Scott
268525 by: Zoltán Németh
Re: how do you get to do multiple mysql queries concurrently?
268526 by: Per Jessen
Re: [Slightly OT] Apple MacBook MAMP and Logic
268527 by: Colin Guthrie
268529 by: Paul Scott
Re: array iteration vs. ArrayIterator
268531 by: Jochem Maas
268536 by: Greg Donald
268538 by: Paul Scott
Search function not working...
268532 by: Jason Pruim
268539 by: David Giragosian
268540 by: Jason Pruim
268541 by: David Giragosian
268542 by: David Giragosian
Pass Variable Names to a Function
268533 by: Bill Guion
268534 by: Greg Donald
268535 by: Richard Heyes
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 Fri, 2008-02-01 at 09:13 +0100, Per Jessen wrote:
> Kyohere Luke wrote:
>
> > Has anyone tried to use this function? Does php actually support mysql
> > embedded server or is this just a stub for future use? I'm trying to
> > convert a mysql-based web app to a desktop app and rather than
> > refactor everything to use sqlite, It would be interesting if I could
> > use mysql embedded server.
>
> Alternatively, you could just run mysql locally on your desktop.
Not so convenient for distribution :/
Cheers,
Rob.
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'
--- End Message ---
--- Begin Message ---
Robert Cummings wrote:
>
> On Fri, 2008-02-01 at 09:13 +0100, Per Jessen wrote:
>> Kyohere Luke wrote:
>>
>> > Has anyone tried to use this function? Does php actually support
>> > mysql embedded server or is this just a stub for future use? I'm
>> > trying to convert a mysql-based web app to a desktop app and rather
>> > than refactor everything to use sqlite, It would be interesting if
>> > I could use mysql embedded server.
>>
>> Alternatively, you could just run mysql locally on your desktop.
>
> Not so convenient for distribution :/
Very true - but maybe Luke is already distributing PHP, a webserver etc?
/Per Jessen, Zürich
--- End Message ---
--- Begin Message ---
Providing an embedded web-server and php package, so embedded mysql would be
nice too.
There is absolutely no documentation regarding this function - isn't anyone
curious? :-)
On Feb 1, 2008 11:48 AM, Per Jessen <[EMAIL PROTECTED]> wrote:
> Robert Cummings wrote:
>
> >
> > On Fri, 2008-02-01 at 09:13 +0100, Per Jessen wrote:
> >> Kyohere Luke wrote:
> >>
> >> > Has anyone tried to use this function? Does php actually support
> >> > mysql embedded server or is this just a stub for future use? I'm
> >> > trying to convert a mysql-based web app to a desktop app and rather
> >> > than refactor everything to use sqlite, It would be interesting if
> >> > I could use mysql embedded server.
> >>
> >> Alternatively, you could just run mysql locally on your desktop.
> >
> > Not so convenient for distribution :/
>
> Very true - but maybe Luke is already distributing PHP, a webserver etc?
>
>
> /Per Jessen, Zürich
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
-- Luke Kyohere
-- /dev/null
--- End Message ---
--- Begin Message ---
2008. 01. 31, csütörtök keltezéssel 12.47-kor Robert Cummings ezt írta:
> On Thu, 2008-01-31 at 18:18 +0100, Jochem Maas wrote:
> > Eric Butera schreef:
> > > On Jan 31, 2008 12:02 PM, Jochem Maas <[EMAIL PROTECTED]> wrote:
> > >> Robert Cummings schreef:
> > >>> On Thu, 2008-01-31 at 17:14 +0100, Jochem Maas wrote:
> > >>>> let's not forget that nobody outside of IT actually uses Opera
> > >>> Please back up that st-ass-tistic please. Methinks you reached around
> > >>> and pulled it out of your lightless nether regions.
> > >> given that you can prove anything with statistics, I'd say that's where
> > >> all stats come from - well not all from my ass but always someone's ;-)
> > >>
> > >> let me guess you use Opera ... and you work in IT right? :-P
> > >>
> > >>> Cheers,
> > >>> Rob.
> > >>
> > >
> > > My wife uses Opera and she doesn't know much about computers. I
> > > installed IE7, FF, Opera, & Safari for Windows and she picked Opera on
> > > her own. I can't really get into it though.
> >
> > I guess the shitty interface is appealing to people with more taste than us
> > :-)
> > Steve Job's would be annoyed though - which is funny in and of itself :-P
>
> I dunno, Opera comes with a built in flag for disabling that wretching
> thing called tabbed browsing. Firefox requires you to install a plugin.
ahh the Great Browser Holy War :)
I must join in...
I never wanted to turn tabbed browsing off (in fact I find it useful and
convenient), so it is not a real concern
> Also, I find the configurability of Opera's interface to be superior to
> what I last used for Firefox.
okay, then how do you stop Opera caching? I tried to turn it off
everywhere but it keeps on creating local files while I browse.
(ubuntu linux/opera 9.25)
aside from that, opera is quite good but for development I find FF much
more convenient. IE just plain sucks, but I have to test my stuff with
it also so I have it installed, but I would never think about using it
for anything else...
greets
Zoltán Németh
>
> Cheers,
> Rob.
> --
> .------------------------------------------------------------.
> | InterJinn Application Framework - http://www.interjinn.com |
> :------------------------------------------------------------:
> | An application and templating framework for PHP. Boasting |
> | a powerful, scalable system for accessing system services |
> | such as forms, properties, sessions, and caches. InterJinn |
> | also provides an extremely flexible architecture for |
> | creating re-usable components quickly and easily. |
> `------------------------------------------------------------'
>
--- End Message ---
--- Begin Message ---
On Fri, 2008-02-01 at 10:11 +0100, Zoltán Németh wrote:
> 2008. 01. 31, csütörtök keltezéssel 12.47-kor Robert Cummings ezt írta:
> > On Thu, 2008-01-31 at 18:18 +0100, Jochem Maas wrote:
> > > Eric Butera schreef:
> > > > On Jan 31, 2008 12:02 PM, Jochem Maas <[EMAIL PROTECTED]> wrote:
> > > >> Robert Cummings schreef:
> > > >>> On Thu, 2008-01-31 at 17:14 +0100, Jochem Maas wrote:
> > > >>>> let's not forget that nobody outside of IT actually uses Opera
> > > >>> Please back up that st-ass-tistic please. Methinks you reached around
> > > >>> and pulled it out of your lightless nether regions.
> > > >> given that you can prove anything with statistics, I'd say that's where
> > > >> all stats come from - well not all from my ass but always someone's ;-)
> > > >>
> > > >> let me guess you use Opera ... and you work in IT right? :-P
> > > >>
> > > >>> Cheers,
> > > >>> Rob.
> > > >>
> > > >
> > > > My wife uses Opera and she doesn't know much about computers. I
> > > > installed IE7, FF, Opera, & Safari for Windows and she picked Opera on
> > > > her own. I can't really get into it though.
> > >
> > > I guess the shitty interface is appealing to people with more taste than
> > > us :-)
> > > Steve Job's would be annoyed though - which is funny in and of itself :-P
> >
> > I dunno, Opera comes with a built in flag for disabling that wretching
> > thing called tabbed browsing. Firefox requires you to install a plugin.
>
> ahh the Great Browser Holy War :)
> I must join in...
>
> I never wanted to turn tabbed browsing off (in fact I find it useful and
> convenient), so it is not a real concern
>
> > Also, I find the configurability of Opera's interface to be superior to
> > what I last used for Firefox.
>
> okay, then how do you stop Opera caching? I tried to turn it off
> everywhere but it keeps on creating local files while I browse.
> (ubuntu linux/opera 9.25)
I never noticed that before... with a little ingenuity though I found the
following to be successful:
cd ~/.opera
sudo chown root:root cache4
sudo chmod 000 cache4
;)
Cheers,
Rob.
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'
--- End Message ---
--- Begin Message ---
Daevid Vincent wrote:
I will be very sad in 15 days when M$ FORCES everyone
to it.
WT?
--
Richard Heyes
http://www.websupportsolutions.co.uk
Knowledge Base and Helpdesk software for £299pa hosted for you -
no installation, no maintenance, new features automatic and free
--- End Message ---
--- Begin Message ---
On Jan 31, 2008 7:04 AM, Eric Butera <[EMAIL PROTECTED]> wrote:
> IE8 passes Acid2. :)
They make a salve for that I heard.
--
Greg Donald
http://destiney.com/
--- End Message ---
--- Begin Message ---
2008. 02. 1, péntek keltezéssel 03.40-kor Jochem Maas ezt írta:
> Per Jessen schreef:
> > Richard Lynch wrote:
> >
> >>> OK, what is a 'geometry column' and what is a 'spatial index' ?
> >> Imagine a single column combining both longitude and latitude.
> >>
> >> Now imagine an index that "knows" about long/lat, and keeps
> >> geographically "close" objects sorted in the index for you.
> >>
> >> Including "knowing" about the 180 <-> -180 degree wrap-around.
> >> (Or 360 === 0 wrap-around in the other geo-system.)
> >>
> >> So when you ask for "theme parks near Zurich" your DB can answer in
> >> milliseconds instead of minutes.
> >
> > Thanks Richard - I thought Nathan was talking about an abstract concept,
> > not something "real".
> >
> > So, back the Nathans suggestion:
> >
> >> Back on the mysql side of things, try using geometry columns rather
> >> than numerical primary keys, with spatial indexes.. it's a MASSIVE
> >> performance upgrade (I've cut 5 second queries down to 0.005 by
> >> using geo columns)
> >
> > Is this worth a try? Have others tried this?
>
> I for one would really like to see a concrete example of this kind of
> use of geometry columns and spacial indexes as an alternative to the stand
> integer based primary keys.
me too
greets
Zoltán Németh
>
> >
> >
> > /Per Jessen, Zürich
> >
>
--- End Message ---
--- Begin Message ---
Did anyone actually get this mail?
More concrete example? What would you like to see?
I suspect that some of my mail is getting dropped :(
--Paul
On Fri, 2008-02-01 at 06:33 +0200, Paul Scott wrote:
> On Fri, 2008-02-01 at 03:40 +0100, Jochem Maas wrote:
>
> > I for one would really like to see a concrete example of this kind of
> > use of geometry columns and spacial indexes as an alternative to the stand
> > integer based primary keys.
>
>
> On one of my local postGIS tables:
>
> CREATE INDEX k1
> ON kanagawa
> USING gist
> (the_geom);
>
>
> A gist index is a GEOS based spatial index. You will need GEOS to create
> one.
>
> When loading spatial data, your geometry column looks like so:
>
> 01050000000100000001020000000C00000011ECE564CF7561404A8999CCDABC4140E5C0981ACE75614012901CD641BD4140603C8386BE756140E525611B40BD41405BF216D3BD756140151DC9E53FBD414054DC1A4DBD756140760B997A3FBD414012219BD1BC756140D20823E33EBD41407AB2884EBC7561400F2110243EBD41404571B4D0BB756140CC0C6A213DBD4140F707192ABB7561405DF2A1803CBD4140F0F11CA4BA756140C3D1B7413CBD4140E89CB2ADB97561406F046D233CBD414017D4B7CCA97561406D47AD7F39BD4140
>
> Which is WKB (Well Known Binary) data or WKT (Well Known Text) data. The
> gist index simply indexes this as opposed to the regular gid (which you
> still use btree indexes on anyways)
>
> --Paul
>
> All Email originating from UWC is covered by disclaimer
> http://www.uwc.ac.za/portal/public/portal_services/disclaimer.htm
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
--
------------------------------------------------------------.
| Chisimba PHP5 Framework - http://avoir.uwc.ac.za |
:------------------------------------------------------------:
All Email originating from UWC is covered by disclaimer
http://www.uwc.ac.za/portal/public/portal_services/disclaimer.htm
--- End Message ---
--- Begin Message ---
2008. 02. 1, péntek keltezéssel 11.55-kor Paul Scott ezt írta:
> Did anyone actually get this mail?
>
> More concrete example? What would you like to see?
>
> I suspect that some of my mail is getting dropped :(
sure I got it but answered before I reached it in reading. sorry for the
noise.
as for the GEOS stuff I think I'll do some research on it, it sounds
very interesting
greets
Zoltán Németh
>
> --Paul
>
> On Fri, 2008-02-01 at 06:33 +0200, Paul Scott wrote:
> > On Fri, 2008-02-01 at 03:40 +0100, Jochem Maas wrote:
> >
> > > I for one would really like to see a concrete example of this kind of
> > > use of geometry columns and spacial indexes as an alternative to the stand
> > > integer based primary keys.
> >
> >
> > On one of my local postGIS tables:
> >
> > CREATE INDEX k1
> > ON kanagawa
> > USING gist
> > (the_geom);
> >
> >
> > A gist index is a GEOS based spatial index. You will need GEOS to create
> > one.
> >
> > When loading spatial data, your geometry column looks like so:
> >
> > 01050000000100000001020000000C00000011ECE564CF7561404A8999CCDABC4140E5C0981ACE75614012901CD641BD4140603C8386BE756140E525611B40BD41405BF216D3BD756140151DC9E53FBD414054DC1A4DBD756140760B997A3FBD414012219BD1BC756140D20823E33EBD41407AB2884EBC7561400F2110243EBD41404571B4D0BB756140CC0C6A213DBD4140F707192ABB7561405DF2A1803CBD4140F0F11CA4BA756140C3D1B7413CBD4140E89CB2ADB97561406F046D233CBD414017D4B7CCA97561406D47AD7F39BD4140
> >
> > Which is WKB (Well Known Binary) data or WKT (Well Known Text) data. The
> > gist index simply indexes this as opposed to the regular gid (which you
> > still use btree indexes on anyways)
> >
> > --Paul
> >
> > All Email originating from UWC is covered by disclaimer
> > http://www.uwc.ac.za/portal/public/portal_services/disclaimer.htm
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> All Email originating from UWC is covered by disclaimer
> http://www.uwc.ac.za/portal/public/portal_services/disclaimer.htm
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
Richard Lynch wrote:
>> I think you are mis-remembering, yes. When your fork() call returns,
>> you have two separate processes, your child process being an exact
>> copy of your parent process. (mostly, see "copy-on-write"). The only
>> thing they share at this point are open file descriptors which have
>> also been copied, so they obviously point the the same file(s).
>
> So they could easily corrupt the file by making assumptions about it.
Actually only if they make incorrect assumptions :-)
> More importantly, if you build and initialize some data structures
> before you fork, and if they each assume they have exclusive access to
> said data structures, your program ends up not being "thread-safe"
I'm sorry, you're wrong. You don't seem to quite understand what fork()
does. After the fork(), both processes will each have a copy of those
data structures, and they can both do whatever they like to them
without interfering with each other.
Anyway, enough of this. I'm done.
/Per Jessen, Zürich
--- End Message ---
--- Begin Message ---
Brady Mitchell wrote:
>>> I don't use a mac myself but a colleague does. He seems to have apache
>>> and PHP installed on the machine but he generally uses the Xampp
>>> package. I don't know if this is the official home page or but but start
>>> here: http://www.apachefriends.org/en/xampp-macosx.html
>
>> Thanks Colin,
>> That's what I use on PC so it will probably do me fine on Mac too.
>
> I've been using XAMPP on Windows for a few years, so when I bought a
> MBP in December I was happy to find that they have a version for OS X
> as well.
>
> The one thing I didn't like about it is that on OS X you have to type
> in your password every time you want to start or stop anything. So I
> wrote some simple applescripts that I use instead of the included
> control panel that handle the authentication for me. If anyone is
> interested, just contact me off-list and I'll gladly share these
> simple scripts.
That's just how sudo works tho' right? You can configure sudo to not
require a password for certain commands run by certain users. Not sure
how it works on the mac as there may be some kind of wrapper but I'm
sure there would be a way to allow your user to not enter a password for
loading xampp.... It's a mac. It's like *nix. It's tweakable ;)
Col
--- End Message ---
--- Begin Message ---
On Fri, 2008-02-01 at 10:58 +0000, Colin Guthrie wrote:
> That's just how sudo works tho' right? You can configure sudo to not
> require a password for certain commands run by certain users. Not sure
> how it works on the mac as there may be some kind of wrapper but I'm
> sure there would be a way to allow your user to not enter a password for
> loading xampp.... It's a mac. It's like *nix. It's tweakable ;)
>
For sure! Although not recommended, I change that behaviour as soon as I
finish installing my system (generally Ubuntu). I really *hate* typing
my password on my own system!
What I do is create a root login by using sudo passwd root
which asks for my password (one last time) then I get to have a root
pass.
--Paul
All Email originating from UWC is covered by disclaimer
http://www.uwc.ac.za/portal/public/portal_services/disclaimer.htm
--- End Message ---
--- Begin Message ---
Nathan Nobbe schreef:
all,
as ive been researching SPL lately ive read several times that spl will
store only the current element of the underlying collection in memory
during iteration. articles that mention this will say that using these
iterators should afford savings when traversing large collections. well
having found nothing empirical i decided to run some tests myself.
and for the hell of it, i also decided to throw the array-by-reference
construct in there (thats the name im giving to the syntax which lets
you alter the array youre iterating over from within the array). mainly
because ive heard people say it will save memory. however, based
upon some things ive read, ive been skeptical of that info.
so here is a quick little report i whipped up, which has the script i used
for the test, and the results in a graphical format so you can get a quick
feel for them.
http://nathan.moxune.com/arrayVsArrayIteratorReport.php
at this point i must retract some of the statements i made during the
conversation about ruby yesterday. it turns out, spl iteration is not
twice as fast as standard array iteration, in fact it quite a bit slower!
that makes sense - your creating objects and wrapping the original data in order
to iterate over it - that can only mean overhead in terms of memory and
performance.
I stick with arrays and foreach (I agree with the carpal tunnel syndrome
statement)
also, it takes up more memory, and lastly, whoever said that using the
array-by-reference syntax saves memory is dead wrong ;)
-nathan
--- End Message ---
--- Begin Message ---
On Jan 31, 2008 10:09 PM, Nathan Nobbe <[EMAIL PROTECTED]> wrote:
> http://nathan.moxune.com/arrayVsArrayIteratorReport.php
>
> at this point i must retract some of the statements i made during the
> conversation about ruby yesterday. it turns out, spl iteration is not
> twice as fast as standard array iteration, in fact it quite a bit slower!
> also, it takes up more memory, and lastly, whoever said that using the
> array-by-reference syntax saves memory is dead wrong ;)
Thanks for the benchmark.
Makes me feel better having previously dismissed SPL for "wordy,
java-like syntax" only.
--
Greg Donald
http://destiney.com/
--- End Message ---
--- Begin Message ---
On Fri, 2008-02-01 at 11:11 -0600, Greg Donald wrote:
> Thanks for the benchmark.
>
Yes, thanks! It has just confirmed what I have been experiencing as
well.
I am busy converting a static site to a Chisimba CMS based site at the
moment with 43 000 odd static, frontpage generated HTML pages. I have
cut down processing times and regex times on the content from around 15
minutes to a few seconds (well waaay less than a minute anyway).
During the course of all of this, I have managed to create quite a few
SPL based classes that extend various aspects of the iterators
especially, which I will share soon if anyone is interested.
--Paul
All Email originating from UWC is covered by disclaimer
http://www.uwc.ac.za/portal/public/portal_services/disclaimer.htm
--- End Message ---
--- Begin Message ---
So I said in another thread that I would be asking another question
about functions... So here it goes, I am attempting to write a
function to search the database, which used to work just fine when I
wrote it without using a function (Would that be considered static?)
Now that I am attempting to rewrite my stuff so I can reuse the code,
now it's not working... Here is what I used to do and it worked just
fine:
$qstring = "SELECT * FROM ".$table." WHERE FName like '%$search%' or
LName like '%$search%' or Add1 like '%$search%' or Add2 like '%$search
%' or City like '%$search%' or State like '%$search%' or Zip like '%
$search%' or XCode like '%$search%'";
if ($_SESSION['search'] != NULL){
echo "The search string is: <strong>$search</strong>.<BR>";
$qrow[]= mysql_query($qstring) or die(mysql_error());
$qresult = $qrow[0];
$num_rows = mysql_num_rows($qresult);
//display search form
echo "
<form action='search.php' method='GET'>
<label>Search:
<input type='text' name='search' id='search' />
</label>
<input type='submit' value='Go!' />
</form>";
echo <<<HTML
<a href='index.php'>Return to database</A>
<P>Total Records found: {$num_rows}</P>
<A href='excelexport.php'>Export selection to excel</A>
<form method='GET' action='edit.php'>
<table border='1'>
<tr>
<th><a href='?order=a'>First Name</A></th>
<th><A href='?order=b'>Last Name</A></th>
<th><A href='?order=c'>Address Line 1</A></th>
<TH><A href='?order=d'>Address Line 2</A></th>
<TH><A href='?order=e'>City</A></th>
<th><A href='?order=f'>State</A></th>
<th><A href='?order=g'>Zip</A></th>
<TH><A href='?order=h'>Code</A></th>
<th><A href='?order=i'>ID #</A></th>
<TH>Edit</th>
<th>Delete</th>
</tr>
HTML;
echo "Just testing: ".$_SESSION['search'];
while($qrow = mysql_fetch_assoc($qresult)) {
//Display the search results using heredoc syntax
echo <<<HTML
<tr>
<td>{$qrow['FName']}</td>
<td>{$qrow['LName']}</td>
<td>{$qrow['Add1']}</td>
<td>{$qrow['Add2']}</td>
<td>{$qrow['City']}</td>
<td>{$qrow['State']}</td>
<td>{$qrow['Zip']}</td>
<td>{$qrow['XCode']}</td>
<td>{$qrow['Record']}</td>
<td><a href='edit.php?Record={$qrow['Record']}'>Edit</a></td>
<td><a
href='delete.php?Record={$qrow['Record']}'>Delete</a></td>
</tr>
</form>
HTML;
Now, here is what I have as a function and is not working:
<?PHP
$FName ="";
$LName ="";
$Add1 = "";
$Add2 = "";
// $_SESSION['search'] = $_GET['search'];
function search($searchvar, $table, $num_rows, $FName, $LName, $Add1,
$Add2) {
$qstring = "SELECT * FROM ".$table." WHERE FName like '%$searchvar%'
or LName like '%$searchvar%' or Add1 like '%$searchvar%' or Add2 like
'%$searchvar%' or City like '%$searchvar%' or State like '%$searchvar
%' or Zip like '%$searchvar%' or XCode like '%$searchvar%'";
$qrow[]= mysql_query($qstring) or die(mysql_error());
$qresult = $qrow[0];
$num_rows = mysql_num_rows($qresult);
//while($qrow = mysql_fetch_assoc($qresult)) {
$FName = $qrow['FName'];
$LName = $qrow['LName'];
$Add1 = $qrow['Add1'];
$Add2 = $qrow['Add2'];
return;
}
?>
And what happens, is first of all it displays the entire database on
the search page, which I'm kind of okay with... But when you search,
it updates the variables, and echo's out the right search term, but it
doesn't update the database to only show the search results... I think
it might be tied to it displaying the entire database at page load...
But I'm not sure.. Anyone have an idea of what I did wrong other then
everything? :)
Oh, and as far as calling the function I do this: search($searchvar,
$table, $num_rows, $FName, $LName, $Add1, $Add2);
--
Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424
www.raoset.com
[EMAIL PROTECTED]
--- End Message ---
--- Begin Message ---
On 2/1/08, Jason Pruim <[EMAIL PROTECTED]> wrote:
>
> So I said in another thread that I would be asking another question
> about functions... So here it goes, I am attempting to write a
> function to search the database, which used to work just fine when I
> wrote it without using a function (Would that be considered static?)
> Now that I am attempting to rewrite my stuff so I can reuse the code,
> now it's not working... Here is what I used to do and it worked just
> fine:
>
>
> $qstring = "SELECT * FROM ".$table." WHERE FName like '%$search%' or
> LName like '%$search%' or Add1 like '%$search%' or Add2 like '%$search
> %' or City like '%$search%' or State like '%$search%' or Zip like '%
> $search%' or XCode like '%$search%'";
> if ($_SESSION['search'] != NULL){
> echo "The search string is: <strong>$search</strong>.<BR>";
> $qrow[]= mysql_query($qstring) or die(mysql_error());
> $qresult = $qrow[0];
> $num_rows = mysql_num_rows($qresult);
> //display search form
> echo "
> <form action='search.php' method='GET'>
> <label>Search:
> <input type='text' name='search' id='search' />
> </label>
> <input type='submit' value='Go!' />
> </form>";
>
>
>
> echo <<<HTML
> <a href='index.php'>Return to database</A>
> <P>Total Records found: {$num_rows}</P>
> <A href='excelexport.php'>Export selection to excel</A>
> <form method='GET' action='edit.php'>
> <table border='1'>
> <tr>
> <th><a href='?order=a'>First Name</A></th>
> <th><A href='?order=b'>Last Name</A></th>
> <th><A href='?order=c'>Address Line 1</A></th>
> <TH><A href='?order=d'>Address Line 2</A></th>
> <TH><A href='?order=e'>City</A></th>
> <th><A href='?order=f'>State</A></th>
> <th><A href='?order=g'>Zip</A></th>
> <TH><A href='?order=h'>Code</A></th>
> <th><A href='?order=i'>ID #</A></th>
> <TH>Edit</th>
> <th>Delete</th>
> </tr>
>
> HTML;
> echo "Just testing: ".$_SESSION['search'];
> while($qrow = mysql_fetch_assoc($qresult)) {
> //Display the search results using heredoc syntax
> echo <<<HTML
>
> <tr>
>
> <td>{$qrow['FName']}</td>
> <td>{$qrow['LName']}</td>
> <td>{$qrow['Add1']}</td>
> <td>{$qrow['Add2']}</td>
> <td>{$qrow['City']}</td>
> <td>{$qrow['State']}</td>
> <td>{$qrow['Zip']}</td>
> <td>{$qrow['XCode']}</td>
> <td>{$qrow['Record']}</td>
> <td><a href='edit.php
> ?Record={$qrow['Record']}'>Edit</a></td>
> <td><a href='delete.php
> ?Record={$qrow['Record']}'>Delete</a></td>
> </tr>
>
> </form>
> HTML;
>
> Now, here is what I have as a function and is not working:
>
> <?PHP
> $FName ="";
> $LName ="";
> $Add1 = "";
> $Add2 = "";
> // $_SESSION['search'] = $_GET['search'];
>
function search($searchvar, $table, $num_rows, $FName, $LName, $Add1, $Add2)
{
$qstring = "SELECT * FROM ".$table." WHERE FName like '%$searchvar%'
or LName like '%$searchvar%' or Add1 like
'%$searchvar%' or Add2 like
'%$searchvar%' or City like '%$searchvar%' or State
like '%$searchvar%'
or Zip like '%$searchvar%' or XCode like
'%$searchvar%'";
$qrow[]= mysql_query($qstring) or die(mysql_error());
$qresult = $qrow[0];
$num_rows = mysql_num_rows($qresult);
while($qrow = mysql_fetch_assoc($qresult)) {
$FName = $qrow['FName'];
$LName = $qrow['LName'];
$Add1 = $qrow['Add1'];
$Add2 = $qrow['Add2'];
}
// what do you want to return...?
return;
}
?>
$returnedSomething = search($searchvar, $table, $num_rows, $FName, $LName,
$Add1, $Add2);
Jason,
1. You're missing a closing brace at the end of the while loop.
2. You're not returning anything from the function.
The input parameters are pretty clear but what were you expecting to
accomplish within the function?
All the data returned from the query only have scope within the function, so
unless you return something, like an array or a string, use references, or
write to a global variable, you're not doing anything with the data from the
db.
David
--- End Message ---
--- Begin Message ---
On Feb 1, 2008, at 2:20 PM, David Giragosian wrote:
On 2/1/08, Jason Pruim <[EMAIL PROTECTED]> wrote:
[snip long explanation of problem]
function search($searchvar, $table, $num_rows, $FName, $LName,
$Add1, $Add2) {
$qstring = "SELECT * FROM ".$table." WHERE FName like '%
$searchvar%'
or LName like '%$searchvar%' or Add1 like '%
$searchvar%' or Add2 like
'%$searchvar%' or City like '%$searchvar%'
or State like '%$searchvar%'
or Zip like '%$searchvar%' or XCode like '%
$searchvar%'";
$qrow[]= mysql_query($qstring) or die(mysql_error());
$qresult = $qrow[0];
$num_rows = mysql_num_rows($qresult);
while($qrow = mysql_fetch_assoc($qresult)) {
$FName = $qrow['FName'];
$LName = $qrow['LName'];
$Add1 = $qrow['Add1'];
$Add2 = $qrow['Add2'];
}
// what do you want to return...?
return;
}
?>
$returnedSomething = search($searchvar, $table, $num_rows, $FName,
$LName, $Add1, $Add2);
Jason,
1. You're missing a closing brace at the end of the while loop.
2. You're not returning anything from the function.
The input parameters are pretty clear but what were you expecting to
accomplish within the function?
All the data returned from the query only have scope within the
function, so unless you return something, like an array or a string,
use references, or write to a global variable, you're not doing
anything with the data from the db.
David
Hi David,
Thanks for looking. I'm just starting to learn about functions, and
obviously making a few mistakes along the road...
Basically what I am trying to do is allow my customer the ability to
search the database, display it on the website, and then export it to
excel if they wish...
the missing closing brace was a bad copy/paste job.
I have tried to add $searchReturn = search($searchvar, $table,
$num_rows, $FName, $LName, $Add1, $Add2);
and then do a vardump on it and it's not returning any thing.
I've also changed the return line to return $searchReturn['FName'];
but it's still not showing through...
I think functions will be the death of me... at least until I
understand how to use them :)
I think I'm off to google some more and see if I can get any more
info...
Thanks again for your help!
--
Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424
www.raoset.com
[EMAIL PROTECTED]
--- End Message ---
--- Begin Message ---
On 2/1/08, Jason Pruim <[EMAIL PROTECTED]> wrote:
>
> On Feb 1, 2008, at 2:20 PM, David Giragosian wrote:
>
> On 2/1/08, Jason Pruim <[EMAIL PROTECTED]> wrote:
> >
> > [snip long explanation of problem]
>
>
> function search($searchvar, $table, $num_rows, $FName, $LName, $Add1,
> $Add2) {
> $qstring = "SELECT * FROM ".$table." WHERE FName like
> '%$searchvar%'
> or LName like '%$searchvar%' or Add1 like
> '%$searchvar%' or Add2 like
> '%$searchvar%' or City like '%$searchvar%' or
> State like '%$searchvar%'
> or Zip like '%$searchvar%' or XCode like
> '%$searchvar%'";
>
> $qrow[]= mysql_query($qstring) or die(mysql_error());
> $qresult = $qrow[0];
> $num_rows = mysql_num_rows($qresult);
> while($qrow = mysql_fetch_assoc($qresult)) {
> $FName = $qrow['FName'];
> $LName = $qrow['LName'];
> $Add1 = $qrow['Add1'];
> $Add2 = $qrow['Add2'];
>
> }
>
> // what do you want to return...?
> return;
>
> }
>
> ?>
>
> $returnedSomething = search($searchvar, $table, $num_rows, $FName, $LName,
> $Add1, $Add2);
>
> Jason,
>
> 1. You're missing a closing brace at the end of the while loop.
> 2. You're not returning anything from the function.
>
> The input parameters are pretty clear but what were you expecting to
> accomplish within the function?
>
> All the data returned from the query only have scope within the function,
> so unless you return something, like an array or a string, use references,
> or write to a global variable, you're not doing anything with the data from
> the db.
>
> David
>
>
> Hi David,
>
>
> Thanks for looking. I'm just starting to learn about functions, and
> obviously making a few mistakes along the road...
>
>
> Basically what I am trying to do is allow my customer the ability to
> search the database, display it on the website, and then export it to excel
> if they wish...
>
>
> the missing closing brace was a bad copy/paste job.
>
>
> I have tried to add $searchReturn = search($searchvar, $table, $num_rows,
> $FName, $LName, $Add1, $Add2);
> and then do a vardump on it and it's not returning any thing.
>
>
> I've also changed the return line to return $searchReturn['FName'];
> but it's still not showing through...
>
>
> I think functions will be the death of me... at least until I understand
> how to use them :)
>
>
> I think I'm off to google some more and see if I can get any more info...
>
>
> Thanks again for your help!
>
Jason,
Untested, but try this...
function search($searchvar, $table, $num_rows, $FName, $LName, $Add1, $Add2)
{
$qstring = "SELECT * FROM ".$table." WHERE FName like '%$searchvar%'
or LName like '%$searchvar%' or Add1 like
'%$searchvar%' or Add2 like
'%$searchvar%' or City like '%$searchvar%' or State
like '%$searchvar%'
or Zip like '%$searchvar%' or XCode like
'%$searchvar%'";
$qrow = mysql_query($qstring) or die(mysql_error());
$qresult = $qrow;
$num_rows = mysql_num_rows($qresult);
$outputStr = "<table>";
while($qrow = mysql_fetch_assoc($qresult)) {
$FName = $qrow['FName'];
$LName = $qrow['LName'];
$Add1 = $qrow['Add1'];
$Add2 = $qrow['Add2'];
$outputStr .=
"<tr><td>$FName</td><td>$LName</td><td>$ADD1</td><td>$ADD2</td></tr>\n";
}
$outputStr .= "</table>";
return $outputStr;
}
$searchReturn = search($searchvar, $table, $num_rows, $FName, $LName, $Add1,
$Add2);
echo $searchReturn;
David
--- End Message ---
--- Begin Message ---
>
> Jason,
>
> Untested, but try this...
>
> function search($searchvar, $table, $num_rows, $FName, $LName, $Add1,
> $Add2) {
> $qstring = "SELECT * FROM ".$table." WHERE FName like
> '%$searchvar%'
> or LName like '%$searchvar%' or Add1 like
> '%$searchvar%' or Add2 like
> '%$searchvar%' or City like '%$searchvar%' or
> State like '%$searchvar%'
> or Zip like '%$searchvar%' or XCode like
> '%$searchvar%'";
>
> $qrow = mysql_query($qstring) or die(mysql_error());
> $qresult = $qrow;
> $num_rows = mysql_num_rows($qresult);
>
> $outputStr = "<table>";
>
> while($qrow = mysql_fetch_assoc($qresult)) {
> $FName = $qrow['FName'];
> $LName = $qrow['LName'];
> $Add1 = $qrow['Add1'];
> $Add2 = $qrow['Add2'];
>
> $outputStr .=
> "<tr><td>$FName</td><td>$LName</td><td>$ADD1</td><td>$ADD2</td></tr>\n";
>
> }
>
> $outputStr .= "</table>";
>
>
> return $outputStr;
>
> }
>
> $searchReturn = search($searchvar, $table, $num_rows, $FName, $LName,
> $Add1, $Add2);
>
> echo $searchReturn;
>
> David
>
Hold on a moment...
function search($searchvar, $table, $num_rows, $FName, $LName, $Add1, $Add2)
{
$qstring = "SELECT * FROM ".$table." WHERE FName like '%$searchvar%'
or LName like '%$searchvar%' or Add1 like
'%$searchvar%' or Add2 like
'%$searchvar%' or City like '%$searchvar%' or State
like '%$searchvar%'
or Zip like '%$searchvar%' or XCode like
'%$searchvar%'";
$qresult = mysql_query($qstring) or die(mysql_error());
// $qresult = $qrow; // this line is the problem !
$num_rows = mysql_num_rows($qresult);
$outputStr = "<table>";
while($qrow = mysql_fetch_assoc($qresult)) {
$FName = $qrow['FName'];
$LName = $qrow['LName'];
$Add1 = $qrow['Add1'];
$Add2 = $qrow['Add2'];
$outputStr .=
"<tr><td>$FName</td><td>$LName</td><td>$ADD1</td><td>$ADD2</td></tr>\n";
}
$outputStr .= "</table>";
return $outputStr;
}
$searchReturn = search($searchvar, $table, $num_rows, $FName, $LName, $Add1,
$Add2);
echo $searchReturn;
That should work, assuming the query returns at least one row..
David
--- End Message ---
--- Begin Message ---
I would like to use a function to check to see if a session variable
is set and return the session variable if it is set, and return blank
if not. Something like
function set_var($var)
{
echo "var = $var \n";
if (isset($_SESSION['$var']))
{
return $_SESSION['$var'];
}
else
{
return "";
}
}
And I would call the function with set_var($name) or set_var($phone).
The problem is getting the function to use $var as a variable name,
rather than a value. What am I missing, please?
-----===== Bill =====-----
--
Diplomacy - telling your boss he has an open mind
instead of saying he has a hole in his head.
--- End Message ---
--- Begin Message ---
On Feb 1, 2008 10:49 AM, Bill Guion <[EMAIL PROTECTED]> wrote:
> I would like to use a function to check to see if a session variable
> is set and return the session variable if it is set, and return blank
> if not. Something like
>
> function set_var($var)
> {
> echo "var = $var \n";
echo "\$var = $var\n"; // :)
> if (isset($_SESSION['$var']))
$_SESSION[$var]
> {
> return $_SESSION['$var'];
$_SESSION[$var]
> }
> else
> {
> return "";
return '';
> }
> }
>
> And I would call the function with set_var($name) or set_var($phone).
> The problem is getting the function to use $var as a variable name,
> rather than a value. What am I missing, please?
"" means interpolate the contents.
'' means use the literal content.
--
Greg Donald
http://destiney.com/
--- End Message ---
--- Begin Message ---
Bill Guion wrote:
I would like to use a function to check to see if a session variable is
set and return the session variable if it is set, and return blank if
not. Something like
You really don't need a function for this:
// Could use null instead of false
$variable = isset($_SESSION[$name]) ? $_SESSION[$name] : false;
--
Richard Heyes
http://www.websupportsolutions.co.uk
Knowledge Base and Helpdesk software for £299pa hosted for you -
no installation, no maintenance, new features automatic and free
--- End Message ---