-
Posts
1,662 -
Joined
-
Last visited
-
Days Won
52
Posts posted by maxxd
-
-
You're mixing and matching SQL approaches. Replace this bit:
$sql = "INSERT INTO workorder (name, date, installer, salesman, category, status) values('$id', ?, ?, ?, ?, ?);"; $q = $pdo->prepare($sql); $q->execute(array($date,$installer,$salesman,$category,$status));
with this:
$sql = "INSERT INTO workorder (name, date, installer, salesman, category, status) values(?, ?, ?, ?, ?, ?);"; $q = $pdo->prepare($sql); $q->execute(array($id,$date,$installer,$salesman,$category,$status));
And it should work.
As an aside, why are you checking the id value in _GET and then assigning it from _REQUEST? If somehow there's an 'id' index in both _GET and _POST, one of them is going to overwrite the other. If the value is set in _GET, pull it from _GET.
-
You can shorten it a bit like so:
<?php if( is_single() || is_home() || is_page() ): ?> <div class='container'></div> <?php endif; ?>
Or you can just put the div in the template pages controlling those particular pages. I think (off the top of my head, so check the template hierarchy on the WordPress site), you'd be looking at index.php for the blog (home) page, single.php or page.php for the other two. I haven't had my second cup of coffee yet and just logged on at work, so I may be mistaken about which files you'll need to target.
-
If you Google 'javascript password strength meter' you'll find several things already in development. I've not used any of them, but this one looks like it could work well...
-
http://php.net/manual/en/class.datetimezone.php
That's not to say it's easy to deal with time zones - in my experience, it's kind of a massive pain in the butt. However, using DateTime and DateTimezone objects does make it a better experience.
-
Okay the error's gone now
It shouldn't be - I still don't see where you're defining $storeID in getProductList(). Unless the code has changed, you should still be getting the undefined variable error.
-
This is untested, but should work:
$parms = array( array( ':id', $idnr, PDO::PARAM_INT ), array( ':name', $name1, PDO::PARAM_STR ) );
Of course, whether it's actually shorter or not is up for debate....
-
It sounds like you're looking for information on AJAX. You can send information from JavaScript to php, process it on the server side in php, and return data to your client-side JavaScript. Here's information on using JQuery - it makes AJAX calls easier to deal with.
-
1
-
-
PDO is a full API that integrates and abstracts several different database connection types into a unified and standard interface. While it's not technically a framework, and I'm sure many here would disagree with my statement, it's kind of close to a framework in itself - well, in a way that makes sense to me anyway, so there you go.
If you're looking for something a bit more abstracted with more convenience methods, bells, and whistles, you might want to check out the Doctrine Project DBAL classes.
-
Just one more thing needed for this - on the page where I am inserting the post data into the mysql database (data from the form posted to this page), I want to add auto increment to $_POST['option'] so its option0, option1, option 2 etc. How can I add the auto increment to this?
Make the text input name an array. That way you can simply loop through the values in your php script. Like so:
//in the form itself for ($i=0;$i<$lim;$i++){ print("<input type='text' name='custUrserInput[]' id='{$i}' />"); } //processing script foreach($_POST['custUrserInput'] as $userValue){ print("<p>\$_POST['custUrserInput'][] is {$userInput}</p>"); }
This way, in your processing script, you don't need to know how many fields the user has added. Just loop through the number that are there and process them individually.
-
-
In Profile::make_array(), you're calling $database_profile->run_query(), not $this->data_profile->run_query().
-
You need to convert the minutes into a decimal value. For instance, 14 hours, 30 minutes equates to 14.5 * 15 = 217.50.
-
Dang - I got size and maxlength confused. NewDLR, if you're trying to set the width of the field, do as requinix suggested and use CSS.
-
Barand, that's what I was thinking with that solution - if you add additional keys to the unique constraint (phone number, for example), the script will handle it automatically.
Either way, glad you got your solution Landslyde!
-
If you're setting a max of 45, the field is only going to have at most 2 digits in it. Why try to allow 3 when 2 is going to happen? If you're worried about browsers that don't support a number form field, add that check to your javascript validation when the form is submitted.
-
Your log out link goes to logout.php, but you've only shown us the code for index.php. The problem would be in the logout.php script (as that's where the browser is going once the link is clicked), so show us that code as well.
-
This may not be the most efficient solution, but it worked in the couple easy tests I just ran on it:
$err = "SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'cowboy@dfwit.co' for key 'username'' in /var/www/html/dfwit/register.php:36 Stack trace: #0 /var/www/html/dfwit/register.php(36): PDOStatement->execute(Array) #1 {main}"; $colMarkStart = "' for key '"; $colMarkEnd = "' in /var/"; $startKey = strpos($err, $colMarkStart) + strlen($colMarkStart); //the first occurrence of the first character in the search string plus the length of the search string $endKey = (strpos($err, $colMarkEnd) - 1) - $startKey; //-1 from the end string position to account for the end quote, then subtract the starting position to get the desired span of characters $column = substr($err, $startKey, $endKey); //pull that span of characters from the error string print("<p>Duplicate column : {$column}</p>");
-
Actually, the scenario you're concerned about is exactly what SQL is designed to do, and it does it very quickly. Because you're indexing everything by user ID, that's the only column that needs to be scanned. Of course, speed of transactions can slow down, but that's usually due to bad programming - for instance, selecting every column in a row when only 1 is needed.
Read up on database normalization - a good article or three should shed some light on the situation and why working as you've proposed is actually far more wasteful than working the way you're concerned about working...
-
The image is scaling - what results are you expecting to see? You've got a set pixel width on your header and footer elements that need to be either turned into a percentage width or adjusted manually with media queries.
-
1
-
-
If you format and re-read your code, I think you'll see what the issue is.
There are only 2 ways I can see that you're not going to be redirected to ./continue.php - if there's nothing in $_POST['username'], $_POST['email'], and $_POST['p'], or if your e-mail is invalid. You don't have an else clause for any of your prepare() statement checks, so the code skips those parts. Nothing is assigned to $error_msg so, when you check the value of $error_msg, it's empty, and you create a password hash only to fail (and therefor skip) the third prepare statement without an else clause, and lickety-split you're being redirected to ./continue.php.
Try adding
else{ $error_msg = 'Yup. Failed a prepare'; }
after the closing brace of both the
if ($stmt) { ... }
segments, and the
if ($insert_stmt = $mysqli->prepare("INSERT INTO members (username, email, password) VALUES (?, ?, ?)")) { ... }
segment of code and see what happens. I'm not saying that exactly this is happening, it just looks to me like the most likely possibility.
-
Wait, now it sounds like the problem isn't in the code that writes the ID into the header location string, but in the receiving page?
Show us the code you're working on. Without seeing the code that's not working and having a detailed and complete description of what 'working' means in the context of the code and project, folks here are stabbing blindly in the dark and can't help, even though they may want to.
-
Before solving the javascript challenge I need to get my result into a useable format.
Each row has three cols and I need each row with the three cols for example and with vars.
$co-ordinate 1=['KT17', 51.34, -0.24, 4], $co-ordinate 2=['KT18', 51.31, -0.26, 5] $co-ordinate 3 =['KT19', 51.35, -0.26, 5]
$co-ordinate 1=['$postcode1', $lat1, $long1, 4],etc $co-ordinate 2=['$postcode2', 51.31, -0.26, 5] $co-ordinate 3 =['KT19', 51.35, -0.26, 5]
So my problem is how to get to that from this,
Any help appreciated.
$i=0; while($row = mysql_fetch_assoc($result)) { $postcode[$i] = $row['postcode']; $latitude[$i] = $row['latitude']; $longitude[$i]= $row['longitude']; $i++; echo $poatcode[$i] .'<br/>'; echo$latitude[$i] .'<br/>'; echo $longitude[$i] .'<br/>'; }
Are you having difficulties with php output for screen or php output for JavaScript?
-
If you use AJAX to load the page content the lag time shouldn't be too bad depending on the amount and type of content. Obviously if you're loading 1006 large images per page, that's going to drag your page load no matter how you navigate through it. You will have to crack into the History API to enable bookmarking and browser navigation. Also, depending on how you set everything up, you may need to build in additional checks at initial page load to make sure you're loading the proper content in case the user is navigating to a page on your site that's not your home page. For instance, if they've bookmarked a specific page and then use that bookmark next time. The only other thing I'd recommend considering early in your dev cycle is whether and how to handle non-JavaScript browsers. If a user has JS turned off, that could seriously affect the display and functionality of your site. Whether it's worth it to enact a back-up methodology or not is obviously up to you, but it's better to think about at the beginning than the end of things...
-
If I'm understanding your question properly, in WordPress you'll want to take a look at the register_script(), localize_script(), and enqueue_script() functions fired from the wp_enqueue_scripts action hook.
function enqueueStuff(){ wp_register_script('script_id',$this->getPluginDirectory()."/js/yourJSFile.js"); wp_localize_script('script_id','script_data',array( 'postCode'=>$this->getPostCode(), 'latitude'=>$this->getLatitude(), 'longitude'=>$this->getLongitude() )); wp_enqueue_script('script_id'); } add_action('wp_enqueue_scripts','enqueueStuff');
Of course, the pathing to your JavaScript file and the methods getting the post code, latitude, and longitude will be different for you - these are random stubs, but that's the basic idea of it.
Cannot insert $id into php pdo array
in PHP Coding Help
Posted
I think I see what you're saying now. *I think*.
So, you're saying the initial two blocks of code in your original post are on the page with the form output, and the third block of code is on the processing page (the value of the form action property), correct?
My question is, where in the script are $date, $installer, $salesman, $category, and $status set and how? Are the values passed from the form via _POST or _GET? The id value should be in there, assuming it's in the form somewhere (this is usually done with a hidden field in the form itself or pulled directly from a session variable).
Perhaps it would help if you posted a bit more code, like the form itself and the code before the "if($valid){" line.