-
Posts
6,906 -
Joined
-
Last visited
-
Days Won
99
Everything posted by ginerjm
-
I'll never understand why people use sprint(f) to build a query string.
-
The point is that you DON"T post the entire code. You do your own debugging and when you can't solve the problem you post the PART of the code that you believe is the cause of your problem. Since you know your code this should not be a huge problem. Of course, if you didn't write the code.....
-
Could we possibly see a complete piece of code that shows how you build the contents of the call to mail, followed by (hopefully) the mail call? So much easier to debug the code as it was written and not in pieces that you feel like posting.
-
That error indicates you either did not establish a connection to your database
-
Show us how you are doing the two unlinks. Are you getting an error message from the failed delete? Do you have php error checking on?
-
which php error checking would have told you. See my signature.
-
So? Define $email. Next time - please post your code properly. And when you have a line you want looked at - POINT IT OUT!
- 6 replies
-
- file upload
- file
-
(and 3 more)
Tagged with:
-
You want us to look at code that you can't even post here? I think you need to do some debugging and find out where that color and read-only is being triggered. That will be your first hint at where the problem is.
-
Pretty sketchy question here. What does the anchor tag do for you exactly? Not much as written. Is that your question? I mean - you posted 3 lines of code and asked about it but didn't state which line you wanted our opinion on. Really - try to be more specific next time.
-
Contact Form + Validator: Have to Click "Submit" Button Twice
ginerjm replied to fadedrunes's topic in PHP Coding Help
If you remove the validator setup lines, does the form work properly? If so, you might want to ask on a JS forum -
It would be easier to follow your code if we saw it sequentially. Question - you say that num_rows "returns 1 row". Doesn't it return a value of 1 instead?
-
I agree with everything you said. 1 - PLEASE read the rules of the forum and afterward you will know how to post your code here correctly. 2 - PLEASE make your code more readable. If you wrote this - please re-structure it so it reads like code and a book. If you didn't write it perhaps that is your problem.
-
What is a custom field? The html image tag (<img>) has attributes for setting the size of the display. Read up on its usage.
-
PHP variables do not get interpreted when not wrapped in double quotes. So the post var you are checking in the loop is 'hashtag$i' which (if you had error checking turned on ) would give you an error message itself. If you use double quotes then you would check 'hashtag1', 'hashtag2' , etc.
-
You didn't post any code. You didn't tell us what is wrong. Show us any error message you get and isolate your (soon to be) posted code to the area of the message and give us a chance to help you.
-
Ok - I took your code verbatim and cleaned it up to read it. Basically it's the same - BUT with error checking on. <?php session_start(); error_reporting(E_ALL | E_NOTICE); ini_set('display_errors', '1'); // $years = array(); //Build the years array, we can only go forward 3 years, backwards 1 year. $sYear = date(Y, strtotime('-1 years')); //Start Year LINE 7 $eYear = date(Y, strtotime('+3 years')); //End Year LINE 8 while($sYear < $eYear) { array_push($years, $sYear); //Add each year that fits to the array $sYear++; } echo "<pre>",print_r($years,true),"</pre>"; //In order for us to make sure we have clean parameters for our jQuery calls later //We have to make sure that our year variable usage is consistant throughout. //If our case, we are passing the full 4 digit year as am INT = $curYear //$curYear = clean($_GET['curYear']); $curYear = $_GET['curYear']; print "Before anything: curYear = $curYear <br><br><br>"; if($curYear == "" || $curYear == null) { //No Year set, use current print "empty or null<br>"; exit; //THIS ENDS THE SCRIPT RIGHT HERE!! $curYear = date(Y); } elseif(!is_numeric($curYear)) { //Not even a number lol print "not number<br>"; $curYear = date(Y); } elseif($aSearch = in_array($curYear, $years, true)) { print "valid year<br>" . $years[$aSearch]; } else { //It isn't in our array of valid years //$curYear = date(Y); //all else failed $curYear = date(Y); print "Failed all tests.<br>"; } //Should be a good year for our calendar by this point. exit; The errors I get are: Notice: Use of undefined constant Y - assumed 'Y' in /home/albany/public_html/homejg/test.php on line 7 Notice: Use of undefined constant Y - assumed 'Y' in /home/albany/public_html/homejg/test.php on line 8 I have marked the lines above. You really need to remember to quote your strings. Other than that though I do get a valid answer from the script during testing.
-
Simple script to show written text on different page
ginerjm replied to Radim's topic in PHP Coding Help
If you are really looking to learn (as gristol suggests) you want to think about these things: 1 - learn how to create a simple 'hello world' web page that every tutorial or book makes you do to start php. 2 - expand on that to develop an html form on that web page that can accept some input string from the user/client. 3 - write a form-processing script that the html form calls (action=???) and sends its data to via $_POST. (Read up on $_GET and $_POST in your book or the PHP manual, listed at the top of this forum) 4 - in this form handling script get the text that was typed into a form field and create a new output page where you display that text. Be sure to read up on how to safely sanitize input from the user/client before displaying it on the client again. -
Can you write your own code to do what? To manage a client's shopping - sure. No problem. Create a db, add some tables, organize your data and write screens to log them in, build product dropdowns and selections and quantity capturing and then create a shopping list. All that is easily controlled by you and your clients. It's the connection to a market that is the difficult part. You have to have a way in to their systems (legal) so that you can grab the info you desire. Maybe you want the current price list. Maybe you want to organize your client's shopping list by aisle number or something which you will have to get from each market's system. That is the hard part - trying to talk to somebody else's body of work. Are you ready for that? Even if you limit the client's shopping to a specific store you would still have to record prices so that you can re-use them the next time they select those items. You could also record the aisle number from the user's input as they check the items off their list on their smartphone inside the store. All that would be doable. But what do you do when the price changes, or when they re-locate items? It's all doable but at what cost to you?
-
Can't speak for the use of the pregmatch since I don't use it, but the second If statement I can. You do realize that that statement doesn't account for case? If the input is BLUE, then you are not going to match on it. I would suggest creating an array of your colors using uppercase values and then take your argument and do this: $colors = array('BLUE','GREEN','RED','YELLOW'); if ( in_array(strtoupper($mycolor), $colors)) echo "color found"; else echo "color NOT found"; Of course someone may coach you on your pregmatch and fix your problem, but the above will work too. PS your if statement also makes a common logical mistake. You need to check for AND, not OR, besides checking the case. (Go with the code I gave you - much less writing.)
-
It's not so much to learn - that pdo. It still boils down to writing the proper query statement and then just using a different set of function calls to execute that query and retrieve the results. Using a prepared query: $q = "select stuff from table where blah='$value1' and moreblah='$value2'"; $qresults = MySQL_query($q); while($row = MySQL_fetch_assoc($qresults) { handle results } becomes $q = "select stuff from table where blah=:val1 and moreblah=:val2"; $qst = $pdo->prepare($q); $parms = array('val1'=>$value1,'val2'=>$value2); $qst->execute($parms) while($row = $qst->fetch(PDO::FETCH_ASSOC)) { handle results } See? Not much different but lots more safety and security. Note: you don't have to do anything to "prep" the vars being used in the query. That is done by the call to 'prepare'. Simply check your inputs for valid data (numbers where numbers are expected, etc.). No need to addslashes or anything else.
-
And that assumes that the particular supermarket has an agreement with the producers of that widget to provide their product list and prices in a useable format. You on the other hand would have to id your products for you clients and then map those ids to each supermarkets ids
-
Problem with Function using mysqli_real_escape_string()
ginerjm replied to n1concepts's topic in PHP Coding Help
Deprecated. Deprecated! -
It is difficult to follow you here. Now it appears that you use main.php to create a page that has a js function that will call sendmessage when activated by the user's actions. So if you truly want sendmessage to return some results to your currently displayed page, then you simply echo that data back to the ajax caller. That's how stuff is sent back. I believe that it can be secured somewhat if you use php to json encode it before sendmessage echos it out and then use the receiving js function (the ajax caller) to un-enccde it. Simply encode your values and echo them back at the end of sendmessage. Or am I reading you wrong again?
- 14 replies
-
- php
- javascript
-
(and 2 more)
Tagged with:
-
Use your array like this: array('value1'=>color1,'value2'=>color2,'value3'=>color2); Use it like this: - determine the condition value - retrieve array value with that condition with: $color = array['condition-value']
-
It seems that you are using both POST and GET args here. If you are letting the user enter an id into a form field that has method='POST', then your url is not going to have a thread_id=xxx in it anymore.