phfilly 26 Junior Poster

Hi guys!

So I need help with a small problem. I'm using a char pointer array which contains a mathematical expression.

For example: "sqrt 25"

Now I want to use the inbuild c++ function sqrt(int)). I'm first searching in the array for the letters 'sqrt' so that my custom function knows what to math function to call. As the example is only a small part of a long math expression. Now I'm running through a while-loop intill it finds a whitespace. So that I know where the number stops.

while(Expression[i] != '')

Dont know should I read the number into another int array?Which creates new problems.The idea is that I want to use the 25 as a whole number and not 2 and 5 seperately because that will give an incorrect answer.

Is there another way of doing this? There must be a simpler way...I think I just forgot about something

Any help will be appreciated :)

Thanks!

phfilly 26 Junior Poster

I'm using the VI editor. I'm not sure how to modify the permissions but I'll take a look into it thanks!

After struggling like this I took an alternative root and reinstalled+redownloaded minix and the virtualbox which seemed to fix the problem for now. Hopefully it stays like this

But Thanks for the feedback!

phfilly 26 Junior Poster

Hi!

I would just like to know is there a way you can overwrite the main.c file in the kernel folder(dir /usr/src/kernel/main.c) in MINIX 3. I want to change some code in the file(I know the risks involved) but the problem is I can't save it. I've tried logging in as 'bin' and 'root' and still the same issue.

Is there another way of doing this?

Thanks-and any help will be appreciated! :D

phfilly 26 Junior Poster

Hi -i've started using netbeans and compiling in it recently and I'm not sure what the problem is here. Not sure if it isn't reading the Element.cpp/.h files while building/running the main.cpp

In my main:

Element a, b(5);

cout<<(5+b)<< endl;

Then in the .h:

Element operator+(const Element&obj);

And in the element.cpp:

 Element Element::operator+(const Element&obj){
     return Element(defaultArgument + obj.defaultArgument);
 }

defaultArgument is a double variable just so btw!

The error states: error: no match for 'operator+' in '5 + b' - maybe just something small. Bit rusty with c++ atm.

phfilly 26 Junior Poster

Hi!

I'm still new to Actionscript 3.0 and was wondering if you could help me please. I'm trying to do a registration form in flash. The user entering his name/email/password and I want to save that value to a variable and return that. The error says that my return type is not valide. What should I use other than 'String' prob just something small I missed.

function RegisterFunction():return String
{
    var RegisterNameVar:TextField = new TextField;//creating the variable to save the name is this correct?

    addChild(RegisterNameVar);

    RegisterNameVar = RegisterName.text;//equals to the name inserted in the input field

    return RegisterNameVar;
}

Register.addEventListener(MouseEvent.CLICK,RegisterUser);

function RegisterUser(event:MouseEvent):void
{   
    testOutput.text = RegisterFunction();//testing if it received the name correctly
}
phfilly 26 Junior Poster

We once did a project with a kind of chess game. But that is very broad and needed all kind of c++ skills. Do you have a kind of game in mind? Cause it such a large field(complex game/simple game?). You can even do a rock paper scissor game which isn't that hectic.

phfilly 26 Junior Poster

Have you tried doing some of it yourself?

phfilly 26 Junior Poster

I agree with NicAx64 using a stack will help with this. This link will show you some examples http://www.cplusplus.com/reference/stl/stack/push/

phfilly 26 Junior Poster

This link will help with the srand function http://www.cplusplus.com/reference/clibrary/cstdlib/srand/. The site helps with some basic c++ theory and functions.

phfilly 26 Junior Poster

@Techite - don't do the program for him! He first needs to show his attempt (according to Daniweb rules) and then you help him from there!

Nick Evan commented: Indeed +14
phfilly 26 Junior Poster

"Life is either a daring adventure or nothing" - Hellen Keller

phfilly 26 Junior Poster

Hi guys

Just wandering what your thoughts are some off the Samsung Andriod phones? I'm considering getting myself the Samsung Galaxy S2? Don't have the cash yet for the S3 - and is not yet launched in my country.

phfilly 26 Junior Poster

Hi the code is a bit difficult to read in this format bot non-the-less I'm going to try help you. You know that your javascript needs to be coded in your head tag?Or did you only just copy the relevant code? Cause most of the times the browser doesn't always read the script tags correctly if it's placed outside of that head tag. I've seen cases where it's also placed outside the body tag. Just something I learned from personal experience. And what do you mean by

so basically when you hover over a td it goes to a other div.

phfilly 26 Junior Poster

Is the script tag in the <head> tag and was your form tag in your <body> tag? It doesn't seem so? That would be my guess...

phfilly 26 Junior Poster

I would write it like this just an example

