nav33n 472 Purple hazed! Team Colleague Featured Poster

:) You are welcome!

nav33n 472 Purple hazed! Team Colleague Featured Poster

I have shown you how to format the array in the way you need(in the other thread). You should try this yourself by analysing the code I gave you earlier. Unless you make an attempt, you wont learn anything. (This is just like the other format. So, I dont see any point why you cannot do it.)

Cheers,
Naveen

nav33n 472 Purple hazed! Team Colleague Featured Poster

You are welcome! :)

nav33n 472 Purple hazed! Team Colleague Featured Poster
<?php
//connect
//select db
$arrData=array();
$query="SELECT SUM(RAW_AMOUNT) as TotalRawAmount, SUM(FG_AMOUNT) as TotalFGAmount, SUM(WIP) as TotalWIPAmount, UPLOAD_DATE FROM raw_fg_sum GROUP by UPLOAD_DATE";
$result=mysql_query($query);
$arrData[0][0] ="";
$arrData[1][0] = "TotalRawAmount";
$arrData[2][0] = "TotalFgAmount";
$arrData[3][0] = "TotalWIPAmount";
$i=1;
while($row=mysql_fetch_array($result)){
	$arrData[0][$i]=$row['UPLOAD_DATE'];
	$arrData[1][$i]=$row['TotalRawAmount'];
	$arrData[2][$i]=$row['TotalFgAmount'];
	$arrData[3][$i]=$row['TotalWIPAmount'];
        $i++;
}
print_r($arrData); //$arrData will have the array in the format you have specified.
?>

Hope that helps.
Nav

nav33n 472 Purple hazed! Team Colleague Featured Poster

I dont know if it is as simple as this, but you have left out a " at the end of your $sql = part before the ;

:) Absolutely right.

nav33n 472 Purple hazed! Team Colleague Featured Poster

hmm.. Ok..

<?php
$conn=mysql_connect("********************","*******","**************") or die(mysql_error());
mysql_select_db("db33717_gradsurvey") or die(mysql_error());


function generatePassword ($length = 8)
{

  // start with a blank password
  $password = "";

  // define possible characters
  $possible = "0123456789bcdfghjkmnpqrstvwxyz"; 
    
  // set up a counter
  $i = 0; 
    
  // add random characters to $password until $length is reached
  while ($i < $length) { 

    // pick a random character from the possible ones
    $char = substr($possible, mt_rand(0, strlen($possible)-1), 1);
        
    // we don't want this character if it's already in the password
    if (!strstr($password, $char)) { 
      $password .= $char;
      $i++;
    }

  }
  
  // done!
  return $password;

}

$query=("SELECT * FROM grads") or die(mysql_error());
$result=mysql_query($query) or die(mysql_error());
while($row=mysql_fetch_array($result)){
$userid=$row['user_id'];
$password=generatePassword(8);
$sql="update grads set password='$password' where user_id='$userid'";
mysql_query($sql) or die(mysql_error());
echo $user_id." : ".$password; //remove this if you dont want to see the user id and password on the screen
}
?>

This will work.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Did you add the lines I mentioned above ? Did you copy the file to system32 folder ? Dude! My suggestion for you is to uninstall apache, php and mysql and install wamp. It saves alot of your work.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Well, as the error says, the columns specified in the insert query doesn't match with the values you are passing. Make sure that you have all the columns(in your table) ! insert into table (col1,col2) values (val1) and insert into table (col1) values (val1,val2) both would generate same error.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Welcome to Daniweb! :)

nav33n 472 Purple hazed! Team Colleague Featured Poster

Welcome!

nav33n 472 Purple hazed! Team Colleague Featured Poster

I guess you dont know how a function works ! Am I correct ? The function call should be outside the function and not within itself. It will enter an infinite loop. $pass=generatePassword($length); should be outside. And it should be something like $x=generatePassword(8); I hope here on, you will debug on your own.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Nope. print_r($_POST); is for debugging. I asked you to remove it because, once your code is up and running, you dont need those debug information. But anyway, unless you dont debug your code yourself, you wont learn anything. Spoon feeding is not good either. So good luck! :)

nav33n 472 Purple hazed! Team Colleague Featured Poster

You are welcome :)

nav33n 472 Purple hazed! Team Colleague Featured Poster

remove print_r($_POST); and then debug yourself. I think I have helped you enough and you are in a state where you can solve your bugs. :)

