Graphix 68 ---

If a color needs to be transparant, you have two options:

  • Use an RGBA definition, e.g. background-color: rgba(255,0,0,0.5); , see http://www.w3schools.com/cssref/css_colors_legal.asp (but this is only supported on the newer versions of browsers)

  • Use the opacity (Netscape-based browsers) and filter (IE-based browsers) property

~G

Graphix 68 ---

Hello everyone,

I stumbled upon a video about the monty hall problem, which I found very well explained, and a lot of comments below the video that were against the conclusion that it is better to switch. To clarify, I wrote this small program that simulates the game and allows everyone to test it for themselves.

I got the following results:

+ Calculation Preferences +

Enter the amount of repetitions:        3000
Do you want to switch choice? [Y/N]     y

+ Calculation Results +

Amount of repetitions:  3000
Correct choices:        2008
Wrong choices:          992
Winpercentage:          66.933333

and:

+ Calculation Preferences +

Enter the amount of repetitions:        3000
Do you want to switch choice? [Y/N]     n

+ Calculation Results +

Amount of repetitions:  3000
Correct choices:        1013
Wrong choices:          1987
Winpercentage:          33.766667

So the conclusion is really self-explanatory :)

~G

Graphix 68 ---

What do you mean by 'A black color around image'? Send us a screenshot of how it looks like in Firefox/Chrome and how it looks in IE

Graphix 68 ---

I don't know much about JSON format, but the replace method only works once, and you need to repeat it in order to replace all (google it).

Example:

<script type="text/javascript">

var str="Visit Microsoft! Microsoft";
document.write(str.replace("Microsoft","W3Schools"));

</script>

Returns:

Visit W3Schools! Microsoft 

So only the first one is replaced (curtisy of w3schools, I was too lazy to fire up editor)

~G

Graphix 68 ---

So you have an image, a link that surrounds it and you want to record whether a visitor clicks on it?

The easiest way is to make a link to a PHP page, e.g. referer.php. This page would take a link as argument and then increment the amount of clicks for that link in a database:

<a href='referer.php?link=http://www.mysite.com'><img src="http://www.mysite.com/banners/2-12/160x600_5.jpg" width='160' height='600' border='1' alt="Click to Visit" /></a>

And then in referer.php you retrieve the link using GET, increment a value in a table (something like 'referer_counter') with columns 'link' (string) and 'counter' (integer) that corresponds with the link and then automatically redirect (google how to do it) the visitor to the correct link.

PS: If it's a rotation banner, you need to change the href everytime a new image is loaded.

~G

Graphix 68 ---

Thanks for the quick replies!

I now understand the values of pointers a bit more :)

Graphix 68 ---

Sure:

size->4
size->4
size->0022FF4C
size->2293580

~G

Graphix 68 ---

Hi,

I've been trying to learn what pointers are and how they function, and I now finally understand most of it. However, I don't understand the assignment of strings to a char *, and what the values they have mean. I wrote a small program to learn:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
{

    int a = 60;
    int * p;
    p = &a;
    printf("Value (with asterisk): %d\n", *p);
    printf("Location (without asterisk): %d\n\n", (int) p);

    char a1 = 'c';
    char * p1 = &a1;
    printf("Value (with asterisk): %c\n", *p1);
    printf("Location (without asterisk): %d\n\n", (int) p1);

    char * p2 = "Some string";
    printf("Unknown (with asterisk): %d\n", *p2);
    printf("Location (with ampersand): %d\n", (int) &p2);
    printf("Value (without asterisk): %s\n\n", p2);

    int * p3 = "47352";
    printf("Unknown (with asterisk): %d\n", *p3);
    printf("Location (with ampersand): %d\n", (int) &p3);
    printf("Unknown (without asterisk): %d\n", (int) p3);

    return 0;
}

I've marked the values I don't understand as 'Unknown'. It seems as if a char * that has a string assigned to it, is sort of the same as a regular type (like int), because it it's value is p2 and it's location &p2. But I don't understand how. I also tryed the same trick with a int *, but the results are not the same (the 'without asterisk' is not the correct value of 47352)

I've googled many tutorials, but none can explain how this really works! If someone could send me a tutorial that does, it would really help me out …

Graphix 68 ---

Thanks for the thorough replies, it really put me in the right direction for this program :)

Graphix 68 ---

I've tried adjusting the modus for file reading/writing, but it did not solve the problem: the file copy is still stopped after 705 bytes.

If I understand correctly, the difference in speed between fread/fwrite and getc/putc is the same? But isn't the getc opening the file each time it gets a character and then reopens the stream, in contrary to fread that would only need to access it one time? I think I'il try the fread/fwrite method in this case.

