nav33n 472 Purple hazed! Team Colleague Featured Poster

When you submit the page, only those checkboxes which were checked will be submitted. So, you will have the count of checkboxes which are checked, you will have all the checkboxes which were checked. Build your query depending upon those values.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Replace testdata in the above example with the database values.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Well, rgviza is saying, instead of having id in the action, pass the value of id in a hidden field. Access id value as $_POST instead of $_GET.
ie.,
instead of <form method="post" action="test.php?id=1"> do,

<form method="post" action="test.php">
<input type="hidden" name="id" value="1">

:)

nav33n 472 Purple hazed! Team Colleague Featured Poster

You are damn right !

nav33n 472 Purple hazed! Team Colleague Featured Poster

Heh.. Great ! Congrats..

nav33n 472 Purple hazed! Team Colleague Featured Poster

You missed out ''. Use this query instead.

$q2 = "UPDATE Operators SET accessLevel='".$accessType."' WHERE EmployeeID =".$empnumber;
maydhyam commented: This guy definitely knows his stuff... +1
nav33n 472 Purple hazed! Team Colleague Featured Poster

Hmm.. Print out the query again.. And also, putting print_r($_POST); (on top of the page) helps alot while debugging.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Are you sure you have changed these configuration ?

$db_server = 'localhost';
$db_name = '';
$db_username = '';
$db_password = '';

nav33n 472 Purple hazed! Team Colleague Featured Poster

Umm.. I just checked bigdump and it worked for me.. Well, I didn't check with over 50mb of data though. :-/

nav33n 472 Purple hazed! Team Colleague Featured Poster

;)

nav33n 472 Purple hazed! Team Colleague Featured Poster

Its $level == "1" and so on.. And why not use just if conditions ? ie.,

$level = $_SESSION['level'];
if ($level == "1") {
  include "page_1.php";
}
if($level == "2") {
  include "Page_2.php";
} 
//and so on..
nav33n 472 Purple hazed! Team Colleague Featured Poster

Also, in check.php, don't forget to assign $_SESSION value to $level.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Okay.. Where are you setting a value to $level ?

nav33n 472 Purple hazed! Team Colleague Featured Poster

Heh! I tested it before posting it here and I am 200% sure it will work..

OmniX commented: php guru once again :) +1
nav33n 472 Purple hazed! Team Colleague Featured Poster

<?php
if (level == "1") { include('page_1.php'); }
else
if (level == "2") { include('page_2.php'); }
else
if (level == "3") { include('page_3.php'); }
?>

Shouldn't level be $level ?

nav33n 472 Purple hazed! Team Colleague Featured Poster

I have a variable in a variable.

I have done this before but it is not working this time.

I have it in a for loop so my code is:

$abc1 = one;
 $abc2 = two;
 for($i = 0; $i < 2; $i++) {
  echo $$abc$i;  
 }

The out come should be "one two", correct?

The concept is correct? The code is correct? - to the best of my knowledge and references.

Any ideas? Thanks, Regards X.

The output will not be one two because $abc1 is one and not $abc0. Try this.

<?php 
$abc1 = "one";
 $abc2 = "two";
 for($i = 1; $i <= 2; $i++) {
  echo ${abc.$i}; //value of $i will be concatenated to string abc and then it will consider the whole as a variable  
 }
 ?>
nav33n 472 Purple hazed! Team Colleague Featured Poster

Hmm.. I don't have a clue.. :(

nav33n 472 Purple hazed! Team Colleague Featured Poster

Umm.. When you visit someone's profile, will his details be added to the session ? If yes, then unset the session variables before using it again. If no, then, I can't think of anything else.

nav33n 472 Purple hazed! Team Colleague Featured Poster

[root@cayenne /home/kletsker/mysqldump]# mysql kletsker_kletskerk < localhost.sql ERROR 1064 (42000) at line 89499: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''[ quote=&quot;Barend&quot;:3v' at line 1

