rotten69 20 Posting Whiz

Hi there,

I've been reading a book on c# and come across a method that is EnsureCapacity on StringBuilder which from understanding it makes sure that how much capacity a variable can hold.

What I made is a variable and then tested it.

StringBuilder st = new StringBuilder("string builder"); // the length == 14


When I call the EnsureCapacity on this variable,it gives me 16. However, it gives me the exact length of the variable if and only if I explicitly specify the maxCap when initialise my variable like so.



new StringBuilder("string builder", 14);  14 or less

thanks..

rotten69 20 Posting Whiz

Hi everyone,

I'm learning C# at the moment and really enjoying it. I'm wondering though how I can develop my own algorithms. do I need to read on data structures and algorithms?
Is there a book for all programming languages so you can apply the knowledge to basically any programming language you use (E.g Java, C#, PHP, JavaScript, Python..etc)?

Links will help also.

thanks,

rotten69 20 Posting Whiz

Salam alikum wa rahmat allah wa brakatah, Faisal. I think that depends on your software requirements. Having said that you can pretty much do both, creating a new database or/and connecting to a previous database. This depends on the way you set up your project.

I'm assuming that for a local database (the one gets shipped with a piece of software and gets installed automatically on user's machine to store online content and make the content easily accessible when the user is not connected to the internet) might be a little hard. Unless you know where it is stored on the user's machine and doesn't get deleted after a newer version of your software is installed.

I hope that answers your questions.

rotten69 20 Posting Whiz

Hmmmm, I can see a few things that don't seem quite right in the SQL statements you've got in there. Firstly, make sure that the connection to your database is established without any errors. Secondly, have a look at table names and fields that you're trying to query.

With the first query, Wouldn't you have something like this

"SELECT * FROM Convocations 
WHERE Name LIKE = 'txtFilterParameter.Text'  
ORDER BY  getSortField() , getSortDirection()";

The second query is:

"INSERT INTO Convocations (Name, Classification, Date, Location) 
 VALUES ('Name', 'Classification', 'Date', 'Location')";

You may or may not need the single quotes around Name, Classfication.. so on.. That depends on how you've set up your script. I'm assuming they're variables?

I hope that helps..

rotten69 20 Posting Whiz

I'd make the account number as a primary key/unique in the database so that way you can pretty much avoid any misleading voilating numbers given by customers because they don't really know what numbers are stored.

rotten69 20 Posting Whiz

That helps, thanks. Sorry to ask too many questions in one thread. What is OP kudos?

rotten69 20 Posting Whiz

Thanks. I already had a look at it but it didn't help much.

rotten69 20 Posting Whiz

Hi there,

I'm reading a book on Javascript and trying to understand a few concepts that are about hasOwnProperty(), propertyIsEnumerable() and isPrototypeOf(). I don't understand when and how these methods are used. That would so appreciated if someone can explain them to me in a nutshell.

This example is from the same book:

var o = {};

// how do we read the line below ?????
Object.prototype.isPrototypeOf(o);                 // true: o.constructor == Object
Object.isPrototypeOf(o);                           //false
o.isPrototypeOf(Object.isPrototypeOf);             // false
Function.prototype.isPrototypeOf(Object);          //true: Object.constructor == Function
rotten69 20 Posting Whiz

There is another way of making your code too difficult to read by obfuscating your code(instead of having line by line code. it is all mashed up in chuncks). That way you can make code stealers go away once they look at your code. Although, they can still use tools to get the code easy to understand. Or it might be a good option to disable a right click action when they try clicking right click -> view source.

At the end of the day, the web is massive and you're trying to prevent your code from a wide variety of people, it is hard.

rotten69 20 Posting Whiz

You may need to have a look at this website and another one

When they generate a CSS3 code, it is explicitly mentioned that what browser is supported

I hope this helps

rotten69 20 Posting Whiz

I'm sorry I think I am not understanding the question in the first post. Why don't you use HTML&CSS and JavaScript(if needed)?

rotten69 20 Posting Whiz

