Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 12/11/2020 in all areas

  1. Quite right, sorry about that. The bind statement should be $stmt2->bind_param('ssss', $fname, $lname, $fname, $lname);
    1 point
  2. Yes, the variables map to the question-mark placeholders. You need one for each question-mark. So when you need to place the same value into a query in different places you need to use multiple ? and bind the variable multiple times accordingly. $stmt2 = $con->prepare("INSERT INTO wp_terms(name, slug) VALUES (concat(?,' ',?), lower(concat(?,'-',?)) ); ^ ^ ^ ^ | | | | +----------+ | | | | +---------+ | | | | +-------------------+ | | | | +------------------+ | | | | v v v v $stmt2->bind_param('ssss', $name, $slug, $name, $slug); The variables should probably be $nameFirst / $nameLast instead of $name / $slug as in this example you're combining the names and generating the slug in the query using the lower/concat functions.
    1 point
  3. You could, but it's easier to do it the PHP code if ($_SERVER['REQUEST_METHOD']=='POST') { $stmt1 = $db->prepare("INSERT INTO a_rosters(uniform, nameFirst, nameLast) VALUES (?,?,?)"); $stmt1->bind_param('sss', $uniform, $fname, $lname); $stmt2 = $con->prepare("INSERT INTO wp_terms(name, slug) VALUES (?,?)"); $stmt2->bind_param('ss', $name, $slug); foreach ($_POST['uniform'] as $k => $uniform) { $fname = $_POST['nameFirst'][$k]; $lname = $_POST['nameLast'][$k]; $name = "$fname $lname"; $slug = strtolower("$fname-$lname"); $stmt1->execute(); $stmt2->execute(); } } To do it in the query you would $stmt2 = $con->prepare("INSERT INTO wp_terms(name, slug) VALUES (concat(?,' ',?), lower(concat(?,'-',?)) ); $stmt2->bind_param('ssss', $name, $slug, $name, $slug);
    1 point
This leaderboard is set to New York/GMT-04:00
×
×
  • 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.