ShawnCplus 456 Code Monkey Team Colleague

No, they can't. That's all stored on the server. Either in the DB or on the filesystem depending on your settings.

ShawnCplus 456 Code Monkey Team Colleague

A great thing about PHP is that because it's so chock-full of crap functions sometimes you find one that's useful :P

php.net/wordwrap

mission_PHP commented: Thanks you have helped rep added +0
ShawnCplus 456 Code Monkey Team Colleague

Other than notepad++ and Netbeans I haven't heard of many other popular programs or none that I can think of.

*cough* vim/gvim/macvim > all *cough* unfortunately : [img]http://www.terminally-incoherent.com/blog/wp-content/uploads/2006/08/curves.jpg[/img]

ShawnCplus 456 Code Monkey Team Colleague

php.net is your friend http://php.net/array_diff

See also
# array_ diff_ assoc
# array_ diff_ key
# array_ diff_ uassoc
# array_ diff_ ukey

ShawnCplus 456 Code Monkey Team Colleague

i=15 Should be i <= 15

ShawnCplus 456 Code Monkey Team Colleague

is MD5 secure? Every place i read of hashing, md5 is being bashed of being insecure

Well if this is true then 99% of the PHP websites out there that do authentication are fucked. :P

Please, explain a little bit

The only use-case for encryption during securing a PHP site is if you want to encrypt passwords rather than hash them. If you encrypt them you can decrypt them and email them back to the user if they lose it. If you hash it you can't do that because it's one way, you'll just have to send a random password back to the user.

ShawnCplus 456 Code Monkey Team Colleague

What books or tutorial (online/downloadable) shall i learn to be able to make secure page? I need to know different technique and algorithms

There aren't really that many techniques (and 0 algorithms to remember) to secure your site. MD5 your passwords, scrub your inputs AND outputs, use prepared queries (PDO). I'm all for being strong in CS but as far as PHP goes unless you're hell-bent on being able to give the user their password back on reset you're not going to be using cryptographic algorithms too much.

ShawnCplus 456 Code Monkey Team Colleague

So I'm using InnoDB and so far it is ok and I will see when I have to restart the mysql service. Because hopefully if it is inserting a record while the mysql service is restarting it shouldn't corrupt the table like myisam does. That is still to be tested. But as for now, I will ask appart from obvious performance what is the difference between InnoDB and Myisam? And yes I read the earlier posts but some of those long words are confusing.

Foreign key constraints, atomic transactions, row-level locking. All-around win.

ShawnCplus 456 Code Monkey Team Colleague

whoops, change document.write(images[index]); to document.write(images[i]);

ShawnCplus 456 Code Monkey Team Colleague
// don't use new Array(3), just use []
var i, images = [];

// use push, don't manually assign the index
images.push("somelink1");
images.push("somelink2");

// shuffle the array
images.sort(function ()
{
    return 0.5 - Math.random();
});

for(var i = 0; i < images.length; i++)
{
    document.write(images[index]);
}
ShawnCplus 456 Code Monkey Team Colleague

try this

function search_highlight($needle, $replace, $haystack)
{
 $haystack = eregi_replace($needle,$replace,$haystack);
 return $haystack;
}
echo search_highlight($searchtext, "<b><font style='color:white; background-color:grey;'>" . $searchtext . "</font></b>", total description);

DON'T use ereg* functions. There's a reason why there are GIANT RED WARNINGS at the top of every page of the PHP documentation with these functions in them. Use preg_*

ShawnCplus 456 Code Monkey Team Colleague

If you're looking to avoid row corruption you'll definitely want to look into atomic transactions http://dev.mysql.com/doc/refman/5.5/en/ansi-diff-transactions.html

But the issue still remains if you restart mysql while updates are still running there's really nothing you can do, you killed the thread it can't recover if it doesn't exist :P

The only situation this solution doesn't handle is when someone kills the threads in the middle of an update. In that case, all locks are released but some of the updates may not have been executed.

ShawnCplus 456 Code Monkey Team Colleague

If tArea is a <textarea> then .value won't work, you'll have to user innerHTML

I am making a little forum and while trying to add the quote post functionality have come across a problem that has me stumped. Here is my js:

function addQuote(text)
	{
		var tArea = document.getElementById('forumReply_message');
		tArea.value = text;
	
	}