$userName = $_POST["username"];
            $pass = $_POST["password"];
          
            $register = "INSERT INTO mytable(Username,Password) VALUES ('$userName','$pass')";
            
            if(!mysql_query($register)){
                die ('Error could not add value' . mysql_error());
            }

Check maybe with a mysql_error() tag at the end

phfilly 26 Junior Poster

Hi All!

I've got a weird problem here...It doesn't want to add my int values to a char array even though I static_cast the value to char.

If you could just look at my code please!

void AltBoolean::print(){
  
 perma = new char[arraySize];
 int temp;
 int counter = 1;

  for(int i = 0 ; i < arraySize ;i++)
  {
      if(ChoiceArray[i] == 0)
      {
	perm[i] = ArrOperator[i];
      }
      else if(ChoiceArray[i] == 1) //it doesn't go into this part of the function it seems!
      {
	cout << "this doesn't even print" << endl;
	temp =  ArrOperand[counter];
	static_cast<char>(temp);
	perm[i] = temp;
	counter++;
      }
  }
  
  for (int d=0; d<arraySize; d++)
    cout << ArrOperator[d];

    for (int e=1; e<arraySize; e++)

	cout << ArrOperand[e];

    
    for (int r=0; r<arraySize; r++)
    cout << perma[r];

}

Declared the array's as follow:

bool *ChoiceArray;
int *ArrOperand;
char *ArrOperator;
char *perm;

The above is initialized correctly! and I checked for that...think its something with the static cast/converting area.

my arraySize is 3 here and the bottom for-loop for the ArrOperator and ArrOperand prints fine! but in the perma arr it doesn't print the ArrOperand part!

Also in my ChoiceArray it only consists of 0's and 1's!

Any help will be appreciated...thanks !

phfilly 26 Junior Poster

Think WaltP just posted wrong!

phfilly 26 Junior Poster

you can't return anything in your "void main()" function as you did in line 47.... though I use an int main().

phfilly 26 Junior Poster

I see the thread is solved-and just I want to know the same thing...could you maybe post the conclusion?

phfilly 26 Junior Poster

Thanks veedeo!Going to try that aswell!

phfilly 26 Junior Poster

Ahh Thank you very much! I'll check it out!

Not a problem! Just glad for some help! :)

Will post when I succeed!

phfilly 26 Junior Poster

"And then I send it to my .php file via <form method="post" action="index.php" enctype="multipart/form-data"> " is in the post... I only included the parts that is necessary though...as you can see!

phfilly 26 Junior Poster

just spit balling here but does GW_UPLOADPATH include the new directory? for example the file your pictures are in?

And i would do it like

echo "<strong>gw_uploadpath with screenshot 4:</strong><img src='.GW_UPLOADPATH.$screenshot.'><br />";

cause i'm also having a kind of similar problem in my thread.../threads/388028

phfilly 26 Junior Poster

you guys can disagree with me...but it sure helped me!

Start by following the php tutorials on - http://w3schools.com/php/default.asp
It doesn't go into much dept but gives you a good overview!

And then for my database I used mysql.
Then I found this site with all you need php files - It has mysql and apache installed on it and is very easy to use! You only need to download and install it.

Here is the link: http://www.easyphp.org/download.php

Oh and I use SciTE as the text editor- its freeware but not as nifty as the other editors out there but it works!

phfilly 26 Junior Poster

I just wanted to test the cmp value. The Loop is actually for something else I just couldn't understand why it doesn't compare.

Thanks diwakar wagle it makes sense to me now!

And yes that is correct AceStryker!

Thanks for the help guys! After a day of searching I got myself a nice assembly online tutor which helped me alot!

phfilly 26 Junior Poster

Hi All!

I got a problem with one of my files where I can't upload a file to my database. I want to save the path in the db but it gives me an error and says the "Filename cannot be empty".

In my .html

Upload a profile picture(50px X 50px): <td><input type="file" name="file" value="Choose a file" id="file"/></td>

And then I send it to my .php file via <form method="post" action="index.php" enctype="multipart/form-data"> In my php I test if it has an jpeg,png etc. extention

$image = $_FILES['file']['name'];
                $error = false;
                
                if($image){
                    $filename = stripslashes($_FILES['file']['name']);
                    $lastpart = getLastExtention($filename);
                    $lastpart = strtolower($lastpart);
                    if (($lastpart != "jpg") && ($lastpart != "jpeg") && ($lastpart != "png") && ($lastpart != "gif")) 
                    {
                        echo "<script type='text/javascript'> alert('Please upload a valid profile picture!'); </script>";
                        $error = true;
                    }
                    else
                    {
                        $image_name= $userName.'.'.$lastpart;
                        $newname="Images/".$image_name;
                    }
                    
                }   
                
                if(!$error){
                    $data = copy($_FILES['file']['tmp_name'],$newname);
                    
                    $result = "UPDATE mytable SET Profile_Picture = '$newname' WHERE Name = '$theName'";
                
                    if(!$result){
                        echo "<script type='text/javascript'> alert('Please upload a valid profile picture!'); </script>";
                    }
                }
                
                function getLastExtention($string){
                    $dot = strpos($string,".");
                        if(!$dot){
                            return "";
                        }
                        $len = strlen($string) - $dot;
                        $extent_part = substr($string,$dot+1,$len);
                        return $extent_part;
                }
                
                if($image){
                    $query = sprintf("INSERT INTO mytable(Profile Picture) VALUES ('$image')");
                }
                else{
                    echo "No Profile picture was uploaded!";
                }