Assuming I find a solution to the EOF problem (probably using fseek, suggested by DeanM), will fread work correctly with really large files (e.g. 3GB +), as it would allocate an absurd amount of virtual memory if it does it all at once. Would it be better to do read/write every 50MB or so? Or should I depend it on the virtual memory available (and if so, how do I measure it with standard C functions)?

Edit: gerard, if EOF is a standard value returned if the file-read has ended, why does it stop after 705 bytes?

~G

Graphix 68 ---

Hi everyone,

I'm currently working on a cross-platform project to copy data from the computer onto a USB drive quickly.

Main problem: EOF in the middle of the file

It's going good so far, but I stumbled across a problem in my copy_file function:

int copy_file(char *source_path, char *destination_path) {

    FILE *input;
    FILE *output;

    char temp1[MAX_PATH] = {0};
    strcpy(temp1, source_path);

    char temp2[MAX_PATH] = {0};
    strcpy(temp2, destination_path);

    if ( (input = fopen(temp1, "r")) != NULL ) {

        if ( (output = fopen(temp2, "w+")) != NULL ) {

            /* Copying source to destination: */
            char c;
            while ( (c = getc(input)) != EOF ) {
                putc(c, output);
            }

        } else {

            /* If the output file can't be opened: */
            fclose(input);
            return 1;
        }

    } else {

        /* If the input file can't be opened: */
        return 1;

    }

    return 0;

}

It works fine for regular formatted files such as WORD-documents and text files, but with movies it stops after about 705 bytes, although the file is 42MB. I think it's because there is a EOF character in the middle of the file which breaks up the while loop. Does anyone know how to solve this?

Secondary issue: speed

In regards to speed, I need to write code that gets the job done as fast as possible. This was the simplest copy function I could think of, but I don't know whether it is the fastest. What is faster, fread/fwrite or getc/putc ? Or is …

Graphix 68 ---

You have it figured out pretty good by yourself, but to help you in the right direction, think of something like this:

$filename = "D:/some/folder/example.txt";
$text = "<a href='delete.php?file=".$file."'>Delete ".$file."</a>";

And apply that to your own script (thus making a new page called 'delete.php' that retrieves the filename from the URL using GET and deletes it)

~G

Graphix 68 ---

Hi!

A few things you might consider:
>> First debug your code and find the source of your problem, then post the small piece of code that is flawed so that we do not have to spit through all your code (which I, for one, am not going to)
>> If you are a novice in JavaScript, you might consider starting with easier things instead of adapting difficult code.
>> If you did not write the script, we can not help you fix it. Seek help at the author of the script.

~G

Graphix 68 ---

It means that either the column 'product_code' or the table 'products' does not exist, duh ;)

~G

Graphix 68 ---

1. You put each mile in an array and each name
2. You sort the miles-array: http://php.net/manual/en/function.sort.php or an equivalent function (you can always write your own -> good for learning)
3. You run through the array echo'ing each element.

~G

Graphix 68 ---

When I meant 'indenting & spacing', I meant it a bit differently than you did it (see the code). Also you can't compare dates using the strings, you first need to convert them to UNIX timestamps (see http://php.net/manual/en/function.strtotime.php for more explaination).

<?php 
/* The date limit when the page needs to be redirected: */
$timelimit = '2012-02-10 00:00:00';

/* The current date: */
$timenow = date('Y-m-d H:i:s');

/* Comparing the two dates: */
if ( strtotime($timenow) > strtotime($timelimit) ) {

	/* Redirecting user to another page: */
	header( "HTTP/1.1 301 Moved Permanently" );
	header( "Status: 301 Moved Permanently" );
	header( "Location: http://www.redirectsite.com" );
	exit(0); 

} else { 

	/* Showing page content: */
	echo "http://www.contestpage.com"; 
}

?>

As for the redirecting, I think it is either this or a JavaScript redirect (which is client side). Try googling it.

~G

Graphix 68 ---

That is right, the code I provided needs to be implemented before it works.

If you are not the author of this code, and bought it from someone (or just copied it?), you can ask him to rewrite the code. The purpose of this forum is to help people to fix their problems by giving clues and advice, not to fix the problems for them.

~G

Graphix 68 ---

Wouldnt that require 5 new fields in members ?

No, only 1 field: permission. E.g.

Username Password Permission
--------- --------- -----------
Dude secret 2
Guy cube 0

And so on.

And then how would i assign a user either 0, 1, 2, 3, 4 or 5?

