Web Development Questions That Don't Need Their Own Thread v2
3,079 replies, posted
It's not bad, but the blue seems a bit harsh - on my monitor atleast,
How does something have to be defined to be accessible as classname::name inside a PHP class?
[editline]4th July 2011[/editline]
nvm, const
I had a website once.
[QUOTE=KmartSqrl;30897765]Very possible and very easy[/QUOTE]
Does it cost? Cheers for the quick reply.
[QUOTE=Occlusion;30911924]Does it cost? Cheers for the quick reply.[/QUOTE]
I reply quicker and get rated dumb. Right.
But anyway, a .com domain costs only like 10$ a year. And there are cheaper choices too.
[quote]
I'm making a system to save users' IPs into a table along with the last time they posted something. First, I check for an already-existent record of the user's IP with
[code]SELECT lastpost FROM users WHERE ip = '$IP' [/code]
I then check whether the result of that query is empty, and if it is it means that the user's IP is not present and it should be recorded, so I proceed by doing this query:
[code] INSERT INTO users (ip, lastpost) VALUES ('$IP', '$ctime') [/code]
Where $IP is the user's IP fetched using $_SERVER['REMOTE_ADDR'] and $ctime is a time string created using date("Y-m-j H:i:s"). Even though after performing the latter query the data is present into the table, I keep getting the error
[code] SQLSTATE[HY000]: General error [/code]
Which is, by itself, not very helpful. I'd like to understand what I'm doing wrong here. Thanks in advance.
[B]P.S.:[/B] I'll use this question to also ask how I could compare, using a query, the time I have calculated with PHP's date() with the time already present in the table (of type "datetime") to see if the one calculated with date() is greater than the one in the database by at least one minute.[/quote]
halp
[QUOTE=TeratybeS;30912779]halp[/QUOTE]
You need to post the code since that gives nothing away that is wrong
I posted the queries, I guess it's more than enough.
The only relevant code could be [code]$IP = $_SERVER['REMOTE_ADDR'];
$ctime = date("Y-m-j H:i:s");[/code]
Always put the unix timestamp into the database instead of the actual date.
[QUOTE=Crhem van der B;30913874]Always put the unix timestamp into the database instead of the actual date.[/QUOTE]
That's not the problem
[editline]5th July 2011[/editline]
It seems that I'm getting this error whenever I insert something into any table.
[editline]5th July 2011[/editline]
I don't know what to do anymore. I've changed the privileges given to mysql.exe, dropped the table, remade the users, tried inserting into another table.
I keep getting this misleading error whenever I do an insert operation on any table.
[editline]5th July 2011[/editline]
I'm an idiot. A proper idiot. A complete idiot. I spent the entire day chasing this thing when the problem was just that I was trying to fetch data after an insert query. Fuck I feel like shit now
[QUOTE=Skorpy;30912261]But anyway, a .com domain costs only like 10$ a year. And there are cheaper choices too.[/QUOTE]
Sorry i meant to rate winner :'(
I mean say if you have the domain registered to one site, and the hosting on another, does this incur any additional cost?
[QUOTE=Occlusion;30915990]Sorry i meant to rate winner :'(
I mean say if you have the domain registered to one site, and the hosting on another, does this incur any additional cost?[/QUOTE]
shouldnt do, your paying for the domain, where you use it is up to you.
That said there have been some hosts that lock their domains to their own nameservers, but I think thats only when you buy cheap hosting that includes a free domain
[QUOTE=Occlusion;30915990]Sorry i meant to rate winner :'(
I mean say if you have the domain registered to one site, and the hosting on another, does this incur any additional cost?[/QUOTE]
Nope just buy a domain from somewhere such as namecheap and then in your control panel on namecheap put in the nameservers which are usually found in your hosting control panel.
[QUOTE=Rashy;30917331]Nope just buy a domain from somewhere such as namecheap and then in your control panel on namecheap put in the nameservers which are usually found in your hosting control panel.[/QUOTE]
Awesome, thank you.
Why is it that you guys say you should use PDO instead of the generic PHP-MySQL functions?
Impossible to do sql injection. Can't think of a better reason.
I can't get two simple links under a picture, and if I get it "under' it ends up going to the right, how could I do this?
[img]http://img811.imageshack.us/img811/3205/unled3tp.png[/img]
Section of what I have right now.
[code]
<p><a href="steam://friends/add/76561198022615177">Directly Add Me</a> <a href="http://steamcommunity.com/id/flakthemighty">View My Profile</a>
<img src="images/left_photo.png" width="203" height="99" alt="Add me on Steam" class="left" />
<h2><img src="images/title_welcome.gif" width="139" height="20" alt="News" /></h2>
<div class="indent">
<font size="5"><p>Just waiting for the DNS server to work.</p></font>[/code]
[QUOTE=Richy19;30918734]Why is it that you guys say you should use PDO instead of the generic PHP-MySQL functions?[/QUOTE]
1. Protects against SQL injection and other nasties through proper and safe parametrization, in a clean format.
2. Provides an engine-agnostic interface with support for [URL="http://www.php.net/manual/en/pdo.drivers.php"]a pretty solid range of drivers[/URL] (it is [B]NOT[/B] an abstraction layer, however).
3. Object-oriented and modern, instead of faffing about in the global space like a derp.
4. Other cool points, like compiling and therefore speeding up multiple queries in certain scenarios.
[QUOTE=FlakTheMighty;30925493]I can't get two simple links under a picture, and if I get it "under' it ends up going to the right, how could I do this?
[img]http://img811.imageshack.us/img811/3205/unled3tp.png[/img]
Section of what I have right now.
[code]
<p><a href="steam://friends/add/76561198022615177">Directly Add Me</a> <a href="http://steamcommunity.com/id/flakthemighty">View My Profile</a>
<img src="images/left_photo.png" width="203" height="99" alt="Add me on Steam" class="left" />
<h2><img src="images/title_welcome.gif" width="139" height="20" alt="News" /></h2>
<div class="indent">
<font size="5"><p>Just waiting for the DNS server to work.</p></font>[/code][/QUOTE]
oh, uhm you never ended your div. and where is your css?
use [url]http://jsfiddle.net/[/url]
[editline]5th July 2011[/editline]
don't be scared to pull up the whole code.
[editline]5th July 2011[/editline]
v:v:v
[QUOTE=zzlawlzz;30925974]oh, uhm you never ended your div. and where is your css?
use [url]http://jsfiddle.net/[/url]
[editline]5th July 2011[/editline]
don't be scared to pull up the whole code.
[editline]5th July 2011[/editline]
v:v:v[/QUOTE]
CSS is a different file, it works and keeps my code nice and clean and the div is ended farther down.
[QUOTE=FlakTheMighty;30926033]CSS is a different file, it works and keeps my code nice and clean and the div is ended farther down.[/QUOTE]
We're not all just learning web dev. I meant why didn't you post your css file?
[QUOTE=zzlawlzz;30925974]oh, uhm you never ended your div. and where is your css?
use [url]http://jsfiddle.net/[/url]
[editline]5th July 2011[/editline]
don't be scared to pull up the whole code.
[editline]5th July 2011[/editline]
v:v:v[/QUOTE]
[url]http://jsfiddle.net/mPSDG/[/url]
And there are a bunch of images in there, they're saved to the machine though.
[editline]5th July 2011[/editline]
[QUOTE=zzlawlzz;30926096]We're not all just learning web dev. I meant why didn't you post your css file?[/QUOTE]
Ah, I have no idea.
How can I use MySQL to select an entry and the direct next and previous ones? I ask because I have a table where entries are identified by id, but some might be missing: just using the entry's number +1 won't work.
OK so I'm redoing the homepage now, I didn't like how it was, but I can't center the Steam Card picture, is there a different tag for centering pictures or do they just not center?
[code] <!--It centers the links, but not the image-->
<center> <p></p><p><a href="steam://friends/add/76561198022615177">Directly Add Me</a> <a href="http://steamcommunity.com/id/flakthemighty">View My Profile</a></p></center>
<div align="center"> <img src="images/left_photo.png" width="203" height="99" alt="Add me on Steam" class="left" /> </div>[/code]
[url]http://98.162.213.251:81/[/url] is what I'm talking about.
Nevermind, it fixed itself somehow.
[QUOTE=TeratybeS;30928197]How can I use MySQL to select an entry and the direct next and previous ones? I ask because I have a table where entries are identified by id, but some might be missing: just using the entry's number +1 won't work.[/QUOTE]
WHERE id > 123 LIMIT 1
My query looks something like this right now
SELECT id, body, upvotes, downvotes FROM suggestions WHERE id = :id
I understand what you mean, but using multiple limits won't work
[editline]6th July 2011[/editline]
Maybe I'm just doing it wrong though
[editline]6th July 2011[/editline]
SELECT id, body, upvotes, downvotes FROM suggestions WHERE id = 22 OR id < 22 OR id > 22 LIMIT 3
This doesn't work. Selects the following two, not the previous one.
just an idea, I think that you should haev a seperate votes table that has suggestion_id, user_id and up_down, that way you can track who votes for what. the way you have it now is a calculated field which is poor database design.
[QUOTE=H4Z3Y;30935813]just an idea, I think that you should haev a seperate votes table that has suggestion_id, user_id and up_down, that way you can track who votes for what. the way you have it now is a calculated field which is poor database design.[/QUOTE]
I already have a lookup table that links users and entries they voted for
Sorry, you need to Log In to post a reply to this thread.