I think I'm just missing something small! Or is there another way to move the uploaded file to a specific directory?

Any help welcome :D - still learning!

P

phfilly 26 Junior Poster
phfilly 26 Junior Poster

Ola!

I'm still kind of new with the whole assembly language and just need some help with this program i'm writing.

What I want it to do is to ask a question -like for a number and then store that inserted number in a variable. And then test whether its bigger than 14 which I declared as a variable already as shown below-and then there is a loop to ask again what is the number. So I want the loop to run as many time the number the user entered.

output db 10,13, "Enter your number: $"
asq dw 10,13, "$" ; ascii values for a new line
stilltoimplement db 10,13, "Do calculations later on $"

.code 
    
jmp start 

    number db ?
    max db 14 ;max number
    
start:
    mov ax,@data 
    mov ds,ax
    
    mov ah,09 ;prints new line
    mov dx, offset output
    int 21h
    
    mov ah, 01 ;checks for key
    int 21h
    mov number, al
    
    cmp max,number
    jg start
    jl part2

part2:

    mov ah,09
    mov dx,offset stilltoimplement
    int 21h
    
ending:
    mov ah,4ch
    mov al,00
    int 21h ;End the program
    
END

It gives me an error in where I try to compare the two variables and says Illegal memory reference. Prob just something small

Any help will be appreciated!

Thanks

phfilly 26 Junior Poster

ah thanks for the help! Much appreciated!

phfilly 26 Junior Poster

Awesome! Thanks once again!

Didn't really know about the type="image" statement. Yet so your learn!

phfilly 26 Junior Poster

The french have some weird bursts of energy in games...Maybe they'll surprise you but I think NZ will take it

phfilly 26 Junior Poster

Can you maybe post the html file?

phfilly 26 Junior Poster

Hi!

I would just like to know if its possible to give an linked image the ability to send the form instead of a submit button? Like in the example below:

<form method="post" action="Search.php">
            <table id="search">
                <tr>
                    <td>
                        Search:  <input type="text" name="search" id="search" placeholder="Search for friends"/><td><a href="Search.php" action="Search.php"><img src="graphics/search.png" id="search_pic"/></a></td>
                        <input type="submit" id="submit"/>
                    </td>
                </tr>
            <table>
        </form>

Because I don't want a submit button. I want to use the picture to send the forms data instead of the actual submit button.

In the receiving file Search.php

$request  = $_POST["search"];

and it doesn't receive the value "search"

phfilly 26 Junior Poster

Your problem is that in your php file you declare your box1 and 2 as id's but you never use them in your actual style sheet!

So in your stylesheet it should be

#box1 {
	position: absolute;
	left: 100px;
	top: 100px;
}
#box2 {
	top: 100px;
	position: absolute;
	right: 100px;
}

Remember the "#" sign in order to connect to your id's. Then also just a pointer- don't use "px" cause it will differ on everyone's screens! use the "%" value...

Hope I could help a bit!:D

phfilly 26 Junior Poster

Hi!

I would just like to know if its possible to give an linked image the ability to send the form instead of a submit button? Like in the example below:

<form method="post" action="Search.php">
            <table id="search">
                <tr>
                    <td>
                        Search:  <input type="text" name="search" id="search" placeholder="Search for friends"/><td><a href="Search.php" action="Search.php"><img src="graphics/search.png" id="search_pic"/></a></td>
                        <input type="submit" id="submit"/>
                    </td>
                </tr>
            <table>
        </form>

Because I don't want a submit button. I want to use the picture to send the forms data instead of the actual submit button.

phfilly 26 Junior Poster

Thanks for the reply! I tried an alternative with just the

header("location:Not_Registered.html?msg=$msg");

And then from there you can navigate back to the login.html

cwarn23 commented: Good response. Love the easy answers :) +12
phfilly 26 Junior Poster

Just something small and I'm not sure how to do it. What I want to do when the user cannot be found in my DB then it should:

1. Print out -I wanted to use a pop-up to inform the user that he has entered incorrect log in details. Which I echo'ed with Javascript

2. Then after the popup the user should return to the Login.html. Because currently it just executes the header function straight without acknowledging the echo