When you insert an user to the database, for example when he registers, he is standard assigned member (0) permission. You could write a script that allows users to assign permission to users below its own permission (e.g. an superadmin can make a member admin, but can't make a member superadmin or president).

You can make it as complex as you want.

~G

Graphix 68 ---

You could also just extend the members table and add a new column named 'permission' that is an integer. The integer corresponds with the level of authentication:

0 :: Member
1 :: Admin
2 :: Superadmin
3 :: President
4 :: Superman

Something like that. And in the code you can test that value: if ($permission > 2) { ....... } ~G

Graphix 68 ---

Your query is a total mess. Using sprintf() is handy in various languages, but as PHP is very flexible with strings, it is completely useless in SQL in my opinion. And if you are going to use it, use it correctly, consult the PHP manual (php.net).

Make it something more nicely put together, and add some comments ;)

Variables:
> $new_password :: The new password
> $old_password :: The old password
> $email :: The email address (used as username)

$query = "UPDATE members 
SET password='".$new_password."' 
WHERE email='".$email."' AND password = '".$old_password."'";

~G

Graphix 68 ---

Hmm... I really thought the problem would lay there.

If that isn't the issue, I can't really give you a straight solution, you will first need to debug the code and check whether everything is received correctly and compared correctly:

$user = mysql_real_escape_string(stripslashes($_POST['username']));
$pass = mysql_real_escape_string(stripslashes($_POST['password']));

echo "Received form values: user='".$user."', pass='".$pass."'<br />";

// You retrieved the form values already, no need to retrieve them again: use the existing variables
$select = "SELECT * FROM `users` where `username`='".$user."' AND `password`='".md5($pass)."'";

echo "Query: '".$select."'<br />";

$msq = mysql_query($select) or die(mysql_error());

$total=mysql_num_rows($msq);

echo "Total: '".$total."'<br />";

This HAS to provide you the solution, as there isn't anything obvious wrong with the script (except some neglected comments and white-spacing).

Make sure that the user and the MD5-HASHED password correspond with the entry in the database (now I come to think of it, have you entered the md5 hash of the password into the row?)

~G

Graphix 68 ---

Your code isn't comparing correctly. You want to see whether text needs to be shown using the 'if' condition, but you are comparing a date? You are also using the assign operator '=' instead of the comparing operator '==':

Line 4-10 should be:

if ($showtxt == false) {
...
...
...
...
} else {
  echo "Page content";
}

I'm not sure whether you can compare dates like that, but I guess you can find that out by yourself. You also might consider indenting & commenting your code!

~G

Graphix 68 ---

The problem isn't that your database isn't connected, but that the database does not have the same data as your local one.

For example there is a user 'jack' in the local database, but not in the hosted database. Or the passwords are not the same.

There is nothing wrong with the script.

~G

Graphix 68 ---

Script looks fine. If I have difficulties when I put a script online it is mostly because of these two reasons:

>> The database is not the same as the local one (this is the most probable cause in your case)
>> I forgot to upload another essential file
>> There is an unknown absolute path

Hope this helps :) I think your database doesn't have a record of user '****' with password hash "jdioafu928749820480fa890'(or something like that).

~G

Graphix 68 ---

The errors you describe are all caused because you messed up the ; and quotes. I spotted one when I was looking through it:

Line 195 >> The query must be encapsed in quotes, e.g. $query = "SELECT * FROM my_table WHERE a_column='".$search_string."'"; So when your code stops giving errors such as 'missing ; statement' or 'unexpected T_STRING', your syntax is incorrect :)

~G

Graphix 68 ---

Hi,

I've been working on a project that needs to list all the drives on a computer (it's kind of a file explorer, but without using the standard one provided by windows). I've searched and found the function GetLogicalDrives(), which does exactly what I want.

However, the return value is a DWORD of which bit-position 0 represents the existince of drive A:/, bit-position 1 of B:/ and so on. I've found a few forum posts about bit-shifting, with which I have no experience.

This is what I got so far:

int main() {

  int bits[32]; // Array to put in the seperate bits of the DWORD
  DWORD input = 9; // This should give 10010000000000000000000000000000
  int i = 0; // Counter

  /* Looping through every bit of the DWORD: */
  for (i = 0; i < 32; i++) {
     bits[i] = input >> i;
     printf("bits[%d] = %d\n", i, bits[i]);
  }

}

But it isn't give the correct output. Does anyone know how to solve my problem :)?

Does anyone know how to do this?

Thanks in advance,
~G

Graphix 68 ---

In my opinion, the three javascript function initForm and showHideBox are unnessecary. When the page reloads, the option that is chosen is already selected (so initForm is obsolete) and using a simple if condition, you can render showHideBox obsolete too!

