Web Development Questions That Don't Need Their Own Thread v2
3,079 replies, posted
[QUOTE=zzlawlzz;33907680]why do you bother adding pren to echo? does it even work?
[/QUOTE]
I thought that was normal. o.o
[QUOTE=jetboy;33908478]I thought that was normal. o.o[/QUOTE]
Personal preference I'd say, I personally don't use parentheses around echo.
I'm working on a one page site (original I know) and I'd like to have a fixed menu where clicking one the links will autoscroll you to a certain position. I know I can code to directly link to certain divs with
<a href="#exampleDivId">Example</a>, but that brings you directly to the position. Is there a way to have that scroll fluidly to the position? I'm guessing I have to use some JavaScript. Thanks in advance if people know.
[editline]x[/editline]
I found jQuery's ScrollTo. Is that what people are using?
[QUOTE=zzlawlzz;33907680]also, i suggest using '' instead of "" when your defining things. I heard it's faster.[/QUOTE]
It's not, it was faster in PHP4, and even then the difference was hardly noticeable.
[QUOTE=atl101;33910177]I found jQuery's ScrollTo. Is that what people are using?[/QUOTE]
That'll do it just fine.
has anyone got any experience using a jquery copy to clipboard plugin?
Hey, guys, I need some mod_rewrite voodoo. I recently moved my old static site from example.com to subdomain.example.com. Links now redirect like this:
[url]http://example.com/file.html[/url] --> [url]http://subdomain.example.com/file.html[/url]
I achieved this in a very simple manner, using 301 redirects in .htaccess:
[CODE]RewriteEngine on
RewriteCond %{HTTP_HOST} ^example\.com
RewriteRule ^(.*)$ http://subdomain.example.com/$1 [R=301,L][/CODE]
This rule redirects [I][B]everything[/B][/I]. But now I want to use the main domain to host another site (a Wordpress installation), so I only want to redirect the old static links. I obviously don't want the root domain redirected, nor the new Wordpress links. Now I need the corect mod_rewrite magic in order to achieve this:
[url]http://example.com/file.html[/url] --> [url]http://subdomain.example.com/file.html[/url]
[url]http://example.com/folder/file.html[/url] --> [url]http://subdomain.example.com/folder/file.html[/url]
[url]http://example.com/file.php[/url] --> [url]http://example.com/file.php[/url] (no redirect)
[url]http://example.com[/url] --> [url]http://example.com[/url] (no redirect)
Any help is appreciated.
This should work:
[code]RewriteEngine on
RewriteCond %{HTTP_HOST} ^example\.com
RewriteRule ^(.*)\.html$ http://subdomain.example.com/$1 [R=301,L][/code]
Can't really test it now, I don't think I have Apache installed anywhere, but tell me if it works.
[QUOTE=Alcapwne;33917301]has anyone got any experience using a jquery copy to clipboard plugin?[/QUOTE]
I've used ZeroClipboard in the past and it does the job.
Copy to clipboard is a royal pain in the ass because of the security concerns involved.
[QUOTE=swift and shift;33918088]I've used ZeroClipboard in the past and it does the job.
Copy to clipboard is a royal pain in the ass because of the security concerns involved.[/QUOTE]
I can't seem to get it to work :(
Pretty much the only reliable way (if you can call it that) is to do it with Flash. Which is still a pain in the ass, and not really "reliable" either.
I would like some feedback and perhaps even help for a simple index page.
[thumb]http://puu.sh/bFsv[/thumb]
With the grid: [url]http://puu.sh/bFss[/url]
What do you think about the alignment?
The spacing and padding isn't consistent at all.
How would you suggest I make like:
There is small 25x25px image, and once user hovers on image it shows a nice formatted small text? Any tutorial links?
[QUOTE=arleitiss;33922522]How would you suggest I make like:
There is small 25x25px image, and once user hovers on image it shows a nice formatted small text? Any tutorial links?[/QUOTE]
Like a tooltip? I posted a code example of that [url=http://www.facepunch.com/threads/1092866?p=33906201&viewfull=1#post33906201]near the top of this page[/url]. The same idea can also be applied to other kind of on-hover texts.
[php]
CREATE TABLE IF NOT EXISTS `users` ( `id` int(11) NOT NULL auto_increment, `username` varchar(32) NOT NULL, `password` varchar(32) NOT NULL,
`online` int(20) NOT NULL default ‘0', `email` varchar(100) NOT NULL, `active` int(1) NOT NULL default ‘0', `rtime` int(20) NOT NULL default ‘0', PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT
CHARSET=utf8;
[/php]
When I try to run that code in PHPMyAdmin it says that there is a syntax error:
[code]
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '‘0', `email` varchar(100) NOT NULL, `active` int(1) NOT NULL default ‘0', `r' at line 2
[/code]
I don't really understand the error so some help would be appreciated.
[QUOTE=toaster468;33925960][php]
CREATE TABLE IF NOT EXISTS `users` ( `id` int(11) NOT NULL auto_increment, `username` varchar(32) NOT NULL, `password` varchar(32) NOT NULL,
`online` int(20) NOT NULL default ‘0', `email` varchar(100) NOT NULL, `active` int(1) NOT NULL default ‘0', `rtime` int(20) NOT NULL default ‘0', PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT
CHARSET=utf8;
[/php]
When I try to run that code in PHPMyAdmin it says that there is a syntax error:
[code]
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '‘0', `email` varchar(100) NOT NULL, `active` int(1) NOT NULL default ‘0', `r' at line 2
[/code]
I don't really understand the error so some help would be appreciated.[/QUOTE]
[php]CREATE TABLE IF NOT EXISTS `users` ( `id` int(11) NOT NULL auto_increment, `username` varchar(32) NOT NULL, `password` varchar(32) NOT NULL,
`online` int(20) NOT NULL default '0', `email` varchar(100) NOT NULL, `active` int(1) NOT NULL default '0', `rtime` int(20) NOT NULL default '0', PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT
CHARSET=utf8;[/php]
try that
[QUOTE=Ac!dL3ak;33926039][php]CREATE TABLE IF NOT EXISTS `users` ( `id` int(11) NOT NULL auto_increment, `username` varchar(32) NOT NULL, `password` varchar(32) NOT NULL,
`online` int(20) NOT NULL default '0', `email` varchar(100) NOT NULL, `active` int(1) NOT NULL default '0', `rtime` int(20) NOT NULL default '0', PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT
CHARSET=utf8;[/php]
try that[/QUOTE]
Thank you man!
Btw did you change any vars because I am following a tutorial.
Edit:
Wow I'm sill he is using different characters for the quotation marks.
-snip-
What would you suggest using for like website theme? Where user can choose? Based on users choice it loads specific CSS file with changed path to images? Would only PHP work? I mean in HTML head change CSS file name based on users choice?
Also any suggestion on how to make Multi lingual website? Some kind of XML files with translated pages or what?
Not too long ago I finished reading Head First PHP and apart from working on one little personal project I'm always on the lookout for other stuff in PHP to get interested in. ie if I wanted to look at creating an Omegle chatbot where exactly would I look in terms of reading material...? Or what should I experiment with doing as a beginner...?
Thank you, Dragory, it worked!
[QUOTE=arleitiss;33928813]What would you suggest using for like website theme? Where user can choose? Based on users choice it loads specific CSS file with changed path to images? Would only PHP work? I mean in HTML head change CSS file name based on users choice?
[/QUOTE]
Depends on the level of customization you're looking for. Loading a specific CSS file based on the user's choice works great. You can take that a step further by adding a basic theme inheritance system, where you have themes that contain css/js/image files, and a manifest file, sort of like this:
Folder structure:
[php]
themes
- base_theme
images
a.jpg
b.jpg
c.jpg
styles
style.css
manifest.php
- themetwo
images
b.jpg
styles
style.css
manifest.php
[/php]
Now, the manifest files declare what changes that theme applies, and where it inherits from (if at all), so, the manifest.php file for the [b]base_theme[/b] is something like:
[php]
return array(
"extends" => null,
"implements" => array(
"images/a.jpg",
"images/b.jpg",
"images/c.jpg",
"styles/style.css"
)
);
[/php]
While the manifest.php file for [b]themetwo[/b] is something like:
[php]
return array(
"extends" => "base_theme",
"implements" => array(
"images/b.jpg",
"styles/style.css"
)
);
[/php]
And when you want to use a theme asset, have a way to resolve these inheritances. For example, imagining that the active theme is [b]themetwo[/b]:
[php]
<img src="<?= theme_asset('images/b.jpg') ?>" alt="">
[/php]
That would point to themetwo's [b]b.jpg[/b], since you declared it to exist. The following, on the other hand:
[php]
<img src="<?= theme_asset('images/a.jpg'); ?>" alt="">
[/php]
Would point to base_theme's [b]a.jpg[/b] - since it was not declared in themetwo's manifest file, you'd keep looking up the inheritance chain (that means looking at the "extends" field, loading the manifest.php file for that theme) until you hit a match.
This is just a very simple example of the sort of schemes you can come up with, good luck!
[QUOTE=zugu;33931869]Thank you, Dragory, it worked![/QUOTE]
Do the new URLs also have .html after them? Looking back at the code above, $1 should only refer to the (.*) and not the \.html after it. Or did you fix that by yourself already?
[QUOTE=kragmars102;33897824]Trying to remember the name of this huge vector icon pack, something in the lines of moonicons[/QUOTE]
[url]http://www.famfamfam.com/lab/icons/silk/[/url]
??
-snip-
Can anybody help me with this?
[url]http://superuser.com/questions/372386/how-do-i-administer-var-www[/url]
how can I make a page on my tumblr just show posts with a particular tag?
[editline]28th December 2011[/editline]
nevermidn..
Where is the document root of nginx situated? I can't find this piece of information by googling.
[QUOTE=TerabyteS_;33937827]Where is the document root of nginx situated? I can't find this piece of information by googling.[/QUOTE]
Depends, did you compile or install it through a package manager? If the later it will also depend on the distro.
Sorry, you need to Log In to post a reply to this thread.