I think (and I am not sure) the problem is with an extra quote ' in the query. It might have encountered a value like,for example, O'neil. This would terminate the query abruptly as in the following example. insert into table (name,address) values ('O'neil','some address'); Anyway, maybe this can help..
http://www.webdevelopment2.com/importing-large-mysql-databases-when-phpmyadmin-lets-you-down-get-bigdump/

nav33n 472 Purple hazed! Team Colleague Featured Poster

Its very difficult to say what is going wrong. Try unsetting the session variables and see if it does any trick.

nav33n 472 Purple hazed! Team Colleague Featured Poster

If "LLL" and "LLNNNN" are the 'standard' format, then you can use strlen to check the string length. If string length is 3, then its usertype1. If its 6, the usertype is 2. Well, this is the simplest way. But if you want to thoroughly check, you can explode the variable into an array, (so the array will be $arr[0]="L"; $arr[1]="L"; $arr[2]="L"; and so on ). Then foreach array element, check if its a character or a number. If the character count is 3 and number count is 0, then the usertype is 1. If character count is 2 and number count is 4, then its usertype2.
It really depends on what logic you want to use in your script.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Substitute correct values to mysql_connect and mysql_select_db.. Are you testing it locally or on a server ? If you are running it on a server, ask your administrator to provide the details.

nav33n 472 Purple hazed! Team Colleague Featured Poster

I think you can ask your question in java forum.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Okay! here is why it doesn't work. First of all, you are calling the function validatedata() in searchuser.php. This function will call the function confirmdata passing empno as a parameter. You fetch the record for that particular empno and display it along with some elements like select box. And,

$accessType=$_POST;

print("<td><input id='upDate' name='upDate' type='submit' value='Update' /></td></form>");
$upDate = $_POST;
print("<td><font face='verdana' size='2'><center><a href=\'update.php?EmployeeID='.$myrow[0].' />Update</a></center></font></td>");
print("<td bgcolor='red'>");
$empNum = $myrow[0];
echo $empNum;
print("</td>");

print("</tr></table></center>");
//print_r($_POST);
if($upDate=TRUE)
{
$q2 = "UPDATE Operators SET accessLevel=".$accessType." WHERE EmployeeID =".$myrow[0];
$result2 = mysql_query($q2, $conn) or die("Update not successful");
}

This part will not work because there is no function call after the page is submitted. Why not put this part somewhere else in the script ? I haven't tested this, but it should be something like this.

<?php

include("./connect.php");


if($_POST['upDate']) {
$accessType=$_POST['accesstype'];
$empnumber = $_POST['empnumber'];
 	$q2 = "UPDATE Operators SET accessLevel=".$accessType." WHERE EmployeeID =".$empnumber;
	$result2 = mysql_query($q2, $conn) or die("Update not successful");		
}


function confirmData($empNo)
{
   global $conn;
   $q = "SELECT EmployeeID, FirstName, LastName, Initials, username, accessLevel FROM Operators WHERE EmployeeID =".$empNo;
   $result = mysql_query($q,$conn);
   $myrow=mysql_fetch_row($result);
   if($result)
   {
      return 1; //Indicates empNo failure
   }
   else  
   {
	   echo"<tr><td>";
	   print("<center>
	   
	   		  <table border='1' width='900'>
				<tr align='center' bgcolor='#339900'>
					<td><font face='verdana' size='2' color='white'><b>Employee ID</b></font></td>
					<td colspan='2'><font face='verdana' size='2' color='white'><b>Name</b></font></td>
					<td><font face='verdana' size='2' color='white'><b>Initials</b></font></td>
					<td><font face='verdana' size='2' color='white'><b>Username</b></font></td>
					<td><font face='verdana' size='2' color='white'><b>Access Level</b></font></td>
					<td colspan='2'><font face='verdana' size='2' color='yellow'><b>Select Access to be Granted and Update-Option 1</b></font></td>
					<td colspan='2'><font face='verdana' size='2' …
nav33n 472 Purple hazed! Team Colleague Featured Poster

ah! cool..

nav33n 472 Purple hazed! Team Colleague Featured Poster

Hmm.. Are you sure about host, username and password ? The database ("people") you are selecting isn't really a database but its a table. web163-dbone is the database.

nav33n 472 Purple hazed! Team Colleague Featured Poster
<?php
$filename ="excelreport.csv";
$contents = "testdata1;testdata2;testdata3; \n";
header('Content-type: application/ms-excel');
header('Content-Disposition: attachment; filename='.$filename);
echo $contents;
 ?>

I had given a similar example in another thread. Well, csv or excel, the procedure is the same.

nav33n 472 Purple hazed! Team Colleague Featured Poster

$querySQL = "insert into people (d_Name, d_Birthday,
d_Birthday) values ($Name, $Birthday, $Telephone)";

Thats wrong. Wrap values in single quote. ie.,

$querySQL = "insert into people (d_Name, d_Birthday,
d_Birthday) values ('$Name', '$Birthday', '$Telephone')";

Cheers,
Nav

nav33n 472 Purple hazed! Team Colleague Featured Poster
<?php
$filename ="excelreport.xls";
$contents = "testdata1 \t testdata2 \t testdata3 \t \n";
header('Content-type: application/ms-excel');
header('Content-Disposition: attachment; filename='.$filename);
echo $contents;
 ?>

This is the simplest way to generate an excel report.

nav33n 472 Purple hazed! Team Colleague Featured Poster

That's strange. Is there any change of version in php/apache ? I can't think of a reason why your script is acting weirdly !

nav33n 472 Purple hazed! Team Colleague Featured Poster

Okay.. So, it inserts a record to the table ? I don't understand the flow of your script, so I can't say much. But why do you have die(); at most places ? :-/

nav33n 472 Purple hazed! Team Colleague Featured Poster

;)

tefflox commented: Not even the MySQL.com would help. nav33n is awesome. +2
nav33n 472 Purple hazed! Team Colleague Featured Poster

Lol.. Congrats :) Good job!