I'il explain with some code:

//
// As you have not given all your code I assume a few things:
//    > $diag is the ID of the selected diagnostic ($_GET['selectedDiag'])
//    > The query $quer2 retrieves all the diagnostic dropdown values
//    > The query $quer retrieves all causes WHERE diagnosticId = $diag (and same with $mediquery)


/* Opening form: */
echo "<form method='post' name='f1' action=''>";

/* Opening diagnostic dropdown with default option: */
echo "
<select id='selectedDiag' name='selectedDiag' onchange='reload(this.form)'>
<option value=''>Select diagnosis</option>
";

while($noticia2 = mysql_fetch_array($quer2)) { 
	if($noticia2['diagnosisId'] == $diag) {
	  echo "<option selected='selected' value='".$noticia2['diagnosisId']."'>".$noticia2['diagnosisName']."</option>";
	} else {
	  echo "<option value='".$noticia2['diagnosisId']."'>".$noticia2['diagnosisName']."</option>";
	}
}

/* Closing diagnostic dropdown with 'other' option: */
echo "<option value='other'>Other</option>
</select>";

/* Only if the diagnostic is set: */
if (isset($diag)) {

/******************************************************************************
 * I'il let you correct this part yourself: 
*/
	echo "<select name='cause'>
	<option value=''>Select cause</option>";
	while($noticia = mysql_fetch_array($quer)) { 
	echo  "<option value='$noticia[causeId]'>$noticia[cause]</option>";
	}
	echo "</select>";

	//////////        Starting of third drop downlist /////////
	echo "<select name='medicine'>
	<option value=''>Select medicine</option>";
	while($noticiamed = mysql_fetch_array($mediquery)) { 
	echo  "<option value='$noticiamed[medicineId]'>$noticiamed[medicineName]</option>";
	}
	echo "</select>";

/*********************************************************************************/

}

/* Showing submit button: */
echo "<input type='submit' name='submit_button' value='Submit'>";

/* Closing form: */
echo "</form>";

I think this will help you make the four dropdown work.

~G

Graphix 68 ---

Hi!

I've read that you are just starting to learn PHP! Good :)

It makes it easier to read your code if you have a few coding guidelines:

>> Indent and comment your code, keeping statements and function calles seperated and clarified:

/* Doing something: */
doSomething();

/* Doing something else: */
doSomethingElse();

/* Indicates whether something needs to be shown: */
$shown = true;

/* Only if it needs to be shown: */
if ($shown == true) {
     
     /* Showing something: */
     echo "Something";
     
}

/* Doing a loop: */
while ($a == 0) {

     //.... Code block ....

}

// I hope you get the picture by now,
// because typing this isn't really helping you at all with your problem...

>> Also, you might want to read up on how to properly write HTML (watch the use of quotes and ';'):

<img src='myimage.png' border='0' onclick='doSomething("StringArgument");' />

And as a final check, you can always go to the guys that design HTML: http://validator.w3.org/

>> Oh and one last thing, don't use old syntax for your HTML:

<script type='text/javascript'>
function reload(form)
{
  var val = form.selectedDiag.options[form.selectedDiag.options.selectedIndex].value;
  self.location='updateMedicalRecords.php?selectedDiag=' + val ;
}  
</script>

I think you will find your answer when you've cleaned up your code.

~G

Graphix 68 ---
diafol commented: Thank you G - saves me posting a sarcy comment +14
Graphix 68 ---

Alright... I haven't taken a look at the thread for a few hours now and see EvolutionFallen helping :) Well OK.

Some small remarks:

>> You should still read through my previous reply and clean the values you collect with POST, as this makes your SQL vunerable for attacks!

>> If you check the following bit of code EvolutionFallen provided:

$sql = "INSERT INTO comments (page_id, comment) VALUES ($myid, '$comment')" or die(mysql_error());
   mysql_query( $sql, $mymysql );

You should notice that you declare an string to an variable and if THAT doesn't work, you let mysql print its last error??? Pretty strange coding to me! Take a look at this:

$query = "THIS is MY query";
$result = mysql_query($query) or die("Could not execute query");

It prevents the visitor from seeing errors if the occur AND they tell you that the query is wrong. Ofcourse, if you are testing and want to know why a query fails, you put mysql_error() as parameter for die() . But remember to remove it when putting it on a live site ;).

Also, regarding your form and show page:

while ($row = mysql_fetch_array($sql)) {
$comment = $row['comment'];
}

Is a correct loop, but you are not echo'ing anything! Try this:

