ramone_johnny Posted June 2, 2013 Share Posted June 2, 2013 Sorry guys, I'm relatively new at PHP, and as I've never done this before, I need to ask. How do I correctly format the syntax below in order to insert to 2 separate tables, one after the other? $r=query_wrapper("SELECT * FROM tblmembers WHERE mem_email = ?",$mem_email); $rstDBEdit=mysql_fetch_assoc($r); if($rstDBEdit) redirect("/message.php?message=already_a_member"); $a["mem_name"] = $mem_name; $a["mem_password"] = $mem_password; $a["mem_email"] = $mem_email; .... query_wrapper("INSERT INTO tblmembers SET ?%",$a); $mem_ID = mysql_insert_id(); ---------------------------------------------------- $r=query_wrapper("SELECT * FROM tblshare_adverts"); $rstDBEdit=mysql_fetch_assoc($r); $a["share_available"] = $share_available; $a["share_header"] = $share_header; $a["share_description"] = $share_description; .... query_wrapper("INSERT INTO tblshare_adverts SET ?%",$a); $share_ID = mysql_insert_id(); Quote Link to comment Share on other sites More sharing options...
cpd Posted June 2, 2013 Share Posted June 2, 2013 (edited) Edit: Miss read your code. What does query_wrapper do? Edited June 2, 2013 by cpd Quote Link to comment Share on other sites More sharing options...
ramone_johnny Posted June 2, 2013 Author Share Posted June 2, 2013 That's a good question - lol I *think* it prevents sql injection attacks. Quote Link to comment Share on other sites More sharing options...
cpd Posted June 2, 2013 Share Posted June 2, 2013 Okay well whats your issue because you've not really specified one? And query_wrapper is doing a fair amount of work so we'd need to see it to ensure its correctly formatting the query. Quote Link to comment Share on other sites More sharing options...
ramone_johnny Posted June 2, 2013 Author Share Posted June 2, 2013 Well when I run this, I get an error that indicates that its pulling those a$ values the second time round. My best guess was that I might need to change the second query to use something like b$, but that would be a complete guess. Quote Link to comment Share on other sites More sharing options...
ramone_johnny Posted June 2, 2013 Author Share Posted June 2, 2013 Sorry, here's the query_wrapper stuff. // // sql_placehloder() + mysql_query(). // function query_wrapper() { global $linkScript; $args = func_get_args(); $tmpl = array_shift($args); if(is_resource($tmpl)) { $link=$tmpl; $tmpl = array_shift($args); } else $link=$linkScript; $query = sql_placeholder_ex($tmpl, $args, $error); if ($query === false) { $error = "Placeholder substitution error. Diagnostics: \"$error\""; if (function_exists("debug_backtrace")) { $bt = debug_backtrace(); $error .= " in ".@$bt[0]['file']." on line ".@$bt[0]['line']; } trigger_error($error, E_USER_ERROR); return false; } $r = mysql_query($query,$link); if (!$r) { echo "<hr>$query<hr>"; $error = "Mysql_query error: ".mysql_error(); if (function_exists("debug_backtrace")) { $bt = debug_backtrace(); $error .= " in ".@$bt[0]['file']." on line ".@$bt[0]['line']; } trigger_error($error, E_USER_ERROR); } return $r; } ?> Quote Link to comment Share on other sites More sharing options...
jazzman1 Posted June 2, 2013 Share Posted June 2, 2013 You defined the query_wrapper() function without any arguments but when you call it you inserted two. Can you explain that? $r=query_wrapper("SELECT * FROM tblmembers WHERE mem_email = ?",$mem_email); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.