nav33n 472 Purple hazed! Team Colleague Featured Poster

You are welcome! :)

nav33n 472 Purple hazed! Team Colleague Featured Poster

umm.. I don't think this would be any problem.. Check that out.. Joins is not my forte! But by looking at the query, I think it will work! (not sure though!)

nav33n 472 Purple hazed! Team Colleague Featured Poster

Example,

select AVG(productrating) as average  from reviewtable group by productid order by average desc

Calculates the average of all the products and puts the product with more average on top. I am sure you can make use of that.

nav33n 472 Purple hazed! Team Colleague Featured Poster

This would list all the records in the reviewtable in descending order(only those within 24 hrs). But if you want only 10 rows, then you can use limit.

select * from reviewtable where reviewdate >= date_sub(NOW(), INTERVAL 24 HOUR) order by productrating desc limit 0,10
nav33n 472 Purple hazed! Team Colleague Featured Poster
nav33n 472 Purple hazed! Team Colleague Featured Poster

err.. You have using getElementById("favorite"), But, you have exp as the id for the textbox.

<html>
<head>
<script type="text/javascript">
function explain(value){
	if(document.getElementById("list01").value=="burn")
	{
		document.getElementById("exp").value="This burns their crops"
	}
	if(document.getElementById("list01").value=="pillage")
	{
		document.getElementById("exp").value="Kill women and children"
	}
	if(document.getElementById("list01").value=="court")
	{
		document.getElementById("exp").value="huh"
	}
}
</script>
</head>
<body>
<form id="myform" method="post">	how would you like to attack <? echo $attuser; ?>, you can:<br /><br />
<select id="list01" name="atk" class="but" onChange="explain(this)">
<option value="burn">burn crops</option>
<option value="pillage">pillage</option>
<option value="court">court women</option>
</select>
<input id="exp" value="" disabled="disabled" class="but" size="50" />
<input type="submit" name="attack" value="Attack!!" class="but" />
</form><br />
</body>
</html>

This works :)

nav33n 472 Purple hazed! Team Colleague Featured Poster

:) Welcome! Keep reading and you will learn a lot !

nav33n 472 Purple hazed! Team Colleague Featured Poster

Welcome to Daniweb!

nav33n 472 Purple hazed! Team Colleague Featured Poster

Welcome! :)

nav33n 472 Purple hazed! Team Colleague Featured Poster

VALUES
('$Vet_First',
'$Vet_Middle:', <<< is $Vet_Middle and not $Vet_Middle:

:)

nav33n 472 Purple hazed! Team Colleague Featured Poster

By default, php5 doesnt support mysql. You need to add these lines in httpd.conf in apache/conf directory.

AddType application/x-httpd-php .php
AddType application/x-httpd-php .php3

LoadModule php5_module "c:/path/of/this/file/php5apache2_2.dll"

Uncomment mysql line from php.ini
Copy php5ts.dll in system32 folder.

Phew! I would suggest you to try WAMP, which does all these things for you.

Cheers,
Naveen

nav33n 472 Purple hazed! Team Colleague Featured Poster

:) He means configuring apache to add mysql module.

nav33n 472 Purple hazed! Team Colleague Featured Poster

80-90 lines of code.. hmm.. Then it doesn't make any difference.. When I said 'a lot of data', I meant, the contents on the screen, eg, images, thousands of lines of code, etc.. Actually, ob_start should be the first line of your code after <?php and ob_flush should be the last line.

nav33n 472 Purple hazed! Team Colleague Featured Poster

ob_start buffers all the output. But, if your page has a lot of data, make sure that you don't use ob_start since it acts on the server load.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Welcome :)

nav33n 472 Purple hazed! Team Colleague Featured Poster

Welcome to Daniweb!

nav33n 472 Purple hazed! Team Colleague Featured Poster

Welcome to Daniweb! Well, since this is an 'introduce yourself' forum, theres no problem if you say about your background. :)

nav33n 472 Purple hazed! Team Colleague Featured Poster

Welcome Rnr! marathon runner! hmm.. cool !

nav33n 472 Purple hazed! Team Colleague Featured Poster
nav33n 472 Purple hazed! Team Colleague Featured Poster

You are welcome! :D