while ($row = mysql_fetch_array($sql)) {
  $comment = $row['comment'];
  echo $comment;
}

Also the returning reply "Still not working" doesn't really help clarify what's going wrong (although more experienced programmers can spot it easier).

You might want to take a look in …

Graphix 68 ---

You have the variable $page_id in your HTML form, which specifies which page the comment should be placed.

You only need to retrieve the comments from the database that have $page_id as page_id.

I'il give you an head start:

SELECT * FROM table_name WHERE column='value'

Now you need to apply that SQL-query to your code, and loop through the result. If you don't know how:

You now need to retrieve the rows from the table, run through the result with a loop, echo'ing each comment. If you don't know how, try reading a good book or searching online.

~G

Graphix 68 ---

Oh and if you run into a problem with the "showing comments"-part: first try to figure out what the problem is yourself and if you still can't find the solution, post a reply and I'il take a look at it.

Graphix 68 ---

Adding comment part

1. Database

Alright, let's review: you have a table with four columns: comment_id, page-id, comment_content, timestamp

So your database is set up and you can start writing code.

2. HTML form

You have made an initial form, but does it cover the two columns it needs to fill? page_id, check, comment_content, check. So your form is done.

3. PHP code

You retrieve the values given to you by the form and execute them in a query. So this is done too.

So you're done for the adding comment part (assuming it works, you should test the variables and add a few fake comments to make sure it works). Also it's not really secure, in my experience, you should a captcha or some sort of verification before you put code like this online.

I once allowed anyone to add comments to my website without a captcha, and it resulted in 50000 (no really, I am not kidding) comments of advertisements about viagra.

Also you might consider cleaning your variables before executing them in an query (prevents SQL-injection):

$variable = htmlentities(addslashes($_POST['variable']));

Showing comments part

You now need to retrieve the rows from the table, run through the result with a loop, echo'ing each comment. If you don't know how, try reading a good book or searching online.

~G

Graphix 68 ---

Hi,

I've finally found the solution to the database problem: I forgot to close the database when the parent activity was finished ( db.close(); ). But I experiencing a new problem: the MediaPlayer is being stopped GC_FOR_MALLOC. The output of LogCat (I highlighted the lines that I think matter):

10-02 19:10:05.968: DEBUG/dalvikvm(453): GC_EXPLICIT freed 7712 objects / 428800 bytes in 844ms
10-02 19:10:07.328: VERBOSE/MediaPlayerService(67): disconnect(36) from pid 6011
10-02 19:10:07.328: DEBUG/AwesomePlayer(67): [U5B] reset (382)
10-02 19:10:07.328: DEBUG/AwesomePlayer(67): [U5B] reset_l (388)
10-02 19:10:07.328: WARN/TimedEventQueue(67): Event 300 was not found in the queue, already cancelled?
10-02 19:10:07.328: VERBOSE/AudioSink(67): stop
10-02 19:10:07.328: VERBOSE/AudioSink(67): close
10-02 19:10:07.328: DEBUG/AwesomePlayer(67): [U5B] reset_l (478)
10-02 19:10:07.328: DEBUG/AwesomePlayer(67): [U5B] reset (382)
10-02 19:10:07.328: DEBUG/AwesomePlayer(67): [U5B] reset_l (388)
10-02 19:10:07.328: DEBUG/AwesomePlayer(67): [U5B] reset_l (478)
10-02 19:10:07.328: DEBUG/AwesomePlayer(67): [U5B] reset (382)
10-02 19:10:07.328: DEBUG/AwesomePlayer(67): [U5B] reset_l (388)
10-02 19:10:07.328: DEBUG/AwesomePlayer(67): [U5B] reset_l (478)
[B]10-02 19:10:07.328: VERBOSE/MediaPlayerService(67): Client(36) destructor pid = 6011
10-02 19:10:07.328: VERBOSE/AudioSink(67): close
10-02 19:10:07.328: VERBOSE/MediaPlayerService(67): disconnect(36) from pid 6011
10-02 19:10:07.328: DEBUG/dalvikvm(6011): GC_FOR_MALLOC freed 52277 objects / 2056488 bytes in 62ms[/B]
10-02 19:10:10.378: INFO/AudioHardwareQSD(67): AudioHardware pcm playback is going to standby.

This is the function I use to play music:

