Web Development Questions That Don't Need Their Own Thread v2
3,079 replies, posted
[QUOTE=deadeye536;32230079]Works just fine on my end;
[php]$sh = $dbh->prepare('SELECT * FROM sometable');
$sh->execute();
print $sh->rowCount();[/php]
Returns 23, the number of rows in the table.[/QUOTE]
Thanks for testing it.
I use query.
[php]
$query = $pdo->query('SELECT pid FROM motorcycles WHERE pid = '. $pid .' AND hidden = 0');
$pidExists = ($query->rowCount() == 1) ? true : false;
[/php]
PID is converted to an int so it's impossible to hijack. At least I think. :v:
I'm no pro.
[QUOTE=jaybuz;32235926]I use query.
[php]
$query = $pdo->query('SELECT pid FROM motorcycles WHERE pid = '. $pid .' AND hidden = 0');
$pidExists = ($query->rowCount() == 1) ? true : false;
[/php]
PID is converted to an int so it's impossible to hijack. At least I think. :v:
I'm no pro.[/QUOTE]
[php]
$query = $pdo->query("SELECT `pid` FROM `motercycles` WHERE `pid` = :pid AND `hidden` = 0");
$query->execute(array("pid" => $pid));
$pidExists = $query->rowCount() == 1) ? true : false;
[/php]
[QUOTE=Ac!dL3ak;32236606][php]
$query = $pdo->query("SELECT `pid` FROM `motercycles` WHERE `pid` = :pid AND `hidden` = 0");
$query->execute(array("pid" => $pid));
$pidExists = $query->rowCount() == 1) ? true : false;
[/php][/QUOTE]Doesn't using query automatically execute it? Don't you need to prepare first?
[QUOTE=TerabyteS_;32236822]Doesn't using query automatically execute it? Don't you need to prepare first?[/QUOTE]
oh yeah sorry i haven't used PDO itself in a while
[php]
$query = $pdo->prepare("SELECT `pid` FROM `motercycles` WHERE `pid` = :pid AND `hidden` = 0");
$query->execute(array("pid" => $pid));
$pidExists = $query->rowCount() == 1) ? true : false;
[/php]
Guys you can't sql inject with numbers, so it cool.
I've had an idea - an internet timezone: stratified by country so that the internet time is closer to the time in countries like the US who use a large proportion of the world's internet, so that it's easier for people to connect on the internet rather than having to convert times from one site into your timezone - you just know how many hours away internet time is, sort of thing
what do you think?
[QUOTE=Alcapwne;32241957]I've had an idea - an internet timezone: stratified by country so that the internet time is closer to the time in countries like the US who use a large proportion of the world's internet, so that it's easier for people to connect on the internet rather than having to convert times from one site into your timezone - you just know how many hours away internet time is, sort of thing
what do you think?[/QUOTE]
so utc?
[QUOTE=Kwaq;32242360]so utc?[/QUOTE]
I didn't know about UTC, but yeah sort of like that but skewed more to suit internet users
Guys, how can I improve this page? I hate it.
[img]http://dl.dropbox.com/u/386727/Web-And-Graphics/speedway-badpage.png[/img]
I know that back button isn't helping but I wanted to keep it similar to this page with placement and style: [url]http://speedwaymotorcycles.co.uk/#/motorcycles/4008/lexmoto-arizona[/url]
Why don't you try styling them in the same way you style the bike purchase pages?
[QUOTE=Sharpshooter;32244997]Why don't you try styling them in the same way you style the bike purchase pages?[/QUOTE]
Well, I guess I could. I just didn't want every page to look the same.
[QUOTE=jaybuz;32246702]Well, I guess I could. I just didn't want every page to look the same.[/QUOTE]Well I think it looks fine, it's pretty commonplace for e-commerce sites to have a standard product page
I've been working on some Javascript just now and I've encountered an annoying problem which probably has a simple answer.
I have a var called [b]result[/b] that I would like to use to return so when I call the function I get True or False but at the moment it's always returning False, even though the google maps directions code is running. Any body know what I'm doing wrong?
[php]
function getLocation(address)
{
var location = (address) ? address : $('#location-input').val();
locationChanged = (address && lastLocation != location) ? true : locationChanged,
result = false;
var request = {
origin: location,
destination: '52.697605, -2.021616',
travelMode: g.DirectionsTravelMode.DRIVING
};
if (locationChanged && lastLocation != location)
{
$('#spinner').fadeIn(200);
directions.route(request, function(response, status)
{
if (status == 'OK')
{
var route = response.routes[0];
addressName = route.legs[0].start_address,
lastLocation = (address) ? location : addressName;
locationChanged = false;
$('#location-input').removeClass('error').val(addressName);
map.setMapTypeId(g.MapTypeId.ROADMAP);
directionsDisplay.setDirections(response);
result = true;
}
else if (status == 'OVER_QUERY_LIMIT') { alert('The server could not be reached, please try again later!'); }
else { $('#location-input').addClass('error'); }
$('#spinner').fadeOut();
});
}
console.log(result);
return result;
}
[/php]
[QUOTE=jaybuz;32247182]I've been working on some Javascript just now and I've encountered an annoying problem which probably has a simple answer.
I have a var called [b]result[/b] that I would like to use to return so when I call the function I get True or False but at the moment it's always returning False, even though the google maps directions code is running. Any body know what I'm doing wrong?
[php]
function getLocation(address)
{
var location = (address) ? address : $('#location-input').val();
locationChanged = (address && lastLocation != location) ? true : locationChanged,
result = false;
var request = {
origin: location,
destination: '52.697605, -2.021616',
travelMode: g.DirectionsTravelMode.DRIVING
};
if (locationChanged && lastLocation != location)
{
$('#spinner').fadeIn(200);
directions.route(request, function(response, status)
{
if (status == 'OK')
{
var route = response.routes[0];
addressName = route.legs[0].start_address,
lastLocation = (address) ? location : addressName;
locationChanged = false;
$('#location-input').removeClass('error').val(addressName);
map.setMapTypeId(g.MapTypeId.ROADMAP);
directionsDisplay.setDirections(response);
result = true;
}
else if (status == 'OVER_QUERY_LIMIT') { alert('The server could not be reached, please try again later!'); }
else { $('#location-input').addClass('error'); }
$('#spinner').fadeOut();
});
}
console.log(result);
return result;
}
[/php][/QUOTE]
OOOH i know
pick me
when you define the callback function for directions.route, it will not be run in the same (scope, i guess?) as where you defined route as false before. Since that route never changes, it will always turn false and the object route off of window might have the actual route information
just a thought
[code]$('li').toggle(function() {
$("#content").animate({height: "180px"},300);
}, function() {
$("#content").animate({height: "100px"},300);
});[/code]
is there a way to unbind the click function after 1 click temporarily, so that it doesnt loop for 10 minutes when you click spam?
Can anyone help me with this little SQL problem;
[img]http://puu.sh/5xaj[/img]
[QUOTE=Kwaq;32252149][code]$('li').toggle(function() {
$("#content").animate({height: "180px"},300);
}, function() {
$("#content").animate({height: "100px"},300);
});[/code]
is there a way to unbind the click function after 1 click temporarily, so that it doesnt loop for 10 minutes when you click spam?[/QUOTE]
[code]
if (!$('#content').is(':animated'))
{
$('li').toggle(function() {
$("#content").animate({height: "180px"},300);
}, function() {
$("#content").stop(true, true).animate({height: "100px"},300);
});
}[/code]
Also notice the stop function in the second function. This stops animations from being qued up and spamming. [url]http://api.jquery.com/stop/[/url]
[QUOTE=Adzter;32252367]Can anyone help me with this little SQL problem;
[img]http://puu.sh/5xaj[/img][/QUOTE]
It looks like you're account doesnt have the privileges?
-snip-
how does the announcements here work? how does it remember that you clicked on close?
[QUOTE=zzlawlzz;32253455]how does the announcements here work? how does it remember that you clicked on close?[/QUOTE]a cookie probably, my guess is it sends one when you haven't clicked close and then deletes it when you click close
[editline]12th September 2011[/editline]
or maybe just a db query
[QUOTE=Octave;32254492]a cookie probably, my guess is it sends one when you haven't clicked close and then deletes it when you click close
[editline]12th September 2011[/editline]
or maybe just a db query[/QUOTE]
Setting an extra cookie on login and then checking if it exists and then show the announcement. Brilliant!
Any of you guys have any experience or tips on converting a custom website to a drupal theme? I despise drupal with most of the fibers in my being, but the company is insisting on using drupal for now. So I have to convert all the work I've done thus far into a drupal theme. Bleh. And drupal isn't cooperating as well as I might have hoped.
[QUOTE=Ac!dL3ak;32247335]OOOH i know
pick me
when you define the callback function for directions.route, it will not be run in the same (scope, i guess?) as where you defined route as false before. Since that route never changes, it will always turn false and the object route off of window might have the actual route information
just a thought[/QUOTE]
Nah, without the var in there, the parser will check every scope for "result", and it will find it in the getLocation scope.
The Chrome developers tools may be useful for identifying the problem; under the Scripts tab, put a breakpoint within the closure to ensure everything is going as expected.
[editline]12th September 2011[/editline]
[QUOTE=Octave;32254492]a cookie probably, my guess is it sends one when you haven't clicked close and then deletes it when you click close
[editline]12th September 2011[/editline]
or maybe just a db query[/QUOTE]
It's probably a database query, it persists across browsers.
[QUOTE=zzlawlzz;32253455]how does the announcements here work? how does it remember that you clicked on close?[/QUOTE]
It's a database query.
What is the CSS to style input boxes? Specifically text and password.
[QUOTE=Notebook;32259695]What is the CSS to style input boxes? Specifically text and password.[/QUOTE]
[css]
input[type=text] {
}
input[type=password] {
}
input[type=submit] {
}
[/css]
[QUOTE=deadeye536;32258550]Nah, without the var in there, the parser will check every scope for "result", and it will find it in the getLocation scope.
The Chrome developers tools may be useful for identifying the problem; under the Scripts tab, put a breakpoint within the closure to ensure everything is going as expected.[/QUOTE]
I don't understand this:
[img]http://dl.dropbox.com/u/386727/Web-And-Graphics/webkit-breakpoint.png[/img]
Sorry, you need to Log In to post a reply to this thread.