Jump to content

niche

Members
  • Content Count

    3,395
  • Joined

  • Last visited

Community Reputation

129 Excellent

1 Follower

About niche

  • Rank
    Devoted Member
  • Birthday 01/01/1958

Previous Fields

  • Languages
    php, mysql, html, css, javascript

Profile Information

  • Location
    Lincoln, Nebraska, USA
  • Interests
    coding, inventing, selling, building large scale models, sci fi

Recent Profile Visitors

53,742 profile views
  1. 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
  2. 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.
  3. 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
  4. 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?
  5. Voila! Thanks for your help.
  6. 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?
  7. 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%' ));
  8. http://php.net/manual/en/language.variables.variable.php (3rd example).
  9. 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"
  10. 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.
  11. My understanding is # is for comments
  12. https://www.w3schools.com/sql/sql_insert_into_select.asp
  13. Sounds like you want something like this: https://stackoverflow.com/questions/14907863/insert-data-from-one-table-to-another-in-mysql
×
×
  • Create New...