Group: http://groups.google.com/group/sitedesign/topics
- php include [6 Updates]
- Members Directory [2 Updates]
- Artist <sitepro@gmail.com> Jul 15 11:50PM -0500
I have a couple of php includes. They look like this:
<div id="navcell" style="background-image:url(<?php include "/home/www/
primo-deluxe.net/scripts/random/random-menu-bg.php";?>);">
in a php page in the root.
the code in random-menu-bg.php:
<?php
$filename = "/home/www/primo-deluxe.net/scripts/random/menu-bg-images.txt";
$opener = file("$filename");
$countImages = count($opener);
$countImages = $countImages-1;
$randomImage = rand(0, $countImages);
echo "\"$opener[$randomImage]\"";
?>
...loads a list of random image urls and is supposed to throw one of those
urls in where the include is.
But it ain't happening. Anyone know where I went wrong?
Thanks!
Doug Peters
(605) 331-0808
http://www.Doug-Peters.com http://www.twitter.com/Domainating
http://www.facebook.com/people/Douglas-Peters/1628191759
http://www.W3DN.com http://www.DomainHostmaster.com
http://www.Domainers.Name http://www.PremiumBrand.Name
http://www.fontjournal.com http://www.StandardLogo.com
http://www.PhotoshopPros.com
http://www.Twidrops.com<http://www.twidrops.com>
http://www.GlossaryIndex.com <http://www.SymbioticDesign.com>
- nestkojex@gmail.com Jul 16 08:22AM
First of all, I will advise that you use REQUIRE. If the address to the urls is not right or there is any other problem the REQUIRE will produce fatal error and the error may point you to the problem.
Second, try to ECHO $countImages = $countImages-1; to see if it even returns anything before using RAND to call it up in your ARRAY. But if I were in your shoes, instead of using the PHP file function to call urls from a txt file, I would rather place the urls in a MYSQL database tables with unique ids and randomly call them into the PHP page with the unique ids.
I hope this helps. I hope this helps. </div>
Sent from my BlackBerry® smartphone provided by Airtel Nigeria.
-----Original Message-----
From: Artist <sitepro@gmail.com>
Sender: sitedesign@googlegroups.com
Date: Mon, 15 Jul 2013 23:50:39
To: Web Design and Development<SiteDesign@googlegroups.com>
Reply-To: sitedesign@googlegroups.com
Subject: [WD&D] php include
I have a couple of php includes. They look like this:
<div id="navcell" style="background-image:url(<?php include "/home/www/
primo-deluxe.net/scripts/random/random-menu-bg.php";?>);">
in a php page in the root.
the code in random-menu-bg.php:
<?php
$filename = "/home/www/primo-deluxe.net/scripts/random/menu-bg-images.txt";
$opener = file("$filename");
$countImages = count($opener);
$countImages = $countImages-1;
$randomImage = rand(0, $countImages);
echo "\"$opener[$randomImage]\"";
?>
...loads a list of random image urls and is supposed to throw one of those
urls in where the include is.
But it ain't happening. Anyone know where I went wrong?
Thanks!
Doug Peters
(605) 331-0808
http://www.Doug-Peters.com http://www.twitter.com/Domainating
http://www.facebook.com/people/Douglas-Peters/1628191759
http://www.W3DN.com http://www.DomainHostmaster.com
http://www.Domainers.Name http://www.PremiumBrand.Name
http://www.fontjournal.com http://www.StandardLogo.com
http://www.PhotoshopPros.com
http://www.Twidrops.com<http://www.twidrops.com>
http://www.GlossaryIndex.com <http://www.SymbioticDesign.com>
--
--
You received this because you are subscribed to the "Web Design and Development" group at Google Groups. Messages are prefixed with [WD&D] in the subject. No spam is allowed. Be civil, be professional; try to be helpful & mind your netiquette. All posts are Copyright the original author and the Web Design and Development group. No reproduction of this content is allowed in any electronic or printed form outside the group at Google Groups and the http://www.WDaDg.org website. Any unauthorized use of our copy constitutes illegal Copyright infringement and may well be prosecuted to the full extent of the law. Digital Signature: $©"[W|D|&|D]g"|^|!SiteDesign@GG||#%$
To post to this group, email SiteDesign@googlegroups.com
To unsubscribe, email SiteDesign-unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/SiteDesign?hl=en
---
You received this message because you are subscribed to the Google Groups "Web Design and Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sitedesign+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
- Artist <sitepro@gmail.com> Jul 16 06:41AM -0500
(Anyone notice that Google sucks for writing code in Gmail now that there
are no real formatting option for that (Code), and other things like
scrolling up and down to read/reply/quote is a headache in the new gmail
format? I usually use my mouse's scroll wheel, but can't anymore. What's
up with that, Gmail? I don't think Google wants us here, anymore.)
(Another note... OK, I guess you guys aren't taking me for the smart-ass I
tend to be, so please just remember that my humor is dry and in my grumpy
old age I consider it humor because I am actually in a lot of pain for the
past year. But I am meaning to be funny a whole lot more than how
seriously everyone is taking me. So just imagine I have smilies in all my
posts, OK?)
*Back on-topic:*
Jeepers, I suck at php. Which is understandable, as I never learned it.
But I have been using this script for random images for quite some time,
now. Since I started designing in Dreamweaver and before you guys (the
group as a whole) made me clean up my code. Now its on for a php lesson.
Cool. At least I'll learn something. ;) But I am going to argue some of
your points, too... ;)
> First of all, I will advise that you use REQUIRE. If the address to the
> urls is not right or there is any other problem the REQUIRE will produce
> fatal error and the error may point you to the problem.
<div id="navcell" style="background-image:url(<?php require "/home/www/
primo-deluxe.net/scripts/random/random-menu-bg.php";?>);">
The reason I asked in the first place is because I could have done it a
little differently, like...
<div id="navcell" <?php require "/home/www/
primo-deluxe.net/scripts/random/random-menu-bg.php";?>">
...and append the url that's called with the...
style=/"background-image:url(
Second, try to ECHO $countImages = $countImages-1; to see if it even
> returns anything before using RAND to call it up in your ARRAY.
so then in the php file I called... random-menu-bg.php:
<?php
$filename = "/home/www/primo-deluxe.net/scripts/random/menu-bg-images.txt";
$opener = file("$filename");
$countImages = count($opener);
echo $countImages = $countImages-1;
$randomImage = rand(0, $countImages);
echo "\"$opener[$randomImage]\"";
?>
or option #2...
<?php
$filename = "/home/www/primo-deluxe.net/scripts/random/menu-bg-images.txt";
$opener = file("$filename");
$countImages = count($opener);
echo $countImages = $countImages-1;
$randomImage = rand(0, $countImages);
echo "style="\background-image:url("\"$opener[$randomImage]\")";
?>
???
Which way is better, option 1 (just returning the url) or option 2
(returning the whole style="background-image:url(home/path/text.txt)";)?
But if I were in your shoes, instead of using the PHP file function to call
urls from a txt file, I would rather place the urls in a MYSQL database
tables with unique ids and randomly call them into the PHP page with the
unique ids.
I hope this helps.
;)
OK, here is where I have to make sure everyone else would do this. First,
I would have to create a database for about 22 random menu background
images, which itself opens me up to MySQL database injection hacks. I
would have to build the database with more than just a few urls, too,
right? Then, the MySQL database is supposed to be slower than accessing
and reading a regular text file, I thought. On top of that I would have to
learn how to open and close the database. Then, I would have to make a
whole 'nother database and do it all again for the other random bg images I
use in the sidebar? I think that has to be way overkill and open myself up
in the security department. Plus, I only have so many databases in the
hosting account anyway. And these urls will NEVER change unless I move to
a new host, in which case I would see both random backgrounds aren't
loading and change their hosting path from home, not have to address making
a new databases, etc... so they are also more portable and more easily
configured.
;) ;) ;)
*What say you, WDADG? ;)*
Thanks.... DP
PS:
(Dang, I hate the new Google GMail. They just don't want to make anything
easy anymore and the whole interface is completely and totally useless in a
smart phone of tablet).
- nestkojex@gmail.com Jul 16 06:41PM
1. I know database is rather not the best for this but under the circumstances, I think it better as it won't give the problems associated with file function.
2. What's the content of the txt file that has the URLs. I mean, how are they listed?
3. For your question on what option is better? I will go with the first. It reduces the chances of errors.
4. Finally, since the URLs are few, I will suggest that you store your URLs directly in an array on the top of your page and call them into the style=/"background-image:url( part. This is better since eventually you still use arrays to call the final output ($opener[$randomImage]). I could have written sample code but I am typing from my phone. But if you want as soon as am home I will write in on my laptop.
I seldom use the file function unless when am dealing with image or Doc upload.
NB: sql attack will be very hard to perform on your database because you won't be placing any form on you serve for uploading the URLs since you will be typing the directly into you PHPMYADMIN. Besides, your host and the recent MYSQL database have other security measures to prevent common sql injections. t be placing any form on you serve for uploading the URLs since you will be typing the directly into you PHPMYADMIN. Besides, your host and the recent MYSQL database have other security measures to prevent common sql injections. </div>
Sent from my BlackBerry® smartphone provided by Airtel Nigeria.
-----Original Message-----
From: Artist <sitepro@gmail.com>
Sender: sitedesign@googlegroups.com
Date: Tue, 16 Jul 2013 06:41:16
To: Web Design and Development<sitedesign@googlegroups.com>
Reply-To: sitedesign@googlegroups.com
Subject: Re: [WD&D] php include
(Anyone notice that Google sucks for writing code in Gmail now that there
are no real formatting option for that (Code), and other things like
scrolling up and down to read/reply/quote is a headache in the new gmail
format? I usually use my mouse's scroll wheel, but can't anymore. What's
up with that, Gmail? I don't think Google wants us here, anymore.)
(Another note... OK, I guess you guys aren't taking me for the smart-ass I
tend to be, so please just remember that my humor is dry and in my grumpy
old age I consider it humor because I am actually in a lot of pain for the
past year. But I am meaning to be funny a whole lot more than how
seriously everyone is taking me. So just imagine I have smilies in all my
posts, OK?)
*Back on-topic:*
Jeepers, I suck at php. Which is understandable, as I never learned it.
But I have been using this script for random images for quite some time,
now. Since I started designing in Dreamweaver and before you guys (the
group as a whole) made me clean up my code. Now its on for a php lesson.
Cool. At least I'll learn something. ;) But I am going to argue some of
your points, too... ;)
> First of all, I will advise that you use REQUIRE. If the address to the
> urls is not right or there is any other problem the REQUIRE will produce
> fatal error and the error may point you to the problem.
<div id="navcell" style="background-image:url(<?php require "/home/www/
primo-deluxe.net/scripts/random/random-menu-bg.php";?>);">
The reason I asked in the first place is because I could have done it a
little differently, like...
<div id="navcell" <?php require "/home/www/
primo-deluxe.net/scripts/random/random-menu-bg.php";?>">
...and append the url that's called with the...
style=/"background-image:url(
Second, try to ECHO $countImages = $countImages-1; to see if it even
> returns anything before using RAND to call it up in your ARRAY.
so then in the php file I called... random-menu-bg.php:
<?php
$filename = "/home/www/primo-deluxe.net/scripts/random/menu-bg-images.txt";
$opener = file("$filename");
$countImages = count($opener);
echo $countImages = $countImages-1;
$randomImage = rand(0, $countImages);
echo "\"$opener[$randomImage]\"";
?>
or option #2...
<?php
$filename = "/home/www/primo-deluxe.net/scripts/random/menu-bg-images.txt";
$opener = file("$filename");
$countImages = count($opener);
echo $countImages = $countImages-1;
$randomImage = rand(0, $countImages);
echo "style="\background-image:url("\"$opener[$randomImage]\")";
?>
???
Which way is better, option 1 (just returning the url) or option 2
(returning the whole style="background-image:url(home/path/text.txt)";)?
But if I were in your shoes, instead of using the PHP file function to call
urls from a txt file, I would rather place the urls in a MYSQL database
tables with unique ids and randomly call them into the PHP page with the
unique ids.
I hope this helps.
;)
OK, here is where I have to make sure everyone else would do this. First,
I would have to create a database for about 22 random menu background
images, which itself opens me up to MySQL database injection hacks. I
would have to build the database with more than just a few urls, too,
right? Then, the MySQL database is supposed to be slower than accessing
and reading a regular text file, I thought. On top of that I would have to
learn how to open and close the database. Then, I would have to make a
whole 'nother database and do it all again for the other random bg images I
use in the sidebar? I think that has to be way overkill and open myself up
in the security department. Plus, I only have so many databases in the
hosting account anyway. And these urls will NEVER change unless I move to
a new host, in which case I would see both random backgrounds aren't
loading and change their hosting path from home, not have to address making
a new databases, etc... so they are also more portable and more easily
configured.
;) ;) ;)
*What say you, WDADG? ;)*
Thanks.... DP
PS:
(Dang, I hate the new Google GMail. They just don't want to make anything
easy anymore and the whole interface is completely and totally useless in a
smart phone of tablet).
--
--
You received this because you are subscribed to the "Web Design and Development" group at Google Groups. Messages are prefixed with [WD&D] in the subject. No spam is allowed. Be civil, be professional; try to be helpful & mind your netiquette. All posts are Copyright the original author and the Web Design and Development group. No reproduction of this content is allowed in any electronic or printed form outside the group at Google Groups and the http://www.WDaDg.org website. Any unauthorized use of our copy constitutes illegal Copyright infringement and may well be prosecuted to the full extent of the law. Digital Signature: $©"[W|D|&|D]g"|^|!SiteDesign@GG||#%$
To post to this group, email SiteDesign@googlegroups.com
To unsubscribe, email SiteDesign-unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/SiteDesign?hl=en
---
You received this message because you are subscribed to the Google Groups "Web Design and Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sitedesign+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
- Artist <sitepro@gmail.com> Jul 16 04:56PM -0500
Hey, nestkojex...
<http://www.SymbioticDesign.com>
> 1. I know database is rather not the best for this but under the
> circumstances, I think it better as it won't give the problems associated
> with file function.
It will do fine. Better that than a database, as far as I'm concerned. I
have to worry about speed and maintaining as few open connections as
possible. Plus, I need the databases for other projects.
2. What's the content of the txt file that has the URLs. I mean, how are
> they listed?
Simple. One per line. No unused lines.
> 3. For your question on what option is better? I will go with the first.
> It reduces the chances of errors.
OK, I thought the 2nd might give less errors. But either way it's just a
missing 1) style argument or 2) a missing style.
> still use arrays to call the final output ($opener[$randomImage]). I could
> have written sample code but I am typing from my phone. But if you want as
> soon as am home I will write in on my laptop.
Well, that would work even better, wouldn't it? Cool. I know about those
phones. I have been typing on them for about a year off and on because
after I hurt myself at work, my Windows stopped updating, and I have been
trying to fix it ever since. I spend days backing up, so no laptop to use
while it does. Then I try and recover/rebuild/fix the OS and eventually
fail after a week, so I have to restore from the backup, which takes days
again. So I use my phone a lot, especially with my tablet down now, too.
> will be typing the directly into you PHPMYADMIN. Besides, your host and the
> recent MYSQL database have other security measures to prevent common sql
> injections.
Yeah, maybe, but loading a called array from the top of the page would be
best. I have 22 random background images urls in one file and 17 random bg
images for the sidebarcell div on the other side. I think that would work
best.
If you get around to it, I would appreciate it, or tell me how, either way.
So...
Setup the arrays in the head.
Set up 2 functions calling the different arrays:
<?php
$countImages = count($opener);
echo $countImages = $countImages-1;
$randomImage = rand(0, $countImages);
?>);">
Then...
<div id="navcell" style="background-image:url(<?php $opener[randomImage);?>
I really made that ugly, didn't I?
Yeah, bust it out, if you would like. ;) Thank you!
*OLD STUFF:*
- nestkojex@gmail.com Jul 16 11:38PM
part 1
<?php
$names[0] = 'url1';
$names[1] = 'url2';
$names[2] = 'url3';
$names[3] = 'url4';
$names[4] = 'url5';
$number =count($names); //count the number of elements in the array
$rand=rand(0,($number-1)); //subtract 1 from the total count so there is possibility of getting 0
?>
part2
<div id="navcell" style="background-image:url(<?php echo $names[$rand];?>)" >Ernest Okojie</div>
You may place part 1 in another file so it can be used in other file and use require to call it in the image display page.
CiaoCiao</div>
Sent from my BlackBerry® smartphone provided by Airtel Nigeria.
-----Original Message-----
From: Artist <sitepro@gmail.com>
Sender: sitedesign@googlegroups.com
Date: Tue, 16 Jul 2013 16:56:50
To: Web Design and Development<sitedesign@googlegroups.com>
Reply-To: sitedesign@googlegroups.com
Subject: Re: [WD&D] php include
Hey, nestkojex...
<http://www.SymbioticDesign.com>
> 1. I know database is rather not the best for this but under the
> circumstances, I think it better as it won't give the problems associated
> with file function.
It will do fine. Better that than a database, as far as I'm concerned. I
have to worry about speed and maintaining as few open connections as
possible. Plus, I need the databases for other projects.
2. What's the content of the txt file that has the URLs. I mean, how are
> they listed?
Simple. One per line. No unused lines.
> 3. For your question on what option is better? I will go with the first.
> It reduces the chances of errors.
OK, I thought the 2nd might give less errors. But either way it's just a
missing 1) style argument or 2) a missing style.
> still use arrays to call the final output ($opener[$randomImage]). I could
> have written sample code but I am typing from my phone. But if you want as
> soon as am home I will write in on my laptop.
Well, that would work even better, wouldn't it? Cool. I know about those
phones. I have been typing on them for about a year off and on because
after I hurt myself at work, my Windows stopped updating, and I have been
trying to fix it ever since. I spend days backing up, so no laptop to use
while it does. Then I try and recover/rebuild/fix the OS and eventually
fail after a week, so I have to restore from the backup, which takes days
again. So I use my phone a lot, especially with my tablet down now, too.
> will be typing the directly into you PHPMYADMIN. Besides, your host and the
> recent MYSQL database have other security measures to prevent common sql
> injections.
Yeah, maybe, but loading a called array from the top of the page would be
best. I have 22 random background images urls in one file and 17 random bg
images for the sidebarcell div on the other side. I think that would work
best.
If you get around to it, I would appreciate it, or tell me how, either way.
So...
Setup the arrays in the head.
Set up 2 functions calling the different arrays:
<?php
$countImages = count($opener);
echo $countImages = $countImages-1;
$randomImage = rand(0, $countImages);
?>);">
Then...
<div id="navcell" style="background-image:url(<?php $opener[randomImage);?>
I really made that ugly, didn't I?
Yeah, bust it out, if you would like. ;) Thank you!
*OLD STUFF:*
> database tables with unique ids and randomly call them into the PHP page
> with the unique ids.
> I hope this helps.
--
--
You received this because you are subscribed to the "Web Design and Development" group at Google Groups. Messages are prefixed with [WD&D] in the subject. No spam is allowed. Be civil, be professional; try to be helpful & mind your netiquette. All posts are Copyright the original author and the Web Design and Development group. No reproduction of this content is allowed in any electronic or printed form outside the group at Google Groups and the http://www.WDaDg.org website. Any unauthorized use of our copy constitutes illegal Copyright infringement and may well be prosecuted to the full extent of the law. Digital Signature: $©"[W|D|&|D]g"|^|!SiteDesign@GG||#%$
To post to this group, email SiteDesign@googlegroups.com
To unsubscribe, email SiteDesign-unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/SiteDesign?hl=en
---
You received this message because you are subscribed to the Google Groups "Web Design and Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sitedesign+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
- samanka farm <samankafarm@gmail.com> Jul 16 03:47PM -0500
Thanks for the ideas and the encouragement.
JJ
- Artist <sitepro@gmail.com> Jul 16 05:52PM -0500
I think the member directory's subdomain has been resolved. I am going to
check the settings and stuff. But we can start adding links to your
websites and blogs with Google Maps support and all...
http://dir.wdadg.org/
I willl be doing something with the design to reflect the front page. But
this part probably won't be supprting your pick of css themes in a drop
down... maybe/maybe-not
Doug Peters
(605) 331-0808
http://www.Doug-Peters.com http://www.twitter.com/Domainating
http://www.facebook.com/people/Douglas-Peters/1628191759
http://www.W3DN.com http://www.DomainHostmaster.com
http://www.Domainers.Name http://www.PremiumBrand.Name
http://www.fontjournal.com http://www.StandardLogo.com
http://www.PhotoshopPros.com
http://www.Twidrops.com<http://www.twidrops.com>
http://www.GlossaryIndex.com <http://www.SymbioticDesign.com>
--
You received this because you are subscribed to the "Web Design and Development" group at Google Groups. Messages are prefixed with [WD&D] in the subject. No spam is allowed. Be civil, be professional; try to be helpful & mind your netiquette. All posts are Copyright the original author and the Web Design and Development group. No reproduction of this content is allowed in any electronic or printed form outside the group at Google Groups and the http://www.WDaDg.org website. Any unauthorized use of our copy constitutes illegal Copyright infringement and may well be prosecuted to the full extent of the law. Digital Signature: $©"[W|D|&|D]g"|^|!SiteDesign@GG||#%$
To post to this group, email SiteDesign@googlegroups.com
To unsubscribe, email SiteDesign-unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/SiteDesign?hl=en
---
You received this message because you are subscribed to the Google Groups "Web Design and Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sitedesign+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
No comments:
Post a Comment