Jump to content

niche

Members
  • Content Count

    3,459
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by niche

  1. Try wrapping this in an if statement that tests for string length: $var = 7; echo sprintf('%02d', $var);
  2. https://www.w3schools.com/sql/sql_update.asp Just substitute col name for value.
  3. niche

    Upload image code example

    Is your question about how to "tuck a $_SESSION"?
  4. Where's it breaking and what error messages are you getting?
  5. Depends on what you want to do and how you want to do it.. Coding is a Superpower. Don't take my word for it. Take Drew Houston's word for it. He's the co creator of dropbox. https://www.youtube.com/watch?v=nKIu9yen5nc Listen to his quote at the 00:04:50 mark (approximately). How much time should someone spend to get a Superpower?
  6. Sure! https://www.w3schools.com/sql/sql_count_avg_sum.asp
  7. Don't understand your question
  8. Check $row["StoryHeadline"] instead of row["StoryHeadline"] 
  9. Looks to me like 'r' is being returned by your query. Please post your query.
  10. What's actually in your results array when you dump it?
  11. Query your table to initialize values then do your nested if statement.
  12. Looks like ID 1 is the ID that has the same a/b values. How does ID 4 & 5 qualify?
  13. Not badly designed (yet). Bad approach! Many thanks to the fox and Funce. Found this link and learned more about PDO investigating PDO rules. https://stackoverflow.com/questions/9250434/pdo-quote-method
  14. Thought I could alter a table with a pdo query and binding. Apparently not. Is there a way to use a pdo query to alter a table without binding using some kind of variable? if so, what would a simple example look like? Else, I'll use mysqli.
  15. JSG said it best. $con doesn't exist. Obviously, the site's not making the connection. For me, that was the whole point of learning how to code. How do I manage the use of frameworks and libraries, when I know I don't have the code skills that would've allowed me to do it myself. https://www.w3schools.com/php/php_mysql_connect.asp I'm not criticizing any one. Just talking for myself. IMHO, frameworks and libraries are the rewards for knowing how to code. EDIT: If needed, there are very good vids on youtube RE: PHP Objects
  16. I'd start with resolving the first error. Looks like there's a problem with your login to your server EDIT: start with config.php does it produce errors by itself?
  17. Voila! Thanks for your help.
  18. Interesting. When I strip-out all the white space it works: $stmt2->execute(array(':itemandsize' => '%' . $var . '%')); I've heard of white space being a problem, but haven't knowingly experienced it. Any thoughts? Urban legend?
  19. This code works, but can someone tell me how I can use an array instead of bindParam in this situation. try { $sql = ' SELECT * FROM nconnectz WHERE itemandsize LIKE :itemandsize AND price > 0 ORDER BY price ASC '; $stmt2 = $db2->prepare($sql); } catch (PDOException $e) { echo $e->getMessage() . '<br>'; } $var = "%Flour%"; try { $stmt2->bindParam(':itemandsize',$var); $stmt2->execute(); } catch (PDOException $e) { echo $e->getMessage() . '<br>'; } Something like? $stmt2->execute(array( :itemandsize => '%Flour%' ));
  20. http://php.net/manual/en/language.variables.variable.php (3rd example).
  21. found the notation: ${$wkvar}[$i] = $val; If this has a name, pls let me know so I can get a ref? stumbled on to by finally googling: "dynamic naming arrays php"
  22. This works: $names = array( array("name"=>"tom","gender"=>"m"), array("name"=>"jane","gender"=>"f"), array("name"=>"steve","gender"=>"m"), array("name"=>"mary","gender"=>"f"), array("name"=>"renae","gender"=>"f") ); $num = 30; $wkvar = 'wk' . $num; foreach ($names AS $val) { $wk30[] = $val; //$$wkvar[] = $val; } var_dump($wk30); this doesn’t and gives me this error, “Fatal error: Cannot use [] for reading”, (goggle hasn’t helped me): $names = array( array("name"=>"tom","gender"=>"m"), array("name"=>"jane","gender"=>"f"), array("name"=>"steve","gender"=>"m"), array("name"=>"mary","gender"=>"f"), array("name"=>"renae","gender"=>"f") ); $num = 30; $wkvar = 'wk' . $num; foreach ($names AS $val) { //$wk30[] = $val; $$wkvar[] = $val; } var_dump($wk30); I need to use the 2nd (variable variable) approach. What am I doing wrong? I tried adding a dynamic index unsuccessfully.
  23. My understanding is # is for comments
  24. https://www.w3schools.com/sql/sql_insert_into_select.asp
×
×
  • Create New...