Here is sample HTML (one that doesn't work):

<a href="#replyArea" onclick="addQuote('Got a random playlist on right now.  All sorts of stuff... Miike Snow, Galactic, Danger Mouse, Bon Iver, Marlena Shaw, Dirty Projectors... it's eclectic to say the least.');">Quote</a>

I really can't figure out why this won't pass the addQuote() value into the textarea. It does work for some posts but most of them it doesn't. I appreciate any help.

ShawnCplus 456 Code Monkey Team Colleague

No, it's very possible but it's just a plain bad idea. IDs are unique identifiers for the DOM, changing the ID is like giving your social security number to someone else; sure it might work but it's bound to cause issues.

Use css to hide/show either the select or the input and update whatever function is dependent on the ID to support two separate IDs.

Is this your way of saying that you don't know if it's possible to change the id of an element?

Situation is as follows:

Jsp uses xsl to render xhtml. I use java helper method in xsl to create a number of <option> elements inside a <select>. I want to swap / replace this <select> with an <input type="text"> according to an <option> selected by the user in another <select>. For the purposes of submitting the form, the <select> or the <input type="text"> need to be a particular id. Thus, I need to set the id of the elements as one becomes active and visible, whilst the other is hidden and inactive.

If it is not possible to change the id of an element then obviously I will look at another way of doing this.

ShawnCplus 456 Code Monkey Team Colleague

If you have to change the ID of an element you're probably doing something else wrong.

ShawnCplus 456 Code Monkey Team Colleague

How would I go about passing a user agent when requesting an external xml feed from a 3rd party web service. Need to pass the user agent or else the feed produces an error. I am using DOM

<?php
$request1 = 'http://www.abc123.com/webservice/this.xml';

$requestIT1 = $request1;
$response1 = new DOMDocument();
$response1->load($requestIT1);
?>

Thanks in advance!

Google is your friend, 2nd result.
http://www.php.net/manual/en/domdocument.load.php#91384

ShawnCplus 456 Code Monkey Team Colleague
<select name=formdata[Program_val] default value='Null' >Program</option>

Should be this.

<select name='formdata[Program_val]'>
    <option value='Null' selected='selected'>Program</option>
ShawnCplus 456 Code Monkey Team Colleague

it doesnt, the form.php uses the php code, defined in the top of the form.

It has to be sending it accross, as the error contains what i input into the form

If the only way the two are connect is because one page POSTs to the other then you need to have the connection code in both places.

ShawnCplus 456 Code Monkey Team Colleague

Is all of this code on the same page? If the connection isn't opened on the same page as the one that executes it then it isn't defined.

ShawnCplus 456 Code Monkey Team Colleague

What is the value of $db by the way. I don't see you setting it anywhere. Or $cid for that matter.

ShawnCplus 456 Code Monkey Team Colleague

Don't remove ID from the database, just remove it from the field list. Also, what was the error that you got (Not the query, the actual text from ERROR: blah)

ShawnCplus 456 Code Monkey Team Colleague

If ID is autoincrement don't include it in the field or value list.

ShawnCplus 456 Code Monkey Team Colleague

You have a syntax error, you're missing the beginning parenthesis before the field list. Which this line will tell you.

if (!$result) { echo("ERROR: " . mysql_error() . "\n$SQL\n");	}
ShawnCplus 456 Code Monkey Team Colleague

The program fails to build most likely because you have no main() function

#include <iostream>
using namespace std;

int main (int argc, char** argv)
{
  // your program here
  return 0; // successful execution
}
wolfkrug commented: Thanks a lot! +0
ShawnCplus 456 Code Monkey Team Colleague
// add spaces after every 4 digits (make sure there's no trailing whitespace)
somestring.replace(/(\d{4})/g, '$1 ').replace(/(^\s+|\s+$)/,'')
ShawnCplus 456 Code Monkey Team Colleague

remove the href='#' altogether. that is what causes the link to refresh the page or jump as you called it.

An a tag without an href attribute is invalid, it also removes the pointer cursor from the a tag.

ShawnCplus 456 Code Monkey Team Colleague

Find the function that is getting attached to the <a> tags' onclick to actually do the magic and return false at the end of it. That prevent the link from jumping.

ShawnCplus 456 Code Monkey Team Colleague

php <filename> Example: php somefile.php Did you even try to find the answer yourself?

ShawnCplus 456 Code Monkey Team Colleague

Where is script_url defined? Global variables = bad. And do some debugging. replace include with echo to see what the actual value being passed to include is.

ShawnCplus 456 Code Monkey Team Colleague

Do your inputs actually have the ids name email and address. You have to modify the code and your form to have the appropriate ids and the validate_fields array to match otherwise it's not doing anything :)

ShawnCplus 456 Code Monkey Team Colleague
$(document).ready(function()
{
	$('#someform').submit(function ()
	{
		var i,
		    validate_fields = ['name', 'email', 'address'], // fields to validate
		    invalid_fields = []; // store of empty fields
		for (i in validate_fields)
		{
			// check if field is empty
			if ($('#' + validate_fields[i]).val().replace(/(^\s+|\s+$)/g, '') === '')
			{
				invalid_fields.push(validate_fields[i]);
			}
		}

		if (invalid_fields.length)
		{
			alert('The following fields were empty: ' + invalid_fields.join(', '));
			return false; // cancel the form submit
		}
		return true;
	});
});
ShawnCplus 456 Code Monkey Team Colleague

Is your select inside the <form> tag, and do a var_dump($_POST); to see the values of everything passed from the form

ShawnCplus 456 Code Monkey Team Colleague

Sorry VD - I'm no great shakes, but I notice that you are making an amazing contribution at the moment with so many replies - well done! It's just that I've been there and done it with some of these questions - I've had the number of records != max id number in table problem and was stuck for hours trying to figure it out. However, I think there may be an even more sophisticated way of doing it.

I'm not sure that RAND() is truly random - more a quick and dirty randomizer *I think*.

There's no such thing as truly random when it comes to the implementations in PHP or MySQL, it'll always be pseudorandom

ShawnCplus 456 Code Monkey Team Colleague

If the javascript is already on a PHP page then you can just do

var postID = <?php echo $_GET['postID']; ?>

And keep the rest of your code the same.

ShawnCplus 456 Code Monkey Team Colleague

how are you all
I want to write a program where when i enter the number
For example 10
must give the numbers of Singles
1, 3, 5, 7 and 9

please its important

What do you have so far? We're not going to help you if you don't show effort.

ShawnCplus 456 Code Monkey Team Colleague

hey ardav! you always contradict at my every post! grrr....! :@

Well, ardav is correct so he is completely within his right to make a post :)