Below: Login.php

if(mysql_num_rows($result)){
                                $user = mysql_fetch_assoc($result);
                                echo '<h1>Welcome, ';
                                    echo $user['Name'];
                                echo '</h1>';  
                            }else{
                               echo "<script type='text/javascript'>alert('Please enter your correct account details');</script>";
                               header("location:login.html?msg=$msg");
                            }

I'm a bit new with the whole php thing-still learning! :)

Any help will be appreciated!

Thanks

phfilly 26 Junior Poster

why use a loop to find the user info? why not just grab that specific user's data from the table in the first query

$result=mysql_query("SELECT * FROM mytable WHERE 
Email = '".mysql_real_escape_string($myMail)."' AND 
Password='".mysql_real_escape_string($mypassword)."'") or die(mysql_error());
if (mysql_num_rows($result)==0){echo "user not found";}
else{
   $user=mysql_fetch_assoc($result);
   echo $user['Name'];
}

Thank you!It works!!Didn't really know about the mysql_fetch_assoc function but sweet! And so you learn!

@evstevemd - I checked it out-and it's definitely what I was looking for-just a lot of video's though- I'm capped with my BW :/ but non the less Thanks

phfilly 26 Junior Poster

My connection works to my database! It prints the "Connected" string so that is fine...this is not the problem

I can't retrieve the data from the table...although the connection is made and correctly spelled

phfilly 26 Junior Poster

Ok one thing I changed in the while loop the

while($rows = mysql_fetch_row($result)){

TO

while($rows = mysql_fetch_array($result)){

so the error is gone but still I can't retrieve the name of the database/table :/ it just gives me "No Name"

phfilly 26 Junior Poster

Hi guys!

I got a problem with my logging in system. I can connect to my database with the code:

session_start();
                        
                        include('header.html');
                        $page_title = 'Home Page';
                        
                        
                        $mail = $_POST['email'];
                        $password = $_POST['password'];
                        $msg ='';
                        
                        if(isset($mail,$password)){
                                $con = mysql_connect('127.0.0.1','root','');
                            
                                if(!$con)
                                {
                                    die('Could not connect: '.mysql_error());
                                }
                                else{
                                    echo "Connected!";
                                }
                        }       

$db_found = mysql_select_db("dbusers", $con);

Then I connect to the table and I want to retrieve the registered users details from the table "mytable" and then I want to greet the registered user with by his name.

$myMail = stripslashes($mail);
                            $mypassword = stripslashes($password);
                           
                            $sql ="SELECT * FROM mytable WHERE Email = '$myMail' AND Password='$mypassword'";
                            $result = mysql_query($sql);
                            
                            $sql2 ="SELECT Name FROM mytable WHERE Email = '$myMail' AND Password='$mypassword'";
$name = mysql_query($sql2);

No I run through the "array" to find the name according to the email and password

while($rows = mysql_fetch_row($result)){
                                if($rows['Name'] == $name ){
                                    echo "<h1>Welcome $name </h1>";
                                }
                                else{
                                    echo "No Name";
                                }
                            }

But the error states:

Notice: Undefined index: Name in C:\Program Files\EasyPHP-5.3.8.1\www\Login.php on line 46

Ok I understand it but the in my table in columns name is "Name" correctly spelled.

Its prob just something small...just need a fresh mind to help me :D

Sorry for the long post.

Kind Regards

Philip

phfilly 26 Junior Poster

have you maybe tried in you compiler:

gdb -tui your compiled executable file (ex. task)

It helps to detect segmentation faults

phfilly 26 Junior Poster

I'm not really an expert but just to give you some advice,cause I know seg faults really makes one just want to give up. You probably know but just check for where(normally in for-loop) tries to access or create elements outside of the range of the array.

Like is all your variables initialized to the correct size,not really sure how you initialized your row variable? Is it through the vector?

Templates with vectors not really my specialty still need some experience in that area.

Hope I could help you only a bit...

phfilly 26 Junior Poster

take a loot a bit at this thread.

phfilly 26 Junior Poster

Thanks for help!

phfilly 26 Junior Poster

Hi Everyone

I'm busy preparing for my programming examination and I would really appreciate it if someone could just give me some references(websites) to some c++ programming exercises. I believe the best way to prepare for this kind of examination is to practice writing code and understanding it.

Thanks!

phfilly 26 Junior Poster

How I Met Your Mother
Big Bang Theory
Scrubs
Two And A Half Men

ALL THE BEST!!

phfilly 26 Junior Poster

Heard there's an up coming Star Wars 3-D movie!Not sure of which one,think it is a remake

phfilly 26 Junior Poster

Crystal Clear from Young guns

phfilly 26 Junior Poster

have you tried it in Linux? Or do you only use Windows 7 and XP?