what is a skill endoresement?

rotten69 20 Posting Whiz

Hey everyone,

I'm wondering why my reputation points don't go up when people give my posts in thier threads a vote-up.

Cheers,

rotten69 20 Posting Whiz

it is a good idea to use var when declaring variables. E.g var number. The reason being is that your variables will be easy to trace and and it is a good practice.

I guess you're trying to add the value to the textbox you've got there, right?

Try this

 document.divfrm.div.innerHTML=d;
 document.divfrm.div.innerHTML=sp;
rotten69 20 Posting Whiz

If I understand your question correctly, you want to change an image that is already displayed on a page when the title is clicked. You're refering to the title tags in head section, right? if yes so, I don't think you can because I have just tried it and unfortunatley, it doesn't work. However, you can still manipualte the title in jQuery or JavaScript easily.

To solve your problem, you might consider adding a button or making an image clickable when it is clicked then an image is changed.

I hope this helps..

rotten69 20 Posting Whiz

Try to change the data type of result to double and this will give you a fractional number E.g 1/2 = 0.5 rather than 0

rotten69 20 Posting Whiz

TV is communicating with A.C

That would be interesting to see.

rotten69 20 Posting Whiz

You need to make use of sessions as phorce mentioned so you can check when registered users are logged in then they can upload ads and view/delete them. You need to make a log-in script and upload images/content script for ads.

What sort of ads are you gonna be storing in your DB? Are they image based or content based? Think about the size of images? By the way, what is the purpose of this project? Is this part of a big website because the problem you're trying to solve sounds a little small?

rotten69 20 Posting Whiz

I'm happy to do the psudo-code for you as this program is really simple.Although I won't be writing the code. I suggest you write some code following the below steps and once you get stuck, just raise another quetion with the code you've achieved.