nav33n 472 Purple hazed! Team Colleague Featured Poster

Have you got it right already ? While inserting a record to a table, you follow this syntax.

$sql = "insert into table (column1,column2) values ('$value1','$value2')";

Its while updating, you use this syntax.

$sql = "update table set column1='$value1', column2='$value2' where id='$id'";
nav33n 472 Purple hazed! Team Colleague Featured Poster

I have already mentioned that problem.. the column count is 20 and the values you are trying to insert is 21.

I hope that fixes it :)

nav33n 472 Purple hazed! Team Colleague Featured Poster

No. If `id` is an autoincrement field, you don't have to do anything with it..

nav33n 472 Purple hazed! Team Colleague Featured Poster

Oh, and one more thing.. As far as I know, Its not a good practice to use - (hyphen) with names of the columns. Use underscore instead. You can use `` to mention the column name. For example,

$sql = "INSERT INTO trucks (`relpath-box1`, `relpath-box2`, `relpath-box3`, `relpath-primary`) values ('$value1','$value2','$value3','$value4')";

This has to work.. :)

nav33n 472 Purple hazed! Team Colleague Featured Poster

umm.. It has to.. I could see few errors. First one is, the column count is 20 and the values you are trying to insert is 21. second error is, first value should be $data[0] instead of data[0]

nav33n 472 Purple hazed! Team Colleague Featured Poster

Yep. The whole structure is fine.. Well, If you want, you can try out this simple example. Print $sql and execute it in mysql console. Also, try with mysql_query($query) or die (mysql_error()); You will know why the query failed.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Oh, you can try one more thing.. wrap your values within single quotes. ie.,

$q2 = "UPDATE Operators SET accessLevel='".$accessType."' WHERE EmployeeID =".$myrow[0];

This will not give you any syntax error ( I am sure!).

Once you are done with it, check why $accessType isn't holding any values.

nav33n 472 Purple hazed! Team Colleague Featured Poster

He has declared the tid field as an integer and he is trying to pass it as a string. MySQL probably doesn't like it.

No.. That wouldn't be a problem.. You can pass an integer like a string, but not vice-versa.
I still believe its the form action which was causing the problem! :-/

nav33n 472 Purple hazed! Team Colleague Featured Poster

Yes. Tht might be because of this.

<select id='access' name=accessType width='15'>
$accessType=$_POST;

It should have been $_POST and you are trying with $_POST, which will be empty.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Umm.. so, what was the error ?

nav33n 472 Purple hazed! Team Colleague Featured Poster

For example, you have this query.

$q2 = "UPDATE Operators SET accessLevel=".$accessType." WHERE EmployeeID =".$myrow[0];

You just have to echo it.

echo $q2;

Then you will have the query with dynamic variables.

nav33n 472 Purple hazed! Team Colleague Featured Poster

So, is your form action is like this ?

<form method="POST" action="reply.php?id=852"> 
</form>

If this is the case, then it should work fine. If not, then you should post your code..

nav33n 472 Purple hazed! Team Colleague Featured Poster

So, that's the problem..There is a syntax error somewhere.. Now, print the query and tell us what it says.. And also, execute it with dynamic variables..

nav33n 472 Purple hazed! Team Colleague Featured Poster

Hmm.. Does it give any error ? print out the query and see whats being passed as values..

$name=$_POST; //from the name form
$q_id=$_GET;

What method have you specified for the form ? POST or GET ?

nav33n 472 Purple hazed! Team Colleague Featured Poster

Umm.. I think you didn't get what I said.. Try wrapping the values in single quote.

$sql = "insert into table (column1,column2) values ('test1',''test2')";

Notice the values within quotes.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Are you getting any error ? The only thing that might be wrong with the query is, not using ' ' while inserting a value to the varchar field. ie.,

$query = "insert into table (col1,col2) values ('test', 'test2')";
nav33n 472 Purple hazed! Team Colleague Featured Poster

Print the update query and see if it executes in phpmyadmin/mysql console. What do you get ? A result or an error ? You can also try $result = mysql_query($query,$conn) or die (mysql_error()); This will also give the error message about why the query failed![code=php]
$result = mysql_query($query,$conn) or die (mysql_error()); This will also give the error message about why the query failed!