ShawnCplus 456 Code Monkey Team Colleague

u forget to show the code... well based in your problem i think its because you didn't escaped the singe quotes (') in the sentece. coz. single qoutes has meaning in PHP so they should be escaped. i think this may be your code

<?php echo "10 Facts about World's Tallest Building"; ?>

. you must escape the single quote inside your sentence to something like this.

<?php echo "10 Facts about World\'s Tallest Building"; ?>

If you're using " then you need to escape with \". Likewise, if you're using ' you need to escape with \'. But you don't need to escape if you're using the opposite ie., "this is ' fine" , ' this is " fine' , " this is " broken" , ' this is also' broken'

ShawnCplus 456 Code Monkey Team Colleague

Why are you using such an old version of MySQL with the new version of PHP? And does that file actually exist in that directory?

ShawnCplus 456 Code Monkey Team Colleague

.db files are usually associated with SQLite, so go download it and use it to open it. In the future don't post massive blocks of text like that. It's not fun having to scroll for an hour.

ShawnCplus 456 Code Monkey Team Colleague

You don't need the leading "'" . when setting $sides and $totals.

ShawnCplus 456 Code Monkey Team Colleague
}else{
   print($con->error);
}
ShawnCplus 456 Code Monkey Team Colleague
ShawnCplus 456 Code Monkey Team Colleague

If you have that code on a php page then it will try to call the function and insert the output directly into that string. You have to understand the difference between a server-side language and a client-side language. PHP will get executed before the javascript even hits the browser.

Example:
What you code in somepage.php

<?php
// this stuff never touches the browser
?>
<script type="text/javascript">
alert("<?php echo 'Hello World!'; ?>");
</script>

When the page gets to the user there is no longer any PHP code in the page, the server has already interpreted it and given the results so the browser receives

<script type="text/javascript">
alert("Hello World!");
</script>
ShawnCplus 456 Code Monkey Team Colleague

You forgot the grouping parens

somestring.replace(/(^\s*|\s*$)/g, "")
ShawnCplus 456 Code Monkey Team Colleague

a header() call does not end the script. Always place exit; after a header() call if you don't want anything else to execute after it.

// do some stuff
header('Location: blah.php');
// this stuff gets executed too
header('Location: blah2.php'); // user is now redirected to blah2.php
exit;
// this stuff doesn't get executed
header('Location: blah3.php'); // never gets here, the user already left the page
ShawnCplus 456 Code Monkey Team Colleague

Also put

ini_set('display_errors', 'On');

Below error_reporting(E_ALL);
If you still don't see any errors it could be because you're trying to call a function which obviously does not exist ( XYZDBConnect() )

ShawnCplus 456 Code Monkey Team Colleague

Hi..

I paced the 'error_reporting(E_ALL);' ... but couldn't find the FAQ that you were saying about...

After you placed that in the code refresh the page. Instead of a white page you should see errors. If you get errors that mention something about a MySQL result resource follow the FAQ. If it is a different error post the error here.

ShawnCplus 456 Code Monkey Team Colleague

Right below # BEGIN SCRIPT place

error_reporting(E_ALL);

Then follow the FAQ on the main page of the PHP forums

ShawnCplus 456 Code Monkey Team Colleague

Show us the source of the page

ShawnCplus 456 Code Monkey Team Colleague

Just go to the page in the browser, the same way you would locally except replace localhost with the domain name.