make these variables:
1-sum (perhaps global but it doesn't matter in this case)
2-min_num ( it takes in user input)
**3-max_num **(it takes in user input)

then step 4 -> do some checking to see the variables (min_num & max_num) are not empty and contain some values. You'll need to parse them as integers or whatever type you're expecting from your users such as float. It might be a good idea to display a message if users are trying to use your calculator but they aren't entering anything or entering some text which is not acceptable.

5- Use an if-statement to compare min_num < max_num

6- inside your if-statement block.. do your formula. Here where you use the sum to store the result in then return it to users. And if you want to go a little nuts with the result you can say if sum <= 0, then you can return a message to your users saying.. The total is less than or equal to zero.

What is number of integer?

I hope this helps.

rotten69 20 Posting Whiz

solved it.

rotten69 20 Posting Whiz

Hi everyone,

I am trying to compile a sencha touch 2 project to build an android app but it doesn't compile fully and successfully. When I run this command, sencha app build native targeting android/iOS platform.

The error I get is as follows below:

[WRN]           [ [1000] : Yui Compressor Warning <> Trailing comma is not legal in an ECMA-262 object initial
izer =>                     }    ] :: ( C:\wamp\www\sencha-touch\GS\app\view\Blog.js => 24 : 21 )
[WRN]           [ [1000] : Yui Compressor Warning <> Trailing comma is not legal in an ECMA-262 object initial
izer =>                         }, ] :: ( C:\wamp\www\sencha-touch\GS\app\view\Main.js => 13 : 4 )
[WRN]           [ [1000] : Yui Compressor Warning <> Trailing comma is not legal in an ECMA-262 object initial
izer =>                         }, ] :: ( C:\wamp\www\sencha-touch\GS\app\view\Main.js => 17 : 4 )
[WRN]           [ [1000] : Yui Compressor Warning <> Trailing comma is not legal in an ECMA-262 object initial
izer =>             } ] :: ( C:\wamp\www\sencha-touch\GS\app\view\Main.js => 22 : 13 )
[INF]           Processing class inheritance graph
[INF]           Processing instantiation refereces to classes and aliases
[WRN]           [ [1000] : Yui Compressor Warning <> Trailing comma is not legal in an ECMA-262 object initial
izer =>                     }    ] :: ( C:\wamp\www\sencha-touch\GS\app\view\Blog.js => 24 : 21 )
[WRN]           [ [1000] : Yui Compressor Warning <> Trailing comma is not legal in an ECMA-262 object initial
izer =>                         }, ] :: ( C:\wamp\www\sencha-touch\GS\app\view\Main.js => 13 : 4 )
[WRN]           [ [1000] : Yui Compressor Warning <> Trailing comma is not …
rotten69 20 Posting Whiz

Personal area? what are they supposed to do in that area after logging in? Just to view their ads?
so then what happens to the ads that they have uploaded?

it might help us to help you once you answer the questions.

rotten69 20 Posting Whiz

I'm using Firefox.

rotten69 20 Posting Whiz

Hey folks,

I am running into a really good function in JavaScript but I wonder how it is used. I've done a bit of search on how it is used and have seen examples but none of the examples seem to work for me anyway.

it throws an error at me saying "TypeError: window.clipboardData is undefined" on the second line.

`  var a = "hello world";
   window.clipboardData.setData("Text",a);    // TypeError: window.clipboardData is undefined
   alert(window.clipboardData.getData('Text'));

`

Cheers,

rotten69 20 Posting Whiz

You're welcome,buddy.

rotten69 20 Posting Whiz

Oh, I know why this is not evlauting because of the space I got in the button name

<button> day</button> != <button>day</button>

it looks exactly the same but the space needs to explicitly speicified in the condition.

rotten69 20 Posting Whiz

var button = $($(this)).text(); this works fine. but the problem with the if-statement.

rotten69 20 Posting Whiz

The snippet below should solve the problem you had with accessing the array $list [count($value)] which doesn't make sense to me. If you're trying to add the value of count to the array because your previous line stores the number of elements in an array to the index. The way you'd normally do it is $list [] .=count($value) the result you will get is this:
Array ( [0] => 3 [1] => 3 ) However, this won't tell you much about the data stored in the array.

Try this and let us know how you go.

$parent=0;
function getMenu($menu, $parent){

    $list=array();
    foreach ($menu as $key=>$value){

        if($value['parent_id']==$parent){

            $counter = count($value); // count the number of elements in an array
            $list[] = $value;
            echo $counter; 

            echo "<br>";
         }

     }

        return $list;

}

cheers;

rotten69 20 Posting Whiz

Hi there,

am I doing something wrong with the if-statement? it either doesn't evaluate the conditions I've got in there or throw an error.

                $('button').click(function(){

                        var button = $($(this)).text();                     
                        console.log(button);   // this logs the value of button as night or day depending on the button I click

                        if(button == 'day'){
                            $('p').text(button);

                        }else if(button == "night"){
                            $('p').text(button);
                        }
rotten69 20 Posting Whiz

@philip ... Thanks pal for the suggestions, I do appreciate that as much as others do. What we would like to see, if you have enough time to take us through the solutions, is a tutorial(s) in new threads. This would be pretty awesome to see in the Java forum.

rotten69 20 Posting Whiz

by the sound of it, you need something like

<input type="text" name="username" id="login_username" class="login_field" value="<?php if(isset($val = $_POST['username'] ) )
            {echo $val; }
   ?>" />

This is gonna save your users from typing whatever they've typed before if something goes wrong.

rotten69 20 Posting Whiz

I'm thinking of making a simple calculator that does temperture conversion.

rotten69 20 Posting Whiz

That command line didn't do much. The result was Windows Resource Protection did not find any integrity violations.

rotten69 20 Posting Whiz

Will try it and see how things go.

rotten69 20 Posting Whiz

I deleted some of the MSI Files and wasn't sure that they had affect on the installed programs. Now, I can't remove any program from the OS and some programs dont display their icons. is there a program that checks for any missing MSI files and download it possibly?

I'm running a basic version of win7 by the way.

rotten69 20 Posting Whiz

die(mysql_error() ); helps a lot with debugging things.

rotten69 20 Posting Whiz

I solved it. For anyone who is having the same problem, this line needs to be added data-ajax="false" to anchor tags. So you'd end up having a similar line to this

<a href="index.php" rel="external" data-ajax="false"> home </a>

I hope this thread helps you if you're reading it.

rotten69 20 Posting Whiz

Hey everyone,

I haven't recently done my research on this yet. I can recall from memory that I did some short research on storing images in a database and also had some questions answered in the forum about it. Additionally, I was told it is not a good practice to store them in a database because of their size. Now, I'm developing a web mobile app using jQuery for mobile and PHP and want to let users to store their profile image as a thumbnail.

Currently, I can't use the form element "file" to let them upload their profile image but I think there is a way around this which I will be looking into soon.

My questions are: 1- After figuring out the right form element that is used in mobile apps, do I store my user's profile image in the database as blob?

2- Is there a good framework that does the job for us pretty quickly?

I hope to hear from someone really soon.

rotten69 20 Posting Whiz

it is to do with jQuery framework. In php, we have header('Location:yoursite') which I assume does similar thing to server.transfer()..

rotten69 20 Posting Whiz

Hmmm, Enable the error reporting function so you will be shown if there are any errors.

error_reporting(E_ALL);

You've got the class name as sandwich and construct as operation (change the name of the function to sandwich). In OOP, you need to have the constructor name corresponding to the class name. You may make a function called operation and then it gets called in the constructor.

I hope this helps!

rotten69 20 Posting Whiz

Hey everyone,

I'm having a trouble with the navigation bar when redirecting users to other pages. For example, if a user logs in, then they will be redirected to the main page (mysite/index.php) but the url displays as mysite/login.php which is the pure PHP script that doesn't contain any HTML lines in it. I guess that is fine, but the nav bar on the main page disappears unless I refresh the page to get it back.

I hope to hear from someone here. cheers

rotten69 20 Posting Whiz

Thanks guys for the help and suggestions. I will be looking into PDO.

rotten69 20 Posting Whiz

I fixed it already. Cheers for the help, guys.

rotten69 20 Posting Whiz

I tried using (id) but this doesn't seem to be working

rotten69 20 Posting Whiz

Any quick help?

rotten69 20 Posting Whiz

Hmmmm, show us what you've got so we can help you with it.

rotten69 20 Posting Whiz

Hey guys,

I don't see anything wrong in the function but mysql_result is complaining about the parameter value passed to it.

function question_exists($question_id){

    $question_id = (int)$question_id;
    return ( mysql_result(mysql_query("SELECT COUNT('id') from `posts`  WHERE `id`=$question_id"),0) == 0) ? false : true;

    // if the question doesn't exist (equal to ZERO) then return false. Else, return true
}


    $id = '20';

    question_exists($id) =>  this gives me this message "Warning: mysql_result() expects parameter 1 to be resource, boolean given "

Thanks in advance for the help!

rotten69 20 Posting Whiz

it is all fixed now. cheers guys!

rotten69 20 Posting Whiz

yes.I'm calling session_start() in other pages.

rotten69 20 Posting Whiz

Hi there,
I have been trying to fix the problem in the below code for a long time, it did work for me at some point. Then, it suddenly stopped storing user's details in a session.

        $user  = $_POST['username'];
        $pass  = $_POST['password'];
        $query = "SELECT username, password FROM
                  USERS WHERE username = '$user' 
                  AND password='$pass' ";


        $result = mysql_query($query) or mysql_error();

        $row = mysql_fetch_assoc($result);



        if(  $row['username'] == $user ){

            $_SESSION['username'] = $row['username'];
            $_SESSION['password'] = $row['password'];
            header('Location:settings.php');
        }




        and this is the form where the above mentioned script gets the values from




            echo "<form action='log_in.php' method='post' >";
                        echo "<input type='text'     name='username' placeholder='username' "; 
                        echo "<input type='password' name='password' placeholder='password' ";
                        echo "<input type='submit' value='Log in' > ";   
            echo "</form>";