Jump to content

Alex

Staff Alumni
  • Posts

    2,467
  • Joined

  • Last visited

Everything posted by Alex

  1. So are you See str_word_count. Learn something new everyday.
  2. $array = Array('Object1', 'Object2'); echo implode(',', $array); // Object1,Object2
  3. If you're not sure what parameters are in your query string you can loop through the $_GET super-global to see. eg. foreach($_GET as $key => $var) { echo "$key => $var"; }
  4. No, my example was to get it from the url, not a blob field. For PFMaBiSmAd's method you'd do this: $id = htmlentities($_GET['id']); if($id != '') { $query = "SELECT location FROM pictures WHERE id='$id'"; $result = mysql_query($query) or die(mysql_error()); if(mysql_num_rows($result) > 0) { $imageData = mysql_fetch_array($result); header('Content-type: image/png'); // Set Content-type header to image/png to output an image readfile($imageData['location']); } }
  5. Yes it does matter. It should match in all 3 locations: The database, the query, and when grabbing the row from the $row array.
  6. There's no need for that. Just make sure that your rows are named exactly 'Duns_num' and 'Fee_percent'. Edit: Just realized in your query it's lower-case, is it all lower-case in the database? If so use this line: echo $row['duns_num']."-".$row['fee_percent']; If it's not all lower-case in your database then just change your query.
  7. You said you're using the $_SESSION variable in a conditional, yet in that code I don't see any of that..
  8. Well that solves your SQL syntax problem. The other issue is because of this line: echo $row['Duns_num']."-".$row['Fee_percent']; Apparently in all the records you fetched the rows (if they even exist) Duns_num and Fee_percent are empty.
  9. Is there any reason you're concatenating strings with other strings? The problem could be because you query looks like this: SELECT sunocoimport.duns_num, custmast.fee_percentFROM sunocoimport, custmastWHERE sunocoimport.duns_num = custmast.duns_num try: $query = "SELECT sunocoimport.duns_num, custmast.fee_percent FROM sunocoimport, custmast WHERE sunocoimport.duns_num = custmast.duns_num";
  10. Can you post your entire code please? It's hard to see what you're trying to do without all the relevant code.
  11. session_start() should be placed at the very top of the page outside of any conditionals. If session_start() is not called you won't be able to access the $_SESSION super-global.
  12. Well in your first post you didn't say what else you need it to you. Maybe you made a mistake? You just said it has to output the number of words in sentence. Checking would be simple, just making sure the form was submitted. if(isset($_POST['Submit'])) { $words = $_POST['Department1']; $arr = explode(' ', $words); echo count($arr); }
  13. First convert $time to a UNIX timestamp using strtotime(). Then add 1 hour and 30 seconds to it, and convert it back to the format you want using date() date('H:i:s', strtotime("13:30:00") + 60*60*1.5);
  14. The problem is with your form, not the arrays. Are you expecting them to enter the sentence in the element named "Department1"? If so then you must change $words = $_POST['sent']; to $words = $_POST['Department1']; You don't need to put "<?=$_POST["sent"]?>" either. <form method='post' action=''> <input type="text" name="Department1" /> <input type='Submit' name='Submit' value="Submit" /> </form> <? $words = $_POST['Department1']; $arr = explode(' ', $words); echo count($arr); ?> Ultimately you should also add checking to make sure that the form was actually submitted using isset()
  15. Since you're using md5 encrpytion when checking your password the script expects that you're storing a m5d hash of the user's password. Since you manually entered 'password', the check will never work. You should put the md5 hash of 'password', which is 5f4dcc3b5aa765d61d8327deb882cf99
  16. You're over complicating things. Do exactly what you said you wanted to do: $words = $_POST['sent']; $arr = explode(' ', $words); // Explode by a space echo count($arr); // Echo out the number.
  17. But you're using && &&, so it means if any of them are false to trigger the else. I thought that's what you wanted: not to display an error if the form hasn't been submitted..
  18. Your problem is that if any of the conditions evaluate to false it'll trigger your error (so say if $_POST['go'] isn't set it'll trigger the error statement). You need to do something like this: eg. if(!isset($_POST['go'])) return; if(!empty($_POST['name']) && preg_match($pattern, $_POST['name'])) { return $this->good; } else { return $this->error; }
  19. For the first time just manually insert a timestamp. And make sure the stored timestamp only updates when the task is run.
  20. There's nothing wrong with that line assuming those are the correct variables. You really need to post the entire section in question.
  21. And as I said before you can completely remove that loop, it's unnecessary.
  22. Can you post the code in context please? In that example implode() isn't being used. And $str isn't even an array unless do_it() takes $str be reference and changes it into an array? I can't really be much of any help unless you post the actual code in question.
  23. For the first problem just use date() to format the timestamp. For the second problem do the same thing but just add 14 days to the timestamp. eg echo date('some format..', $timestamp); echo date('some format..', $timestamp + 60*60*24*7*2);
  24. Are you sure $data is an array?
  25. You're using square brackets where you should be using curly ones in the else statement. There's also no need for a loop, just use in_array() Ex: if(in_array($name, $array)) { echo "Found"; } else { echo "Not Found"; } This can also be shortened to (using the Ternary Operator): echo (in_array($name, $array)) ? 'Found' : 'Not Found'; To post code use [ code ] or [ php ] tags (without the spaces). If you don't know what I'm talking about press quote on my post to see what it looks like.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.