Jump to content

OriginalSunny

Members
  • Posts

    95
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

OriginalSunny's Achievements

Regular Member

Regular Member (3/5)

0

Reputation

  1. The correct values are now being output but as soon as i use update it come up with a blank white screen again. $q = UPDATE Stock SET stockAmt = '$newStock' WHERE stockID = '$stockID'; $q_res = mysql_query($q,$connect) or die("sql: ".mysql_error($connect)); I cant see where i am going wrong here.
  2. Tried it but it keeps comming up with a blank page. Here it is again. Can anyone spot any errors causing it to come up with a blank page? Or find out why it isnt working? The bit in bold is causing the problem. Thanks. while($row1 = mysql_fetch_array($result1)) { echo "<tr><td><b>"; echo ''.$row1['stockID'].''; echo "</b></td>"; echo "<td><b>"; echo ''.$row1['quantity'].''; echo "</b></td>"; [b] $sql = "SELECT stockAmt FROM Stock WHERE stockID = $row1['stockID']"; $result = mysql_query($sql,$connect) or die("sql: ".mysql_error($connect)); $row2 = mysql_fetch_array($result); $result1 = $row['stockAmt'] - $row1['quantity']; UPDATE Stock set stockAmt = $result1 WHERE stockID = $row1['stockID'];[/b] ... } echo '</table>';
  3. These errors are ouput in nusphere debugger: Warning: session_destroy() [function.session-destroy]: Trying to destroy uninitialized session in C:\Project\htdocs\logout.php on line 4 Warning: Cannot modify header information - headers already sent by (output started at C:\Project\htdocs\logout.php:4) in C:\Project\htdocs\logout.php on line 5 The thing is its an admin area of the website which i want administrators to be able to log out of. There are some session variables used in the admin area to pass information and post is used to pass values through a lot of the pages. So should i just have a logout which is a link back to the homepage and do i really need to use session_destroy()??? Thanks!! It worked. What a silly error lol.
  4. I just want to get rid of any variables. It doesnt seem to be working because a blank white page is output.
  5. Why doesnt this code work? I have never used destory session before so nt sure how to implement it. I simply want to use it as a logout function and then return to the homepage of my website so what am i doing wrong and how should i change it?? <?php session_destroy(); header("homepage.htm"); ?>
  6. Hi i am trying to update the value for my stock when this page is run. The value of the stock should be deducted by the quantityAs you can see the value of stockID is output and this is output correctly so why doesnt the rest of it work?? And am i better of using REPLACE INTO??? while($row1 = mysql_fetch_array($result1)) { echo "<tr><td><b>"; echo ''.$row1['stockID'].''; echo "</b></td>"; echo "<td><b>"; echo ''.$row1['quantity'].''; echo "</b></td>"; $sql = "SELECT stockAmt FROM Stock WHERE stockID = $row1['stockID']"; $result = mysql_query($sql,$connect) or die("sql: ".mysql_error($connect)); $result1 = $result - $row1['quantity']; echo "$result1"; UPDATE Stock set stockAmt = "result1" WHERE stockID = $row1['stockID'] ; } Its the bit in bold thats causing the problem. I am just using echo to test if the output for the value i want to replace it with is ok.
  7. Tried it. Still have no luck.
  8. Tried it but still got the same problem. Its either reading in the admin value wrong or i have done something wrong in the coding. I am pretty sure it isnt reading the admin value in wrong however, but i cnat see whats wrong with the coding either.
  9. I have tried create a login page for an administrator so that if the value in admin is 1 it will let the user go through to the next page but it just doesnt work. The code i have used is: $sql1 = "SELECT admin FROM Employee WHERE empUsername='$_POST[empUsername]'"; $result1 = mysql_query($sql1) or die("Couldn't execute query."); if ($result1 == 1) { ....(go through to the next page) } else { (print error message) } No matter what i do it just seems to output the error message. I have stored the value 1 for one of the employees and 0 for the other but it still doesnt work. Is it an error in my code?? (I have also tried to put "" around the 1 highlighted in bold). Please help!
  10. while($row = mysql_fetch_assoc($result)) { foreach($row as $field => $value) { if($field != "purchaseID") { [b] $items[$n][$field]=$value;[/b] if($field == "modelnum") { $sql_2 = "SELECT prodDesc FROM stock WHERE modelnum = '$row[modelnum]'"; $result2 = mysql_query($sql_2,$cxn) or die("sql_2: ".mysql_error($cxn)); $row = mysql_fetch_row($result2); [b] $items[$n]["name"]=$row[0]." ".$row[1];[/b] } } } $n++; } From what i can understand it is going through the loop for the total number of rows(in the value $result) and then if the field is not equal to purchaseID it goes through to the next bit and so on... I dont understand what is being stores in the arrays which are in bold. Please could someone tell me. Thanks.
  11. I have tried to do it so that if the value in admin is 1 it will let the user go through to the next page but it just doesnt work. The code i have used is: $sql1 = "SELECT admin FROM Employee WHERE empUsername='$_POST[empUsername]'"; $result1 = mysql_query($sql1) or die("Couldn't execute query."); if ($result1 == 1) { ....(go through to the next page) } else { (print error message) } No matter what i do it just seems to output the error message. I have stored the value 1 for one of the employees and 0 for the other but it still doesnt work. Is it an error in my code?? (I have also tried to put "" around the 1 highlighted in bold). Please help!
  12. Hi, I am creating a login page for an employee however the administrator should also be able to access the page. I have got it working for the employee to be able to access the page with a username and password using: $sql = "SELECT Username FROM Employee WHERE Username='$_POST[username]'"; $result = mysql_query($sql) or die("Couldn't execute query."); $num = mysql_num_rows($result); if ($num == 1) // login name was found { $sql = "SELECT password FROM Employee WHERE Username='$_POST[username]' AND password='$_POST[password]'"; $result2 = mysql_query($sql) or die("Couldn't execute query 2."); $num2 = mysql_num_rows($result2); if ($num2 > 0) // password is correct ( ......................... Now how do i alter it so that an administrator from the admin table can also access the page?? I am thinking of using this but i know it wont work so there must be another way?? $sql = "SELECT Username FROM Employee [b]OR Admin[/b] WHERE Username='$_POST[username]'"; $result = mysql_query($sql) or die("Couldn't execute query."); .............................. The bit in bold is the bit i am supposed to be changing. Thanks.
  13. Hi, My form outputs the quantity and productID correctly on the form but i can't seem to decrease the amount for quantity by the quantity output. while($row1 = mysql_fetch_array($result1)) { echo "<td><b>"; echo ''.$row1['quantity'].''; echo "</b></td>&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp"; echo "<td><b>"; echo ''.$row1['stockID'].''; [b] $sql = REPLACE INTO Stock (stockAmt) VALUES (" stockAmt - ''.$row1['quantity'].'' ") WHERE stockID = " ''.$row1['stockID'].'' "; mysql_query($sql);[/b] } The problem is the code in bold. I don't get where i am going wrong as the correct values are ouput but when i use the bit to replace the value, it causes a blank output so there is an error somewhere. If you know what it is please let me know. Thanks.
×
×
  • 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.