[Gllug] mySQL PHP
Bruce Richardson
brichardson at lineone.net
Tue Jul 10 18:10:43 UTC 2001
On Tue, Jul 10, 2001 at 04:09:01PM +0100, Jackson, Harry wrote:
> Hi all,
>
> For anyone who is interested this is the PHP page that I am using to
> generate the front page. It probably could be a lot neater but it works
> except on initial load because the "$var" variables have not been initiated
> and I am not sure how to initiate them only on refresh or first entry of the
> page. I have tried to just declare them but they then always default to that
> value when I hit the "Enter Information" button on the page.
[snip]
> $caseid = mysql_query("SELECT * FROM remedy_base where $var1 Like '%$var2%'
> and $var3 $var4 '%$var5%'",$db);
This line is the problem? Well, what you need to do is set the $varN
variables to some default value if they are unset or FALSE. Here's an
example:
$var1 = $var1 ? $var : "default value";
or alternatively
($var1) || ($var1 = "default value);
whichever takes your fancy.
Or you could test to see if the variables have been set and only execute
your statement if they all are:
($var1) && ($var2) && ($var3) && ($var4) && ($var5)
&& (execute your statement within these brackets);
Which would be more appropriate to your needs? Setting defaults or not
executing if unset?
I have some other concerns about your code but there's no need to go
down those byways right now.
--
Bruce
The ice-caps are melting, tra-la-la-la. All the world is drowning,
tra-la-la-la-la. -- Tiny Tim.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 261 bytes
Desc: not available
URL: <http://mailman.lug.org.uk/pipermail/gllug/attachments/20010710/f6ce3120/attachment.pgp>
More information about the GLLUG
mailing list