Jump to content

OriginalSunny

Members
  • Posts

    95
  • Joined

  • Last visited

    Never

Everything posted by OriginalSunny

  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.
  14. Tried this but it comes up with the error "couldnt execute query". $sql = "SELECT Username FROM Employee E, Admin A WHERE E.Username='$_POST[username]' or A.Username='$_POST[username]'"; $result = mysql_query($sql) or die("Couldn't execute query."); Any idea why??
  15. Hi, I have been looking on a number of websites and seen that in their FAQ sections they have links to the answers to their questions. The thing is how do they create the link so it goes to the answer on a certain part of the same page?? The only thing i know is to create a link to another page not at a different part of the same page. If you know how to do this please let me know as i am creating an FAQ section for my website. Thanks.
  16. Thanks but there is still no output for the second loop.
  17. Hi, I have used the following code for my queries: $connect = connect_to_db("con.inc"); $query = "SELECT * FROM purc WHERE ID='{$_SESSION['ID']}'"; $result = mysql_query($query,$connect) or die("sql_del: ".mysql_error($connect)); $connect1 = connect_to_db("con.inc"); $query1 = "SELECT * FROM [b]purc_item[/b] WHERE ID='{$_SESSION['ID']}'"; $result1 = mysql_query($query,$connect1) or die("sql_del: ".mysql_error($connect1)); The only difference is the table which is highlighted in bold and i have changed the variable names. Now the following code is used to extract the data: echo "The ID for the product is: <br>"; while($row = mysql_fetch_array($result)) { echo ''.$row['ID'].''; } echo "The quantity for the product is: <br>"; while($row = mysql_fetch_array([b]$result1[/b])) { echo "<td><b>"; echo ''.$row['quantity'].''; echo "</b></td>"; } echo "<br><br>"; The first piece of data is extracted perfectly but the second piece doesnt seem to work?? I have changed the variable name. It seems i can keep extracting data from the first query but not the second? I had this problem before and wanst able to see what i was doing wrong?
  18. 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: [i] $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 ( .........................[/i] 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?? [i] $sql = "SELECT Username FROM Employee [b]OR Admin[/b] WHERE Username='$_POST[username]'"; $result = mysql_query($sql) or die("Couldn't execute query."); ..............................[/i] The bit in bold is the bit i am supposed to be changing. Thanks.
  19. Hi, Just creating a few forms for users to be able to fill out on my webpage. I am using the code below to create boxes users can fill out: [i]<tr><td align="right"><b>Message</b> <td><input type="text" name="message" value="<?php echo @$message ?>" size="50" maxlength="50"></tr>[/i] Its in my .inc file which is then posted to the .php file. The thing i want to know is how you make the box bigger in terms of depth (currently they are like the topic title box when you fill out a new topic on this website. I want them to be larger so they are more like the actually message box when you fill out a new topic on this website). Thanks.
  20. Hi, I am trying to add a new column to my table and making it the primary key. The problem is that i already have a primary key in the table. I cant seem to delete the column which is already the primary key and i cant seem to add the new column as i want to make it the primary key, and there is already a primary key in the table. So how do i do this?? Here is what i have tried and none of it works: [i]alter table emp add column ID int(5) auto_increment first; (empID is the new column i want to make the new primary key) alter table emp drop index username; (username is the present primary i want to change)[/i] Thanks
  21. [!--quoteo(post=364804:date=Apr 14 2006, 10:41 AM:name=wildteen88)--][div class=\'quotetop\']QUOTE(wildteen88 @ Apr 14 2006, 10:41 AM) [snapback]364804[/snapback][/div][div class=\'quotemain\'][!--quotec--] You need to point PHP to a SMTP sever. The address is usally like smtp.hostname.com. Usually you your ISP deals with an SMTP server so tehir customer can send and recieve emails with thier account. If your ISP has an smtp server then use the address for that smtp server and PHP should be able to send an email through the smpt server you specify. localhost which is your PC won't have an SMPT server to send emails. [/quote] So from what i understand i am unable to send emails until the website is up and running on a server(the internet as a web page). Or do i not quite get it? and do i need to find out the name of the SMTP server? Thanks.
  22. Hi, I am trying to send an email in php using the mailsend function. The code i am using is: <?php $to = "manjl@hotmail.com"; $subj = "test"; $mess = "This is a test of the mail function"; $headers = "From: hi@mycompany.com\r\n"; $mailsend = mail($to,$subj,$mess,$headers); ?> It doesnt seem to be working??? What am i doing wrong?? Is there something i need to change in the php.inc file? Currently in my php.ini file i have this: [mail function] ; For Win32 only. SMTP = localhost ; For Win32 only. sendmail_from = me@localhost.com
×
×
  • 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.