/**
         * Plays an in-game sound effects
         * 
         * @param res_id : The raw resource to be played (.mp3, .wav etc.) e.g. R.raw.explosion_small
         * @param loop : Boolean that indicates whether it needs to be looped
         *
        */
        private void playSound( int res_id, boolean loop ) {
 
	       MediaPlayer mp = MediaPlayer.create(mContext, res_id);   
	       mp.setLooping(loop);
	       mp.start();
	
	       mp.setOnCompletionListener(new OnCompletionListener() …
Graphix 68 ---

Hi,

In the past few months I've been learning how to make applications for android by making small games just for the fun of it. I am stuck at the moment at the database object I created to manage the database, specifically the cursor: it won't close. A snippet of my code:

public class DatabaseManager extends Activity
{
	// the Activity or Application that is creating an object from this class.
	Context context;
 
	// a reference to the database used by this application/object
	private SQLiteDatabase db;

/**********************************************************************
	 * RETRIEVING A ROW FROM THE DATABASE TABLE
	 * 
	 * This is an example of how to retrieve a row from a database table
	 * using this class.  You should edit this method to suit your needs.
	 * 
	 * @param rowID the id of the row to retrieve
	 * @return an array containing the data from the row
	 */
	public ArrayList<Object> getRowAsArray(long rowID)
	{
		// create an array list to store data from the database row.
		// I would recommend creating a JavaBean compliant object 
		// to store this data instead.  That way you can ensure
		// data types are correct.
		ArrayList<Object> rowArray = new ArrayList<Object>();
 
		try
		{
			
			Cursor cursor;
			
			// this is a database call that creates a "cursor" object.
			// the cursor object store the information collected from the
			// database and is used to iterate through the data.
			cursor = db.query
			(
					TABLE_NAME,
					new String[] { TABLE_ROW_ID, TABLE_ROW_ONE },
					TABLE_ROW_ID + "=" + rowID,
					null, null, null, null, null …
Graphix 68 ---

Hi!

About a year ago I was working on a text editor which included highlighting and such, but also offered the functionality to insert BB-code, just like at DaniWeb. The basic idea of this is to retrieve the position of selected text, retrieve the text, embody it with BB-code and then save the changes in the value of the textarea. Here is the function I created:

*** EDIT: Due to the annoying fact that BB-code within the CODE tags is also parsed on DaniWeb, I added forward-slashes to prevent that. Remove them in order for the code to function properly. ***

/*
 *
 * Function: InsertBBCode
 * Parameters:
 
       [0] TXT_Element: The textarea element in which BBCode needs to be inserted
	   [1] Variable: Contains the variable name of the BBCode
	   [2] Value: Contains the variable value of the BBCode
	   
 * Notes: inserts bbcode into the textarea
 * Last edit: 2010-10-10 13:08
 * Author: Graphix
 * Contact: http://www.webdevproject.com
 * Distributed under the GNU Free Documentation License
 *
*/

function InsertBBCode( TXT_Element, Variable, Value )
{
  
  var Open_Tag = "";
  var Close_Tag = "";
  
  switch ( Variable ) {
  
   case "bold" :
     Open_Tag = "\[b\]";
	 Close_Tag = "\[/b\]";
   break;
   
   case "underline" :
     Open_Tag = "\[u\]";
	 Close_Tag = "\[/u\]";
   break;
   
   case "italic" :
     Open_Tag = "\[i\]";
	 Close_Tag = "\[/i\]";
   break;
   
   case "justifyleft" :
     Open_Tag = "[align=left]";
	 Close_Tag = "[/align]";
   break;
   
   case "justifycenter" :
     Open_Tag = "[align=center]";
	 Close_Tag = "[/align]";
   break;
   
   case "justifyright" :
     Open_Tag = "[align=right]";
	 Close_Tag …
Graphix 68 ---

Hi erixxye,

As this is your first post to the forums, you might want to keep some things in mind:

- Place code between CODE tags
- When you post, first describe your problem, then post code

But anyway, onto your issue. You are mixing up PHP with JavaScript. The OnClick attribute is HTML, generated by the PHP code. PHP retrieves form values from submitted HTML forms. So when you click the button in your code, it just simply looks for a JavaScript function called activate_user_id and since it does not exist, it does nothing.

It would appear as if you got the code from some place and tried to adapt it to work on your own website, but I could be wrong...

Anyway, you should replace the <input type="button|submit"> with:

echo '<form action="" method="post">
<input type="submit" name="delUserSubmit">
<input type="hidden" name="loginid" value="'.$rows["loginid"].'" />
</form>';

And then you can delete the user using the following PHP code:

<?php

/* Checking whether a user needs to be deleted: */
if (isset($_POST['delUserSubmit'])) {

    /* Retrieving loginid from the form: */
    $loginid = htmlentities(addslashes($_POST['loginid']));

    // TODO : Delete the user from the login table

}

?>

I would recommend that you read a beginner book on PHP & MySQL (like PHP & MySQL for dummies) and a beginner book on HTML.

~G

Graphix 68 ---

One other small adjustment: a space is required at the beginning of the second parameter in order to work, this is because it is directly parsed behind the process name. Also, it does not automatically search the system folders for a known process, such as notepad.exe . I added a copy of notepad.exe instead of finding the location of it on the system the process is being run (which is also a good possiblity). The full code that works good:

STARTUPINFO sinfo;
PROCESS_INFORMATION pinfo;
memset(&sinfo,0,sizeof(STARTUPINFO));
sinfo.cb = sizeof(STARTUPINFO);
memset(&pinfo,0,sizeof(PROCESS_INFORMATION));
CreateProcess("notepad.exe", " logs\\log.log", 0, 0, FALSE, 0, 0, 0, &sinfo, &pinfo);

~G

Graphix 68 ---

Thanks for the help, that solved my problem!

PS: Also, you forgot to close the memset() function in line 5 with a ) on the end, might want to adjust that ;)

Graphix 68 ---

Umm, try this checklist:

A. Is "users" the correct table?
B. Is the name of the column that holds the level really "level", as you described on line 25?
C. You should have fixed it by now, if not, post a reply :)

~G

Graphix 68 ---

Hi,

At the moment I am trying to open a log file with notepad.exe while the original process continues. As I am developing for Windows, fork() is not available for me. I googled alot and found a good reference to opening processes (http://www.yolinux.com/TUTORIALS/ForkExecProcesses.html), however they all put the original process into a hold. For example:

exec("notepad.exe", "logs/Log.log", 0);

or

system("notepad.exe logs/Log.log");

All stop the original process. Does anyone know the way to fix my problem? I am developing on Windows XP and am using Code::Blocks as IDE.

Thanks in advance,
~G

Graphix 68 ---

Thank you, that worked! I was so fixed on finding a .lib file on the MinGW folder that I did not realize that MinGW uses other types of libraries.

Graphix 68 ---

Hi,

Your code looks alright and should work. I think the problem lies in how you approach the page. When you look at your address bar when you are at request.html, is there a file path (e.g. C:\some\folder\request.html)? If so, you need to go to the file via the localhost: type in the address bar http://localhost/some/folder/request.html and try it again.

If the above is not working, just open demo_get.php in your browser using the localhost and tell me what is echoed in the source code (you know, right click -> source code)

~G

Graphix 68 ---

Hi tstory28,

After a quick look through your code, I would like to suggest a few things:

- Put a new if statement around line 6 to 61, in which you check whether the email and password form variable are set (if (isset($_POST['email) && .....) and delete the if statement in line 10

- Line 7, 8 - Clean the form value first: $variable = htmlentities(addslashes($_POST['form_variable'])); - Line 26 - Add an echo in which you show all the variables from the database:

echo "dbemail=".$dbemail.", dbpassword=".$dbpassword.", dbname=".$dbname.", dblevel=".$dblevel;

If you did all those steps (especially the last one), you will find out why your code is not working (probably because dblevel is empty, but you'll see)

~G

tstory28 commented: This helped me find my issue. +1
Graphix 68 ---

Hi,

Recently I started working on a project (it's called 'fd') that needs to retrieve the current processes running. It is written in C using the WinAPI. I am running Windows XP SP3 and am using MinGW compiler with Code::Blocks. After much searching I found the PSAPI to provide the solution to my problem. It is added below, direct copy from http://msdn.microsoft.com/en-us/library/ms682623%28v=VS.85%29.aspx:

#include <windows.h>
#include <stdio.h>
#include <tchar.h>
#include <psapi.h>

// To ensure correct resolution of symbols, add Psapi.lib to TARGETLIBS
// and compile with -DPSAPI_VERSION=1

void PrintProcessNameAndID( DWORD processID )
{
    TCHAR szProcessName[MAX_PATH] = TEXT("<unknown>");

    // Get a handle to the process.

    HANDLE hProcess = OpenProcess( PROCESS_QUERY_INFORMATION |
                                   PROCESS_VM_READ,
                                   FALSE, processID );

    // Get the process name.

    if (NULL != hProcess )
    {
        HMODULE hMod;
        DWORD cbNeeded;

        if ( EnumProcessModules( hProcess, &hMod, sizeof(hMod), 
             &cbNeeded) )
        {
            GetModuleBaseName( hProcess, hMod, szProcessName, 
                               sizeof(szProcessName)/sizeof(TCHAR) );
        }
    }

    // Print the process name and identifier.

    _tprintf( TEXT("%s  (PID: %u)\n"), szProcessName, processID );

    // Release the handle to the process.

    CloseHandle( hProcess );
}

int main( void )
{
    // Get the list of process identifiers.

    DWORD aProcesses[1024], cbNeeded, cProcesses;
    unsigned int i;

    if ( !EnumProcesses( aProcesses, sizeof(aProcesses), &cbNeeded ) )
    {
        return 1;
    }


    // Calculate how many process identifiers were returned.

    cProcesses = cbNeeded / sizeof(DWORD);

    // Print the name and process identifier for each process.

    for ( i = 0; i < cProcesses; i++ )
    {
        if( aProcesses[i] != 0 )
        {
            PrintProcessNameAndID( aProcesses[i] );
        }
    } …
Graphix 68 ---

Hi,

In your code you defined that there are three variables needed to search for wine:

- The color of the wine (e.g. red, white, or something like that), which I think is not really relevant but whatever
- The country of origin, or more specifically a region
- The price range

You can make a initial search bar that only covers the basic input:

Color: [________[>] Country: [________[>]

Then when either one of them is changed, a function is called, let's say RetrieveWinesOne():

- Retrieves the values of the color and country input
- Send a request to a PHP page to retrieve the wines matching the color and country

You can send multiple variables using the GET method:

xmlhttp.open("GET", "test3.php?k=" + kleur + "&l=" + land, true);

- Echo the returned HTML of the PHP page (preferably a table of some sort)

When this all is working, you should think about what the script needs to do furthermore, as the initial search bar contains only the primary variables needed to search wines and can be expanded with secundary variables such as the region in the selected country and the price range.

~G

Graphix 68 ---

Thanks for the clarification, I assumed that the drive could be accessed without internet connection, thus being equally efficient as TrueCrypt. However as you mentioned, the drive can't be decrypted without connection to the Conseal Server as the AES encryption is practically undecipherable. I now understand why Conseal could be better than the TrueCrypt drive encryption and why it may be worth the 20 euros per year.

~G

Graphix 68 ---

As you said, it is true that TrueCrypt requires admin rights, or a admin that installed TrueCrypt on the computer. You might say that it restricts the portability because users without TrueCrypt can't access the data.

This is however not without reason, this limitation increases the security, as stated in the TrueCrypt manual:

"Warning: No matter what kind of software you use, as regards personal privacy in most cases, it is not safe to work with sensitive data under systems where you do not have administrator privileges, as the administrator can easily capture and copy your sensitive data, including passwords and keys."
Source: http://www.truecrypt.org/docs/?s=truecrypt-portable

Increasing portability decreases security. Ofcourse encrypting your data is more secure than keeping it unencrypted, but it is a waste of money to use Conseal USB when you have a even better free alternative.

~G

Graphix 68 ---

Although I understand that this program enables the owner of the USB drive to check where, when and by who it is being used, this is only possible when the USB drive is allowed access to the internet via the computer it has been connected to. Imagine that a professional thief deliberatly took your USB drive to the sole purpose of retrieving its data, he will not be so foolish to allow the USB to connect to the internet, which will result in notifying the owner, which may have already have activated the swipe-on-sight-command using the website that when it is connected again it will be swiped.

Ofcourse then the last line of the defence will be the ASE encryption that prevents the thief to read the data, assuming that he does not have the facilities for brute force or any extra information about the encryption such as processor time etc.. But encryption of your USB drive already exists, services such as TrueCrypt provide that option. So in fact you could say the only difference between the already exisiting usb drive encryption and Conseal Security is that data on the usb drive will be swiped when the program on the usb drive can connect to the internet.

In conclusion, the security of already existing usb drive encryption software and Conseal Security is practically the same, as brute forcing a AES encryption has 2^200 possibilities which would take longer than the age of the universe to complete (

Graphix 68 ---

A pocket PC is just like a regular computer, so you just need to do the following things (assuming you want to create dynamic sites using PHP & MySQL):

- Install a Apache server, preferably with MySQL implemented: I would suggest XAMPP http://www.apachefriends.org/en/xampp.html

- Place the files into the xampp/htdocs/ folder (for example: xampp/htdocs/MyPage.php)

- Edit the files using a text editor, I would recommend one with syntax highlighting (http://notepad-plus-plus.org/)

- Open the files using a modern browser, I would recommend Firefox or Chrome, and not Internet Explorer, as IE has the nasty habit of caching pages so you can't see changes you keep making in the code. You can open the files by typing in: http://localhost/MyPage.php

And thats about it, it is the same as with an normal computer (but only pocket size)

~G

-