nav33n 472 Purple hazed! Team Colleague Featured Poster
<?php
if(isset($_POST['submit'])) {
		if($_FILES['fileupload']['name']==""){
			echo "Empty"; //no file was uploaded
		}
		//continue with rest of the operation..
}
	?>
<html>
<body>
<form name="upload" method="post" action="upload.php" enctype="multipart/form-data">
<table>
<tr><td>
<input type="file" name="fileupload">
</td></tr>
<tr><td>
<input type="submit" name="submit">
</td></tr>
</table>
</form>
</body>
</html>

This will do.. :)

Venom Rush commented: helped me a lot. Where would I be without nav33n :P +1
nav33n 472 Purple hazed! Team Colleague Featured Poster

Run a query to get all the required data from the table. Put it in the message part.

nav33n 472 Purple hazed! Team Colleague Featured Poster
$query="select user_id from table";
$result=mysql_query($query);
while($row=mysql_fetch_array($result)){
$x=generatePassword($length);
$userid=$row['user_id'];
$sql="update table set password='$x' where user_id='$user_id'";
mysql_query($sql);
}

:) Simple.

nav33n 472 Purple hazed! Team Colleague Featured Poster
mail( "to_address","subject","message details","From: from_address");

In message details, you can send whatever information you want. So, I think this would be better instead of sending a user an excel attachment mail !

nav33n 472 Purple hazed! Team Colleague Featured Poster

Earlier in your query, you were using $row as value. So I asked you to change the query. Since you have changed the value to $row it should work fine. Its passing first name because (I think) you are storing first name in user_id column. Because, when I asked you to show what's in <option value=''>..</option>, it showed me the first name.

<?php
// Welcome the user
echo '<h2>Welcome';
if (isset($_SESSION['agent'])) {
	echo ", {$_SESSION['agent']}!";
}
echo '</h2>';

That doesnt work since you are not setting $_SESSION anywhere. First check if $_SESSION is not set. If its not set, set agent name. Then this will work.
And about the password generation. Well, the link that I gave you was a function. You just have to copy that function in your script and call that function whenever you want to generate a new password. And this is how you call that function.

$pass=generatePassword($length); //length of the password.. by default it takes 8 if you don't specify any.
nav33n 472 Purple hazed! Team Colleague Featured Poster

Uploading images to a table ? 99% of the people who upload an image wouldn't upload it to the table. Instead, they upload the image to the filesystem and insert the path of the image to the table. Fetching the blob data from the database just adds on to the server load. But if you want to insert an image to a table, you can check this site.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Excel is easier compared to pdfs. Or instead, you can send a mail with all the data fetched from the table.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Can you explain that in detail ? I didn't get you!

nav33n 472 Purple hazed! Team Colleague Featured Poster

:) the easiest way is to execute a query just like you are doing here.

$query="select * from tablename";
$result=mysql_query($query);
while($row=mysql_fetch_array($result){
  $var=$row['column_name_of_your_table'];
 ....
...
..
.
}

The most simplest way!

nav33n 472 Purple hazed! Team Colleague Featured Poster

You mean the script you have here ? No. On every submit, it will add a new record ! (Even if you refresh this page, it will insert a new record! )

nav33n 472 Purple hazed! Team Colleague Featured Poster
select * from reviewtable where reviewdate >= date_sub(NOW(), INTERVAL 24 HOUR) order by productrating desc

I think this should work. I am selecting only those records where reviewdate is greater than (present-time - 24 hours).
P.S. I haven't tested it. But I think it will work.

nav33n 472 Purple hazed! Team Colleague Featured Poster

umm.. I guess you didn't see what I posted in my previous post ? :S

nav33n 472 Purple hazed! Team Colleague Featured Poster

:) Great!

nav33n 472 Purple hazed! Team Colleague Featured Poster

$city')"; This should have been '$city')" ;

nav33n 472 Purple hazed! Team Colleague Featured Poster

See! I told you. Values are not being assigned to the option :) ! This should have been,

<option value=Jacob Anderson>Jacob Anderson</option><option value=Mohammed Abbas>Mohammed Abbas</option><option value=Hiroaki Abe>Hiroaki Abe</option>

:)


Edit: Change $query="select user_id from grads"; to $query="select user_id,grads from grads"; It should work.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Ok. What is the error now ? Print out the query. (print $sql; ) . Where are you assigning the tablename ($tbl_name) ? and NEVER display your host, username and password :S !