hansford
Members-
Posts
562 -
Joined
-
Last visited
-
Days Won
4
Everything posted by hansford
-
Well, he obviously isn't familiar with PDO and so the code would make no sense to him. He is just trying to grasp basic principles at this point and see some results. I believe we would have all gave up on programming years ago if we didn't see some results for our efforts, ever how poorly constructed etc. they were.
-
sql is works in phpmyadmin but not working in php with special case
hansford replied to gratsami's topic in PHP Coding Help
I don't rely on rowcount() because it can be hit or miss depending on your database. It takes two queries, but at least you know if something was actually returned or not. The first query you get the count. SELECT COUNT(*) After executing this query you can use fetchColumn() to see if any results were returned. If so, then you can execute your regular query. -
The code you posted is missing key steps if you're trying to do an UPDATE operation in the database. As it is now, it will never work, has SQL errors and security issues. No where in this section of code do we see that you actually perform an UPDATE operation on the database. You incorrectly write an UPDATE statement and store it in a variable and that's it. ...And, what if more than one user has the same password? Not a good way to distinguish between users. Go by their username and password. Two users shouldn't be allowed to have the same username. $update = "UPDATE password FROM $tbl_name WHERE pass='$newp'"; if($update) { echo " ".$row['username']." password has been reset! "; } else { die("Error"); } Create the SQL statement and perform the UPDATE operation on the database. $update = "UPDATE $tbl_name SET password = '$newp' WHERE username = '$username'"; $result = mysql_query( $update ); if( $result ) { echo "success!" }
-
Need some directions creating a multi-user site
hansford replied to Idefix99's topic in PHP Coding Help
After your users register and the information is stored in the database, when a user attempts to log-in, your code will try to match the username and password with the log-in information they provided. If they match, the user gets access. If they don't then they will get a message stating that the "Username and/or Password are not valid". Never clue them in as to which was incorrect. You will also need to store a "salt" in the database. This will be some hash that you will add to the users password. Read up on "Salting passwords". You will have to get familiar with sessions and cookies so you can keep track of your guests as they move around in your site while they are logged in. Maybe someone can chime in here with some additional advice and point you to a good tutorial to get you started. You will learn a lot while creating a robust and secure log-in system. -
What does that mean - that it can't use a dynamic language? The web is static - a page is requested and the server fills that request and could care less about validation or anything else. However, along with the page, they also send headers which attach information about the request, including POST or GET data. But that information has to be processed in order to gain any benefit. So, without some dynamic language coming to the rescue, I am unaware of how that would be accomplished.
-
What happens if two people submit at the same time?
hansford replied to greenace92's topic in PHP Coding Help
It's ok to post questions to forums when you've exhausted doing searches concerning a question and just can't find the answer. However, probably 98% of the time someone already asked the question or a similar one and the solution can be located by sifting through a simple Google search. You find the answer faster and can get back to actually productively coding. -
Build up your form inputs in your loop, but at the end, you need to appendTo('form'). Use Firebug or Chrome and then see if they are getting attached as expected. You don't appear to be attaching anything to the actual form.
-
Object of class mysqli_result could not be converted to int
hansford replied to bravo14's topic in PHP Coding Help
Without correct parenthesis, you're code is being in interpreted as trying to cast the result set to an integer. -
I don't even fully understand the question of what you/they are wanting. You have a main array and within the array you have other arrays. So, array[0] = a key/value paired array. to access you would do: array[0]['name']; array['options'] = an empty array. array[0]['options'][0] = first element of empty array. You can determine how to access subsequent arrays and their values by determining if the array is an indexed array or a key/value array.
-
Data is not inserted to database after submit
hansford replied to osherdo's topic in PHP Coding Help
Everything needs to match up, from the form element names for your $_POST array to the variable names you declare and assign to that $_POST['name']. You declare variables of $lastname, $firstname and then use $lname and $fname to put them in the database. Check everything and echo the values to the screen before you try to insert them into the database to make sure they all match up. -
When you hit enter you are submitting the form. There is apparently no validation code, client side, that would prevent this. You need some client side validation code that would prevent the form from submitting to the server until all required fields have been filled out. If, for some reason, client side validation is not possible, then when the form reaches the server side script, you need to do your validation there. If all required fields are not filled out, you need to fill in a template page with the submitted data that was filled in and echo that same form to the screen. In the template, you can use CSS and empty DIVS to let the user know that not all of the required fields have been filled out. Maybe others can point you to a good tutorial/example on how to best accomplish this task.
-
I haven't had the "pleasure" of running into this problem because I only run on Linux. However, the question intrigued me and I did some digging and found some other people who had similar experiences. It seems that PHP running on Windows has an empty: $_SERVER[REQUEST_URI] Here is one article with a workaround. http://davidwalsh.name/iis-php-server-request_uri You can try it and see if it's something you can work with. There is a solution, maybe not this one, but there is a one out there.
-
You can either hire a freelance PHP programmer - this is not the forum to do that - or you can try and tackle it yourself using a Search to look up basic IF/ELSE clauses and how to use them. Who knows, you might enjoy what you learn and you'll save some money.
-
Query in php not working for Danish characters
hansford replied to shmideo's topic in PHP Coding Help
Instead of repeating this information, as this issue has come up many times before, here is a link to the answer. http://stackoverflow.com/questions/19546792/php-mysql-foreign-characters -
Email report -I have the report but I don't know where to start
hansford replied to kat35601's topic in PHP Coding Help
If you want a PHP solution, you can look into Phpmailer. Github: https://github.com/PHPMailer/PHPMailer Sourceforge: http://sourceforge.net/projects/phpmailer/ You already have the data in variables. Create a nice formatted test html document with dummy vars. Then fill in that with variable data along with Phpmailer to email it in html format. Phpmailer will also allow you to attach files, in case you want to create your own document and just attach the report with or without fancy formatting. -
The page load time is per user, the size (in kb, mb) of the images loading on the page, and the individual users connection speed (download). So, forget about multiplying across many users. That would only have a substantial impact if the server was overloaded or the page requires heavy script processing time - which means you have other problems. Anyways, you can preload images in Javascript or jQuery to have smooth scrolling of many images without problems. WOW Slider is very popular. Click on the carousel demo and then move the mouse over it. The animation will stop until you mouseout and then continue. http://wowslider.com/best-jquery-slider-crystal-linear-demo.html
-
Here is a step-by-step tutorial: "Building a jQuery/PHP Powered Chat Room" http://css-tricks.com/jquery-php-chat/ Start with the basics and then when you have some working code, narrow down into a single question that is not overwhelming to tackle.
-
Use a loop to go through the $_FILES array. for($i = 0; $i < count($_FILES['resume_path']['tmp_name']); $i++) { //your code here }
-
PHP and MySQL: Displaying something within a table
hansford replied to mstevens's topic in PHP Coding Help
You need to quote your fields when pulling from the database. $Row['proverb'] Also, you might want to use htmlspecialchars() when displaying your data as html. -
I don't know whether you just pasted without it or it was never there. But you are missing a closing tag. </soapenv:Envelope
-
Instead of using a GET request and having the information in the url, you can do a POST request using a hidden form field. <form name="myform" action="http://www.microprocessor.ddns.net" method="post"> <input type="hidden" name="update" value="1"> <input type="submit" value="submit"> </form> if( !empty($_POST["update"]) ) { $hidden = $_POST["update"]; }
-
First thing I would check is the action attribute of the form, what url is the form submitting to and is it a valid address of a script. The function that loads the form will by default use the base url you set up to use Codeigniter.
-
Trying to use variables from another file out of memory
hansford replied to Andrew789123's topic in PHP Coding Help
Here is where that code came from: http://subinsb.com/php-logsys Make sure you have followed along with the "rules" to successfully incorporate the code. I go along with the idea that the reason you are getting a memory error is because the script is getting stuck and exhausted at some point. I would do some var_dumps or echos at various points of script execution to narrow down where the problem is. -
I was going to include the lookahead, but it doesn't appear you need it. I'll let others weigh in on this, but this is all you need from what I'm seeing. $pattern = '/\[code\](.)+\[\/code\]/i';
-
You are attempting to iterate over an object like an array. $postArray is returned as an array of "nlEmails" objects. To get the id and email properties of each "nlEmails" object: foreach ($email as $newEmail) { $addEmail = $newEmail->email; $mail->AddAddress($addEmail); $DBH = null; }