Jump to content

Inserting


ec

Recommended Posts

I'm trying to save the result of this query into the table members but it wont do anything...It works when I type the qry directly into phpmyadmin but wouldn't with mysql...

anyone know what's wrong with it??

 

 

$qry = "SELECT accesslevel.level FROM accesslevel, teacher WHERE accesslevel.position= teacher.position AND teacher.teacherid='teacherid'";

$result=mysql_query($qry);

$result = mysql_fetch_array($result);

 

//Create INSERT query

$qry = "INSERT INTO members(firstname, lastname, level, teacherid, passwd) VALUES('$fname','$lname','$result','$teacherid','".md5($_POST['password'])."')";

$result = mysql_query($qry);

//Check whether the query was successful or not

if($result) {

header("location: register-success.php");

exit();

}else {

die("Query failed");

}

Link to comment
https://forums.phpfreaks.com/topic/98054-inserting/
Share on other sites

no worries, it's working now

 

the code is

 

<code>

 

//userlevel

$qry = "SELECT accesslevel.level as level FROM accesslevel, teacher WHERE accesslevel.position= teacher.position AND teacher.teacherid= '$teacherid' ";

$result=mysql_query($qry);

  $result = mysql_fetch_array($result);

$level = $result[0];

 

//Create INSERT query

$qry = "INSERT INTO members(firstname, lastname, level, teacherid, passwd) VALUES('$fname','$lname','$level','$teacherid','".md5($_POST['password'])."')";

$result = mysql_query($qry);

//Check whether the query was successful or not

if($result) {

header("location: register-success.php");

exit();

}else {

die("Query failed");

}

</code>

Link to comment
https://forums.phpfreaks.com/topic/98054-inserting/#findComment-502148
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.