ShawnCplus 456 Code Monkey Team Colleague

Really? You're going to support PHP4? Please stop, it's a decade old, full of security holes and damn-near useless. As for not knowing what version of PHP will be on the client's server it's your responsibility as a developer to make sure that they have an environment that fits a stable, secure environment which almost always means the most recent version of PHP. Not a single reputable shared host ONLY uses PHP4. And the way you should be releasing to clients, dedicated hosting, is customized to your needs.

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

Read the FAQ, you have a syntax error in your query.

ShawnCplus 456 Code Monkey Team Colleague

My dear Shawn,

I am aware that both PHP4 and PHP5 (and likely the others) have XML functions but as I have explained already they are always dependent on your install thus neither portable nor controllable. My solution will be much slower but as it will consist merely of some PHP files they will work everywhere.

As for regex vs. strtok/explode

For now I'm not including a validating functionality. Only some well-formedness constraints will be checked (where needed for the function). For the time being I expect anyone to check the XML data for well-formedness and validity (if needed by the user) before feeding it to the function.

As for strtok I was thinking to use < and > as delimiters to break it down. But regular expression might be useful. I'm still working on the best structure for standard XML array.

No they aren't dependent on your install "These functions are enabled by default, using the bundled expat library." I'm just trying to save you time from reinventing the wheel when it doesn't need to be.

If you're determined to write your own then you have a few ways to go about it.
* Write a lexer to parse the XML then an FSM to iterate over the tokens to determine well-formedness
* Use regular expressions (NO)
* Use strtok (slightly less enthusiastic NO)

ShawnCplus 456 Code Monkey Team Colleague
ShawnCplus 456 Code Monkey Team Colleague

If you're thinking of implementing your own XML parser in PHP you might want to forget that idea. PHP already has a built-in XML parser in SimpleXML and the XMLParser library which are language functions written in C. Writing you own parser is possible but will be orders of magnitude slower that the built-in libraries.

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

The problem is that HTML/XHTML is really a horrible and bloated markup language. Most of the larger websites (Google being the main one) that forgo valid HTML do so because the browser will still render it just the same but they save on bandwidth (referring to omitting end tags). Go toss the w3c validator at the Google homepage and take a look at the result.

Until the large players join in and support valid (X)HTML or invent a new markup language it's just not going to happen

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 port itself is not important, I tried many and the same errors.

The port itself is important. The receiving computer must be listening on the port you're trying to send.

ShawnCplus 456 Code Monkey Team Colleague

It's never impossible to crack hashing algorithms. Just unlikely due to the massive increase in time needed version encryption. As to where to find it take a look at the SHA1 wikipedia entry and read the papers cited.

http://en.wikipedia.org/wiki/SHA1#SHA-1

Many of these exploits are still in their infancy and it's highly unlikely that any script-kiddie tools will be released any time soon. So good luck deciphering the math in the papers and implementing your own versions :P

ShawnCplus 456 Code Monkey Team Colleague

While I am asking for help how would i go about implementing my li.js switch to something like this...

You'd want to take advantage of what's called a fallthrough.

switch(this.id){
	case "home":
	case "about":
	case "shop":
	case "friend":
	case "vids":
	case "music":
	case "pics":
	case "ranks":
	case "stuff":
	case "read":
	case "leave":
		content.slideUp();
		content.load("http://tdr.host22.com/sections.html #" + this.id + "_section", hideLoading);
		content.slideDown();
		break;
	default:
		hideLoading();
	break;
}
ShawnCplus 456 Code Monkey Team Colleague

Why are you using file , just use file_get_contents which doesn't split by newline

ShawnCplus 456 Code Monkey Team Colleague

thanks for the reply... the __autoload function requires one argument, isnt there any other way just to load all the files, i mean why cant i just include or require all the include files and then be able to access their functionality on other pages???

You never call the __autoload function, it is automatically called when you try to use a class. So all you have to do is include the file that defines the __autoload function and any time you try to instantiate an undefined class it will call the autoload function.

