I can find it in 10 seconds with Google, it doesn't need a discussion!
I think I beat your time. Took me 6 seconds.
http://stackoverflow.com/questions/5963182/how-to-remove-spaces-from-a-string-using-javascript
I can find it in 10 seconds with Google, it doesn't need a discussion!
I think I beat your time. Took me 6 seconds.
http://stackoverflow.com/questions/5963182/how-to-remove-spaces-from-a-string-using-javascript
Come on. What are you asking?
Do you need to be professional to earn money?
It's in the word.
Do you need to be the best? No, many mediocre developers get paid just fine.
You should load in all the words in a PHP array.
As milil suggests, this will take up a lot of memory. Basically consider the size of your text file, and expect to need this much memory (RAM) on the machine that will run this script. In addition you will need to set the php directive for maximum allowed memory usage, do this with the function ini_set.
Set up a loop that will combine all your words, and then output that word to a text file or flush it to echo (display on screen). If you have enough memory and also need to post process the words, store them in memory, that's faster.
It makes perfectly sense. Your delete function loops through your array, when it finds the element you want to delete it REPLACES this element with the previous element.
If you want your strategy to work, I suggest creating a temporary array by looping through all the elements, like you do now, but for the condition do:
if(i != x) addElementToNewArray
Thanks for all your answers.
I was sure I tested whether the output from the Java code corresponded to PHP's md5()
function, but apparantly I did something wrong. Because I see @cereal was right actually.
Sorry for not noticing this myself!
Thanks again.
Update: I manage to verify that Java code does actually represent the hashing algorithm used by the Flash application.
Mystery solved so far.
Am opening a new thread as for how I recreate this hashing method in PHP (http://www.daniweb.com/web-development/php/threads/481298/converting-java-hash-method-to-php).
Hello,
I hope someone is more knowledgeable in Java than me while still knowing PHP!
The following Java code makes a hash from a string, and I need a PHP equivalent that makes the exact same hashes.
Simply md5() does not do the trick, and I looked at some PHP libraries for BigInteger but maybe it is over-kill to include all sorts of third party libraries?
public static String encrypt( String source ){
String md5=null;
try{
MessageDigest mdEnc = MessageDigest.getInstance("MD5"); // Encryption algorithm
mdEnc.update(source.getBytes(), 0, source.length());
md5 = new BigInteger(1, mdEnc.digest()).toString(16); // Encrypted string
}
catch(Exception ex){
return null;
}
return md5;
}
Thanks!
So I found a piece of Java code in the folder with the Flash application. It has some MD5 going on. I have absolutely no clue if it is related or how to execute this to see if it gives the same hash output, so I'll just throw it out there.
public static String encrypt( String source ){
// String toEnc = "Encrypt This!"; // Value to encrypt
String md5=null;
try{
MessageDigest mdEnc = MessageDigest.getInstance("MD5"); // Encryption algorithm
mdEnc.update(source.getBytes(), 0, source.length());
md5 = new BigInteger(1, mdEnc.digest()).toString(16); // Encrypted string
}
catch(Exception ex){
return null;
}
return md5;
}
Hello Daniweb,
I'm rebuilding a Flash-based website in PHP/HTML maintaining the same MySQL database.
My problem now is, the user passwords are hashed of course - I need to use the same hash in the new application for old users to be able to still log in. But since the Flash-based application is compiled and I don't know what method was used, I'm kinda lost.
Maybe there is no easy way to recognize the hashing method, but hoping someone knows more than me I am posting this asking for your suggestion.
When I create a dummy user with password '123456789' (w/o quotes) ends up in database hashed to: '25f9e794323b453885f5181f1b624d0b' (w/o quotes).
Any suggestions are welcome!
I too think you need to use the OR operator. You can still use the and operator, like this
SELECT * FROM table WHERE field1 = 'something' AND field2 = 'somethingelse' AND (field3 LIKE '%word1%' OR field3 LIKE '%word2%')
Are you simply asking for something like
SELECT * FROM table WHERE word = 'Example' OR word = 'Another example'
If not, I don't understand what you are asking for.
In short, this would be a bug. Too harmless for anyone to care go through the incredibly backtrace of debugging it.
Thing is, graphics software and drivers are extremely complex and much can and will go wrong.
Maybe your computer is set up to use a given color profile, and then your buggy flash application (be it a game or an ad) mismatches with this color profile, and then show "nothing" (in the context of the application) - thus rendering the content beneath as per the graphics driver definitions.
I'm not an expert on the subject, but this is my idea from experience with working with and developing all sorts of applications.
Your example makes little sense.
You want to unset $dates
but I don't see it's definition. If you are trying to unset the array you are currently looping through, then you are asking for trouble.
Please be more specific in your code snippet with what and where you want to do this, so we know the whole scenario. Also, when you say you tried a few things, and it didn't work.. Let us know, why it didn't work: what happened?
You are not even mentioning what database type you would like to access.
If you just need any, then have a look at LiteSQL - easy to use and first few results already talks about C++. However this one is typically locally stored.
Maybe you want a more typical network-accessed database like MSSQL or MySQL?
If you specify this in your own Google searches, I think you will have much more success in finding a good library for implementation. But if you are a beginner to C++, you will learn MySQL implementation can be a little challenging.
Good luck.
Your post is a bit confusing, also 'dfml' has 32 values, not 15.
If you want to reference a specific key in an array you simply write $arrayName['dfml']
.
If you want to loop through all the values of an array, use foreach.
foreach($arrayName['dfml'] as $itemNumber => $oneItem)
{
echo "Item number $itemNumber is: $one item <BR />"
}
Your code is very messy in my opinion, so a quick glance does not find me your unexpected end of file.
Note it could be a problem if your file was not saved right or uploaded correctly.
But I can tell you your closing bracket on line 538-542 is NOT unnecessary. The displayed code has 12 opening brackets and 12 closing brackets. So maybe you should try and understand why you think it is unnecessary, it could be placed wrong?
Also, all your case
's should be strings. You are switch()
'ing a string $_GET['page']
but you are using constants, example: case action:
.
While it will probably work because PHP is very helpful and convert action
into (string)'action'
when it can't find a matching constant, you should fix it to avoid any conflicts. So put quotes around all those case
's.
Hi there,
When you are updating the text hint with Ajax, your Javascript code looks for the first element with ID="txtHint"
.
But you are creating multiple elements with ID="txtHint"
and so your hint will always be shown in the first row.
To resolve this you need to correlate the Ajax call to a given row and make sure your ID's are unique.
For example when creating a new row (line 98 in your snippet) do something like
var numRows = 1; // keep track of how many rows you have
$('#addmore').on('click', function(){
numRows++; // when adding a row, increment the count
...
data += '<input type="text" name="conn_type[]" id="conn_type" onChange="showptype(this.value, \'txtHint' + numRows + '\');">...<div id="txtHint' + numRows + '"></div>...';
// use the number in the ID of your element ^ and when calling Ajax
...
}
Now you just need to use the second argument of showptype to find the right txtHint.
function showptype(str1, txtHintID) // second parameter added
{
if (str1=="")
{
// we use the variable txtHintID which should contain fx "txtHint2" or "txtHint7" depending on the row called from
document.getElementById(txtHintID).innerHTML="";
... // and so on, update your other txtHint-references too
This should be more than enough to get you finished.
Remember - always keep unique IDs or things will break ;-)
Hi there,
I think you are trying to import your SQL data into the database 'world', which is highly unlikely yours.
With your web host you will have both MySQL username, MySQL password and MySQL database name. Your database name will probably something generic like your username is (a1581119_ts1).
If you are already trying to import into the right database (maybe through PHPMyAdmin) the problem could be that your .sql dump file is specifically asking for the database 'world' - maybe your old database was named this.
Edit your .sql file and replace occurrences of 'world' with your new database name. It is also possible to remove the specific reference to a given database, but that can be more complicated so try replacing first.
Welcome to Daniweb.
Your post is very lacking - please read: http://www.daniweb.com/web-development/php/threads/435023/read-this-before-posting-a-question
I assume you are referring to something like Apache mod_rewrite (nicknamed prettyurls), but am not going to try and help you until you edit your post to be more specific.
Hi there.
I assume you are using PHP as your programming language. You must use PHP to develop the logic of finding out whether or not something has been clicked on the HTML end.
When your PHP program knows this, fx by the POST-variable you mentioned
if(isset($_POST['like']))
{ // So the LIKE-button was pressed
}
You would add any logic to prevent liking multiple times in there too.
Then you can increment the database value independent of PHP-variables, with the query below. But first, you are saying your table columns "likes" and "dislikes" are varchar-type. Varchar is for characters, and I think you want "likes" and "dislikes" to be a count (number, integer). So please change their type to something like int(11), unsigned optionally.
Then you can do
UPDATE clicks SET likes = likes+1 WHERE user_associated = {$_SESSION['user_id']}
Where $_SESSION['user_id']
being an integer user id, you can change that to whatever variable you use.
I hope this helps.
To be honest, your question is a piece of ****.
You should read the posts on how to write posts.
Your post exclaims that you are getting stressed about your website not letting users register with it - and so what? Do you want us to care?
If you have a specific question, please ask. And be specific.
Read through all of this, then try again by editing your post:
http://www.daniweb.com/web-development/php/threads/435023/read-this-before-posting-a-question
Please improve your post and I will gladly help.
You should always make it as easy for someone to help you, if you want them to answer your question - for free after all.
Important things we want to know:
You are posting 286 lines of code and markup language without in any way hinting where you are having trouble. Including the full code may be useful, but you should point out the significant parts.
To be honest, your question is a piece of ****.
You should read the posts on how to write posts.
First of all you are referring to a report.
Which is many things: http://en.wikipedia.org/wiki/Report
Then you are comparing Visual Studio to PHP - two different things.
Visual Studio is an IDE: http://en.wikipedia.org/wiki/Integrated_development_environment
PHP is a programming language: http://en.wikipedia.org/wiki/Programming_language
Please at least understand the basics of what you are asking for, otherwise we can not help.
Unserealizing the BLOB byte data would be done in a program, probably just like you turned it into bytes in the first place.
I don't think there is a way of doing this directly in the database, and if so, we would like to know what type of database you are using.
Hello Daniweb,
I want to make a custom visitor tracking tool and like Google Analytics it must be able to track how long time visitors spend on each page.
How do you recommend doing this?
I thought of using the Javascript onload event to start counting time serverside and then the onbeforeunload event to do tell the server to end the time count. I'm just skeptic of an infinite visit duration if the visitor's browser for some reason doesn't call the event (ie power outage).
Any ideas? I'm using PHP server side and looking for a most cross browser compatible solution.
I am aware that precise measurement of this is not possible.
Kind regards,
Excizted
Hello,
We are two geeks doing a lot of coding, documentation and designing (PhotoShop, Illustrator, InDesign and FireWorks).
We both carry a laptop, have our personal stationary PC's and then we have a couple o' iMac's that we dedicate to working with these stuff together.
It is important that we can access our files from everywhere.
I've considered a simple FTP accessible NAS on the network of the iMac's (70% of the creativity happens here). But FTP sometimes becomes annoying to use (have to open up FTP application, etc.).
Also I've considered to use Dropbox, but I'm not the biggest fan of cloud storage - it is important to us that these things remains ours and that they are always accessible.
Another issue here is the huuge graphics files that will eat bandwidth everytime we open up another PC.
Well - any - to you obvious - suggestion of software or technology for this scenario?
Have a nice evening.
KVM over IP requires hardware.
Hello,
I have a server that I have decided to divide into VM's using HyperVM with OpenVZ, so that some friends can play around on the server and that I can have several Linux distros on one server.
I am wondering if I should install nothing on the host other than the HyperVM panel, or if I should leave important things like Apache and FTP on the main host rather than in a VM.
If I'd install it on the host OS, I would be afraid that it would interfere with the virtual machines.
But if I create a virtual machine just for some software which could just run on the host OS, then the virtual machine will waste resources for the OS used in the VM?
Please advice, thanks :)
You would want a KVM switch.
There is no serious software to do this.
The easy answer is physics & "soft" targeting. Apply your x/y/z acceleration to the object, having it move toward the current node/point/target and once it gets within a pre-defined distance to that target, set it's new target to the next point and accelerate the object toward that new target. This should give a smooth transition, as long as you're not using a pure xVelocity = 2.0 type statement, but positive & negative acceleration.
Thank you will try that and work my way from there! :)
This is the most correct way to do it.
Alternate methods are C ways, and is shouldn't be used in C++ :)
I have done as instructed, and the person is able to enter a value, but then it says that Fahrenheit is uninitialized, I don't know how to take the value that a person entered and put it in the cout as well. Take a look.
#include <iostream> #include <iomanip> #include <fstream> using namespace std; float FahrenheitToCelsius(float); int main() { float fahrenheit; char input[10]; float celsius; int choice; do{ cout << "This program converts fahrenheit to celsius" << endl << endl ; cout << "Please Enter Fahrenheit Degrees: "; cin >> input; for(unsigned int i = 0; i<10; i++){ if (input[i] == '\0') break; if(!isdigit(input[i])){ cout <<"Please Enter Digits "; } } cout << "Your Conversion Is: "<< fahrenheit << " Degree Fahrenheit to:" << endl; cout << FahrenheitToCelsius (fahrenheit) << fixed <<setprecision(2) <<" Degrees Celsius."; cout << "Want To Play Again?"; cout << "1 == Yes"; cout << "2 == No " << endl; cin >> choice; } while (choice == 1); cin.get(); return 0; } float FahrenheitToCelsius(float fahrenheit) { return fahrenheit = (5.0/9.0) * (fahrenheit - 32); }
Sorry my bad.
This means that float fahrenheit has not been assigned a value.
You will have to convert the input string to a floating numeric value, after validating it.
You will have to #include <stringstream> also.
After line 26, you would have to do the conversion like this:
stringstream convert;
convert << input;
convert >> fahrenheit;
isdigit checks a character if it is a digit character.
The user entered string is parsed into a float (float fahrenheit; on line 10) and is automatically (if possible) converted to a digit.
This means you will not be able to check if the entered string was letters or numbers.
You would have to read the cin to a character array instead, and then check each character for validity.
You could do something like this:
char input[10]; // max length is 9 (tenth place is needed for terminating null)
cin >> input;
for(unsigned int i = 0; i < 10; i++) // 10 again, as we wrote it in input size
{
if(input[i] == '\0') // we have reached the end of the input
break;
if(!isdigit(input[i]))
{
cout << input << " contains invalid characters." << endl;
return -1; // exit program
}
}
Well you have some serious issues there.
On line 20 you try to cout a function. Uh-oh, that does not work at all.
You would write
cout << FahrenheitToCelsius(fahrenheit) << " Degrees Celsius";
Also, on line 32 your function definition mismatches the declaration up on line 6.
Make sure both lines read
float FahrenheitToCelcius(float fahrenheit)
Also, delete line 13.
I am surprised you say it crashes. I wouldn't think this would even compile.
Please make the corrections I suggested and post back with your results :)
Ps. You might want to call it function not subprogram, although it is probably not wrong ;-)
Well obviously your client has given you the wrong details somehow.
It can not be your problem, that your clients webhost is unreliable.
You could tell him to get it fixed with his hosting provider, or ask him to look for a new webhost like www.webhosting.blanye.pro
No, Ruby on Rails does not do all this for you. You have to work with the Javascript yourself.
Here is a relevant example of serialization, meaning writing the data binary.
class Matrix
{
public:
Matrix()
{
x1 = x2 = x3 = y1 = y2 = y3 = z1 = z2 = z3 = 0.f;
}
float x1, x2, x3, y1, y2, y3, z1, z2, z3;
};
int main()
{
Matrix myMatrix;
fstream stream("file.bin", std::ios::write | std::ios::binary);
stream.write((const char*) &myMatrix, sizeof(Matrix));
stream.close();
}
I skimmed both these links (and the downloadable material), but I do not understand how it relates to the goal I have (and is demonstrated on the Valve PDF, page 14).
Could someone explain?
Edit: Ps, I do not need to generate a path, I just need to make the moving along the path more realistic, by not following it exactly, as it is jagged.
Hello Daniweb,
In 3D space I have generated a path which jumps between points in a grid of 100x100x100.
When simulating movement through this path, I tried making a bezier curve of the points in the path, but the results were not good enough.
I googled a lot, and the closest I came to success was this article from a game developer (http://www.valvesoftware.com/publications/2009/ai_systems_of_l4d_mike_booth.pdf, page 14) - something called reactive path following seams to be good for my purpose.
I am not sure at all, how I would get on to do this.
I thought of choosing a random number (2-6 or something) of points ahead the current point and then move to that position, but it simply seems to random and would make the bot run confused around.
I also thought of finding the point on the path, which is closest to being directly in line of sight of the current position, and move there.
But what if that selected point is like the end of the path, 2.5 kilometers away and crosses a lot of walls? - Furthermore, the point the bot moves to would continuously be the point directly in front of it, so it would not get far.
I hope anyone has advice or articles on this subject.
Thank you :)
Initially store the descr of the selected one (get it from mysql).
Then in your while loop, you check if $r == $your_new_variable;
If it is, then you echo "selected" in your <option> tag.
Omg use google, this is a broadly discussed topic.
if (mysql_query("SOURCE file.sql"))
{
echo "success";
}
When an average user demands to run Windows app on Linux, what he/she actually conveys is "I'm not satisfied with what comes with Linux as alternative". OOo is regarded like "MS Office 10 years ago". There're no equivalents of Adobe (GIMP? no, thanks) or Autocad tools. Even Nokia does not supply a Linux version of Ovi/PC Suite.
Wine is only an experiment on code reversing. Woe betide on whoever considers it seriously.
People don't ask Apple to run Windows apps because MacOS users are not constantly irritated by anti-Windows fanboys to ditch their OS and use Linux instead.Retail (closed) software on Linux is not viable. There's not a distro-independent packaging format embraced by all distros. There's not even a release-independent packaging policy for a distro, and major distros release twice a year. Will you spend time with developing software or packaging software? Overall, the Linux world does not welcome closed source. When you open the source you cannot make money by selling license, maybe only by selling support.
Like your thoughts. Totally flameable, but worth thinking about.
Very helpful post, thanks Excizted. Do you use Fedora, Ubuntu, or some other distro?
I use Ubuntu mostly with NetBeans IDE 6.9 (6.8 is in Software Center, but 6.9 is much faster - do the manual install!!)
It is perfect for anything from big commercial projects to quick small scripts for myself.
Finally I have gotten my hands on an extra nvidia graphics card for PCI Express x1.
I'm really putting my hair out, as it totally seems I cannot have whats called twinview across multiple GPU's.
I can choose to have separate X screens, but it is not very productive as I can't drag my windows to all the monitors.
Whats even worse, I tried out booting Windows and it was 1-2-3 and I had all monitors set up and could drag windows around with no issues at all.
I really hope there is a way, or plans to help this issue?
Super.
I may look for a standard-PCI graphics card then.
Would it by any chance be better worth upgrading motherboard?
I could achieve USB 3 by that, but will most likely have to upgrade to DDR3 RAM aswell.
Should I wait with this, and let the PCI graphics card be a relatively short investment?
This thread is 8 months old, lol :)
I learnt this long ago, but thank you anyway I guess.
Those persistant cookies are just the regular cookies you set with setcookie()
.
They persist UNTIL DELETED - by you, the user, the browser or anyone else with access to them.
also, what is a session? why do sessions have expiry if it only lasts for a session when u can set the expiration makes no sense. also what is a session efined as when the user closes the browser? NO i have closed my browser many times and been still logged in
Modern browsers as Firefox has option to remembers your session for next time you open it, keeping all your webpages/tabs open.
Since the session isn't reset, so isn't the variables linked with a session.
I haven't heard of persistant cookies.
Imagine if a regular webpage could enforce cookies not to be deleted.
How would user keep that website from loading down 10GB of cookie on his computers?
How would he uninstall his old browser to start using Chrome, Firefox, whatever instead?
- The cookies can't be deleted, so guess the uninstaller will fail, no?
Then what when he wants to switch to Ubuntu from Windows. He can't remove Windows from his harddisk, because of the cookies that are immortally un-destructible.
What will still keep him from inserting a new harddrive in his computer? The cookie will die in some way unless you burn it to his flesh. Oh wait, todays doctors just transplant the skin.