ShawnCplus 456 Code Monkey Team Colleague
ShawnCplus 456 Code Monkey Team Colleague

@ is not a common character, it was chosen as the email delimter because it isnt common
I am not familiar with wordpress's setup so I'm not sure how many @ there will be or how close to physical line 430 the one with an error will be, or what the fix will be when you find it, sometimes the error is simple and visible
example: $address=fred@fredsite.com; that should be $address='fred@fredsite.com'; othertimes it makes no sense at all

It may be a corruption during file transfer or setup that you have to run the setup script again
it could be something ridiculously simple if you know wordpress
this should be posted at Wordpress.org help forums they have wordpress gurus

@ is also used as error suppression in PHP ie.,

// don't do this EVER
$something = @mysql_fetch_assoc($someres); // suppress the error if $someres isn't a valid resource
ShawnCplus 456 Code Monkey Team Colleague

You're not assigning the function to the onclick the way you're doing it. You're assigning the RETURN of the function to the onclick. You want to return a function from your function so just change your changeDay function to this and use the blah.onclick = changeDay(newDay);

function changeDay(newDay)
{
	return (function (newDay)
	{
		ajaxCall('tools/refresh_booking_visual.php','start=' + newDay, function(x)
		{
			var pieces = eval("(" + x + ")");
			document.getElementById('booking_visual').innerHTML = pieces.visual;
			document.getElementById('booking_date').innerHTML = pieces.date;
			document.getElementById('date_back').onclick = changeDay(pieces.backdate);
			document.getElementById('date_next').onclick = changeDay(pieces.nextdate);
		});
	});
}
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

Where did you get that number from?

btw, it doesn't really matter per se but the functions are called sine and cosine, a sinus is for example the empty space behind your nose and upper cheeks.

Have you done some calculus? Have you heard of Taylor Seres?

The number is the value of sin(1) so he's essentially getting sin(x) by doing sin(1)*x which is quite wrong :P

ShawnCplus 456 Code Monkey Team Colleague

Hey guys,
so I want to write a program that calculates the sinus, cosinus and tangent without using math library...
Any ideas?

SOHCAHTOA

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

Go over to the PHP forum and read the FAQ.

ShawnCplus 456 Code Monkey Team Colleague

Actually, I think it's good that he corrected the answer. It's still a valid question and cursor:pointer is still valid CSS for anyone else who might have the same question in the future :)

My post was also almost an exact quote of the response to my first post as a little throwback (I think it was Narue who responded to me)

ShawnCplus 456 Code Monkey Team Colleague

BTW "cursor:hand" only works in IE. The correct W3C standard is actually "cursor:pointer," which will work across all major browsers.

Welcome to the community Johnny but try not to revive 4 year old threads in the future.

ShawnCplus 456 Code Monkey Team Colleague

Well you want to JOIN but you're not JOINing

(side note, don't use * be explicit about the fields you want.

SELECT u.userid, bd.bdate, bd.id FROM bookingdata bd JOIN users u ON bd.userid = u.userid
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

I'm working on a contact form. I have the form being checked by a PHP script once it's submitted. If the script finds an error, it will load a new page with the error message and then redirect back to the form after 10 seconds so the user can correct the error.

The problem is that when the form reloads, it is blank.

How can I have the form reload and keep the entered data?

This is what I'm using now:

window.setTimeout("window.location = './contact.htm'", 10*1000 );

Thanks.

Why not just reload the same page and display the error there instead of a separate page and use PHP to set the field values instead of javascript?

ShawnCplus 456 Code Monkey Team Colleague

Graphix is correct. min-height will not work in IE < 7.

Google around for min-height hacks

ShawnCplus 456 Code Monkey Team Colleague

You can just use CSS.

height: auto;
min-height: 400px;
ShawnCplus 456 Code Monkey Team Colleague

Did you echo out "fileName: $fileID" to see what the actual value being passed was?

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

You don't need to get so defensive. I'm not singling you out. You posted an example of one of your posts and I gave my response. And it's obvious when a user shows effort and when they don't. Suffice it to say you have your opinion and I have mine. Anyway, could a mod for the PHP forum please chime in regarding the original topic of this thread.

ShawnCplus 456 Code Monkey Team Colleague

Did you bother to read:
http://www.daniweb.com/forums/post1095425.html#post1095425

The OP took my code-only response and elaborated on the reasoning for the logic. Not only did he understand it, he posted back a "more detailed description" PLUS another way of going about it, although I wouldn't suggest the method he described. Infracting regulars for something like that will serve no purpose other than to tick them off.... but if you just want to tick off a regular then start -rep'ing him. No need for an infraction.

The OP in that thread also showed effort from the start, it wasn't a copy/paste from his homework assignment without any other posts in the thread.

ShawnCplus 456 Code Monkey Team Colleague

I disagree. Sometimes I answer questions with pure code, as the code speaks for itself:
http://www.daniweb.com/forums/post1098395.html#post1098395
http://www.daniweb.com/forums/post1095425.html#post1095425

So with that reasoning, again, I should be infracted.

IMO, yes. Teach a man to fish, and all that jazz coupled with the fact that I despise giving out answers to people that don't show any effort at all. I understand that there are situations when one needs help immediately but in most cases it takes just as much time to solve it on your own than it does to mooch off a forum and wait for a reply.

ShawnCplus 456 Code Monkey Team Colleague

Who cares? If one of the daniweb solvers wants to answer a homework question with full code then let them do it. The only person losing out is the person doing the homework since they never learned the topic. "Just because I think this guy is lazy and needs to do his own homework but XXXXXXX solved it, i'm going to infract him." -- doesn't make sense to me.

Bring on the downvotes because i'm sure I stand alone on this.

It's not just the OP, it's the entire community because now there isn't a nice archive of knowledge of how the OP arrived at a solution. There's just the question and the answer.

It's the difference between showing your work or not when solving a math problem.

ShawnCplus 456 Code Monkey Team Colleague

*sigh* Read the FAQ at the top of the PHP forum

ShawnCplus 456 Code Monkey Team Colleague

A) Fix your identation
B) You don't need addslashes on the password, you're MD5ing it, there will never be slashes
C) Where do you place what on your page?

ShawnCplus 456 Code Monkey Team Colleague

A) Use actual links and not butchered URLs
B) Post your code, don't use imageshack with a screenshot of your code.

ShawnCplus 456 Code Monkey Team Colleague

>I doubt it'll stem the flow of begging or spoonfeeding - which
>is becoming a growing problem - but it wouldn't hurt.

IMO, all of those announcements and stickies are completely ineffective for fixing the problem. All they do is make it easier for mods to justify punitive action.

Frankly, it's I'm not even trying to target new posters with it. I'm trying to target the existing members with 100+ posts that are still spoonfeeding the newbies. Perhaps it could even be specifically targeted to say something like "Do not give help to those who do not show effort." instead of the other way around ("We won't help those who do not show effort")

ShawnCplus 456 Code Monkey Team Colleague

Could the Homework Help announcement in the C++ forum also be added to the PHP forum. I doubt it'll stem the flow of begging or spoonfeeding - which is becoming a growing problem - but it wouldn't hurt.

ShawnCplus 456 Code Monkey Team Colleague

Shawn I agree , it is on my list of things to do, but since i have to get the site signed off by the end of the week, I don't think I have time to learn the required code and get it working in that time.

Learning entry-level AJAX takes all of 2 or 3 hours. Clicky

ShawnCplus 456 Code Monkey Team Colleague

Yeah, Javascript and PHP don't work like that. PHP is run before the page gets to the user. Javascript is run after it gets to the user so those inserts are happening every single time someone visits the page, not based on that confirm popup.

so don't have the time to learn ajax to sort it out myself.

You might want to go ahead and make time, this is pretty much an essential skill for web developers.

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;
	});
});