hielo 65 Veteran Poster

try:

<?php

$ndnews = file_get_contents('http://www.naughtydog.com/index.php/site/tickerData');

preg_match_all("/<div class=\"message\">\n(.+?)\n<\/d/", $ndnews, $news); 
foreach($news[1] as $item) {
    $Items = explode("  ", $item);
  echo "<span class=\"message\">" . preg_replace('#0(\d)/#','$1/',$Items[0]) . " - " . $Items[1] . "</span><br />\n"; 
}

?>
hielo 65 Veteran Poster

A. at the end of line 17 you have horizontal[fishPos[fishNumber] . That's a syntax error. You are missing a closing bracket after fishNumber .

B. On line 24 you have setInterval(fish1Swim, 100); , but there is no such thing as function fish1Swin(){...} declared anywhere, so I don't see how you can claim that you can make one fish swim (especially after the syntax error outlined on point A.). What you do have is function swimFish(){...} which expects a number, so what you need to do is call it once foreach of your fishes:

function startSwimming() {
        setInterval("fishSwim(1)", 100);
        setInterval("fishSwim(2)", 100);
        setInterval("fishSwim(3)", 100);
}

c. fishPos is declared as number on line 9, but you are using it as an array in lines 17-20. Also, based on lines 18-20, it seems like you are "depending" on something like fishPos[1] for fish1, fishPos[2] for fish2, etc. So line 9 should be changed to an array where indices 1,2, and 3 are required to be initialized:

//the -1 is irrelevant. It's indices 1-3 that you need for fishPos[1]-fishPos[3].
var fishPos = [-1,0,0,0];

If you implement the changes above, you should see three fishes swimming in unison across the street. I'll leave it up to you to make them swim in different directions/rates.

hielo 65 Veteran Poster

try not to use the decrated method

I meant to write "deprecated".

hielo 65 Veteran Poster

on line 16, $query is NOT an sql command (You already have a result set in $query from the executed sql command on line 5), so it is essentially erroring out before it can emit those other options (look at the browser source code).

On what you posted, I don't see the point of lines 6-8 since:
a. You keep overwriting the value of $subjectid on every iteration of your loop
b. You are not using it anywhere else
c. You intended to execute the same query again to generate the options. Why not just use what's in $query

hielo 65 Veteran Poster

why both ".toUTCString()" and ".toGMTString() " failed.

OK, I see. On the posted code expdate is a number object, not a date object. The .toGMTString() and .toUTCString() are methods of a date object. So you need to use
that numeric value to create a date object. So change expdate = (currDate.getTime()+ 3652425 * 24 * 60 * 60 ); to expdate = new Date(currDate.getTime()+ 3652425 * 24 * 60 * 60 ); FYI: The previous suggestion still stands - going forward, try not to use the decrated method .toGMTString() and use .toUTCString() instead.

hielo 65 Veteran Poster

BTW, since you are using:

<form name="market" action="merchant_acct.htm" onsubmit="return handleAll()" method="post">

typically web servers don't process files that end in ".htm" (or ".html") dynamically. Meaning, said files are treated as "static" files. If that is the case with your server configuration, when you submit a POST request (which your form is currently doing), you will most likely get a 405 error - which basically translates to "this server is not configured to allow POST requests to files ending in .htm").

If you notice this problem, change your form to

method="get"
hielo 65 Veteran Poster

Try using .toUTCString() instead of .toGMTString() http://www.w3schools.com/jsref/jsref_obj_date.asp

hielo 65 Veteran Poster

making the question I shall ask a fair question.

So what's your question. You never actually asked a question.

On another note, when posting "blocks" of code, wrap them in [ CODE ] and [/ CODE ] (without the spaces around the word "CODE" - I used spaces so you can see the needed syntax). Alternatively, you can press on the "button" labeled CODE on the editor. Here's what it would look like if you do it right:

var str="hello";
alert( str );

To write inline-code (highlight a single code statement) use [ icode ] and [/ icode ]. Notice how alert("hello"); is highlighted when you use icode.

hielo 65 Veteran Poster

look at the success option.
http://docs.jquery.com/Plugins/Validation/validate#toptions

You can see a full demo at http://jquery.bassistance.de/validate/demo/milk/ (look at the source code)

jQuery.ajaxSetup( ) will allow you to setup async as default

hielo 65 Veteran Poster

OK, I see you have a very outdated version of the validation plugin. Try updating it to the latest first and try again.

hielo 65 Veteran Poster

but i didnt include get method in that form.
i didnt understand because i didnt use get method there

But if you do NOT see any method attribute at all, it is expected that as the web developer you would already know that it defaults to GET.

Here's the link to the relevant W3C spec in case you haven't read it:
http://www.w3.org/TR/html4/interact/forms.html#h-17.3

hielo 65 Veteran Poster

Open Firefox, install the Firebug plugin and then restart Firefox. Go to your page. On the lower-right corner of the browser you will see a "bug". Click it and you will see a sub-pane at the bottom of the Firefox. On that pane click on the "Net" menu, then on the "XHR" option/button. Fill your form and submit it. Once you do so, you will see the url that is submitting to and it will be prefixed with POST or GET, depending on the request type. You need to verify that it is in fact doing a GET request (may not be the case depending on your global jquery setting). Then click on the "+" icon to expand it. There should be a "params" tab that shows you what it is sending to the server and on another tab named "response" that shows what it is receiving FROM the server.

If you have a link to your page, it will help (I don't have all those js libraries you are using).

hielo 65 Veteran Poster

did you try the remote option? On the server, you should check for $_GET and return true OR false (lowercase) without any leading and/or trailing spaces.

$(document).ready(function() {

    $("#register_form").validate({
        onkeyup:false,
        rules: {
            username: {
                required: true,
                minlength: 3,
				remote:"username_availability.php"// remote check for duplicate username
            }
        },
        messages: {
            username: {
                required: "username is required.",
                minlength: jQuery.format("username must be at least {0} characters in length."),
                remote: jQuery.format("{0} is already in use")
            }
        }
    });
});
<?php
include('database_connection.php');                                  
if (isset($_POST['username'])) {                                                               
    $username = mysql_real_escape_string($_POST['username']);                                  
    $check_for_username = mysql_query("SELECT user_id FROM users WHERE username='$username'"); 
    if (mysql_num_rows($check_for_username)) {
        echo "true";                                                                           
    } else {
        echo "false";//No Record Found - Username is available
    }
}
exit;
?>
hielo 65 Veteran Poster

try:

...
success:
                function(msg) { isSuccess = !/TRUE/.test(msg); }
...
hielo 65 Veteran Poster

Prepared Statements are a mechanism/feature to prevent sql injection.
PDO, mysql, mysqli are "software layers" that allow you to interact with the db server, but not all of them support prepared statements.

-only PDO and mysqli support prepared statements.
-mysql and mysqli can be used only with mysql database server
-pdo can be used with various db servers

I prefer to use PDO since it does support prepared statements and it gives me the flexibility to potentially change to a new host where the db server might NOT be mysql but say postgresql.

hielo 65 Veteran Poster

try:

<?php

$connect = mysql_connect("localhost","root","") or die ("connection failed!");
mysql_select_db("users") or die (mysql_error());


echo "connected!"

$recordset = mysql_query("select * from member order by id ASC") or die( mysql_error());
$row=mysql_fetch_assoc($recordset);
extract( $row );



?>
hielo 65 Veteran Poster

To understand that, you need to realize that your doSearch() has the following: window.location.href = submitto; That line basically will change the browser's url to whatever is in the submitto variable. Essentially that line is emitting a search request using method="get" , since all the search parameters are already included in the submitto variable.

If you were to REMOVE that line and get rid of return false, then you would notice that the same thing happens - meaning, the url changes so that it contains all the search parameters. Since you do NOT have <form method='post'...> , the browser defaults to <form method='get'...> . This is the reason why the url would change and include the search parameters if you were to get rid of return false; and the [ window.location.href = submitto; So, to summarize, if you get rid of return false; , the browser would submit the FORM 's search request using method="get" and by having window.location.href = submitto; it would ALSO submit a search request using method="get" .

Clearly, there is NO need to submit two requests for every search you make. So, by adding return false, the FORM 's get request is cancelled.

hielo 65 Veteran Poster

detached_fields += $(this).remove();

that's your problem. You can concatenate STRINGS, but NOT objects. remove() returns an object. Since you are issuing a concatenation operator, javascript calls its toString() method which simply returns a string whose value is [object Object] . What you need is the ACTUAL objects. Make detached_fields an array, and then as you remove an item add/push it to that array. In your else clause, you need to iterate over the array, popping one item at a time. As you pop each item, add it back to your form.

hielo 65 Veteran Poster

I never worked with PHP before though, and the question is how are the vars in URLs called?

When someone visits your page and the url to your page contains variables like site.com/test.php?f=17&s=23 , the PHP engine automatically creates a global array named $_GET which gets "stuffed" with the url parameters. Thus, given the sample url above you can see the values by echoing them as follows:

echo $_GET['f'];
echo $_GET['s'];

You can of course simply assign those values to some other variable: $F=$_GET['f']; and then do whatever you want/need with $F On the other hand, if you have a string that is formatted like a URL, you can use parse_str() (http://us.php.net/manual/en/function.parse-str.php) to "extract" the parameters in the url yourself - basically doing exactly what the PHP engine does automatically when initializing $_GET :

$str="site.com/test.php?f=17&s=23";
parse_str($str,$param);

echo $param['f'];
echo $param['s'];
hielo 65 Veteran Poster

because if your script is sending Hello{"title":"test"} , only {"title":"test"} is a JSON string. Read about JSON on the json.org website.

To clarify further, if you are familiar with xml, you would know that this IS Valid XML:

<root>
 <title>Test</title>
</root>

but NOT this:

Hello
<root>
 <title>Test</title>
</root>

The same concept applies to what you are sending. By introducing the "BaSk" delimiter in my previous post, if you split it at that character sequence/delimiter, you would be able to separate the json string (which you are sending at the end of your output) from the leading non-json encoded output.

hielo 65 Veteran Poster

you have to return false when there is an error. Since you are NOT doing that, the form gets submitted and quickly reloaded (hence the "flash"). Try:

function validate() {
	var ok=true;
	ok=ok && firstname();
	ok=ok && lastname();
return ok;
}

function firstname() {

	var x=document.forms["signup"]["firstname"].value;
	if (x==null || x=="") {
		document.getElementById("error").style.visibility = "visible"; 
		document.signup.firstname.focus();
		return false;
	}
return true;
}
function lastname() {

	var x=document.forms["signup"]["lastname"].value;
	if (x==null || x=="") {
		document.getElementById("error").style.visibility = "visible"; 
		document.signup.lastname.focus();
		return false;
	}
return true;
}
hielo 65 Veteran Poster

You also need to echo json_encode()...; , and you can also send a particular character (or character sequence) where you can split the json string from everything else that has already been send. To clarify, it sounds like you have: ...blah......blah...{"title":"test"} Let's assume that your ...blah......blah... does NOT contain (and never will contain) "BaSk". So if you send that character sequence right before you json string, on the javascript end you can split it at that delimiter(character sequence):

<?php
echo 'Hello';
$propName="test";
$title = array("title" => "$propName");
echo 'BaSk';
echo json_encode($title);
exit;
?>
$.ajax({
			
			type : "POST",
			url : "sortProp.php",
			data : "f="+type+"&s="+filter,
			success : function(data){
			  var temp=data.split("BaSk");

                          //temp[0] should have Hello
                          //temp[1] should have the STRING {"title":"test"}

                          //convert it to an object
                          temp[1]=$.parseJSON(temp[1]);
				$('#propHold').html( temp[0] );
				$('#propHold .prop:first').addClass('active');
				
				alert(temp[1].title);
			
			}
		
		});
hielo 65 Veteran Poster

well, in that specific example I know that the properly encoded string appears after Hello, which consists of 5 characters, so I would skip the first five characters and use $.parseJSON() to convert the remainder of the string to an object:

success: function( data )
{
  var myobj=$.parseJSON(data.substring(5));
alert(myobj.title);
}
hielo 65 Veteran Poster

if I change the data type to json, will i need to encode all data?

Yes, and that is the reason for your troubles.
For this to work: alert(data.title); the data you are returning must be:
a. ALL in json format
OR
b. you must parse the data parameter of your success function and YOU convert it explicitly.

To clarify on point b, let's say you have:

<?php
echo 'Hello';
$propName="test";
$title = array("title" => "$propName");
json_encode($title);
exit;
?>

that would end up sending the following to the browser: Hello{"title":"test"} since it is NOT a properly-encoded json string, it will NOT be "auto-converted" to a json object by jquery, so within success() , data is a string NOT a json object - that's why you cannot use data.title.

hielo 65 Veteran Poster

...i would like it to return a result whether only a name was found, just an owner, or both.

You don't need to AND. The OR should give you what you want even when both are true:

$sql="SELECT `name`, `owner` 
FROM Table WHERE `name` LIKE '$%term%' OR `owner` LIKE '%$term%'";
hielo 65 Veteran Poster

add dataType:'json' to your $.ajax() options. Also, make sure that your PHP file does NOT return anything after that json_encode statement - try:

<?php
$propName="test";
$title = array("title" => "$propName");
json_encode($title);
exit;
?>
hielo 65 Veteran Poster

instead of:

echo "\t"."Confirmation Page<br/>";

try:

echo "<div style='padding-left:10px;'>Confirmation Page</div>";
hielo 65 Veteran Poster

currently I see the following on line 148: $to = $_POST['email']; but on line 33 you have: <input type="text" name="vemail" > Notice that the name of the input text box does NOT match the key in the $_POST array. If you fix the name of the input field (get rid of that "v"), then you should be able to type a comma-separated list of email addresses and all of them will get the same email message.

As far as the foreach goes, given this:

$contacts = array('other', 'email', 'substat');
foreach ($contacts as $email) {
  $email = $to;
}

A. assigning the variable $to to the varialbe $email doesn't make sense since on the very first time that statement is executed $to doesn't exist at that point.

B. as far as understanding arrays, it will make more sense if you can see/understand that this:

$contacts = array('other', 'email', 'substat');

is equivalent to:

$contacts = array('0'=>'other', '1'=>'email', '2'=>'substat');

Armed with that knowledge, look up the foreach on the manual:
http://us3.php.net/manual/en/control-structures.foreach.php

Notice the second syntax?
So basically if you do:

$contacts = array('other', 'email', 'substat');
foreach($contacts as $index=>$value)
{
  echo $index.'='.$value.'<br/>';
}
//output should be:
0=other
1=email
2=substat

So, I hope that clarifies how the foreach works.

C. As far as your project goes, I suspect what you actually want is for the user to be able to check multiple users and then email only the checked individuals. If that is the case, then the problem …

hielo 65 Veteran Poster

It would help if you actually post the HTML you are using. As for:

//element.style.visibility = 'hidden' and 'block'
element.style.visibility  ==> visible OR hidden
element.style.display     ==> none OR block OR inline

So if you have an input and next to is is the element you want to display (like a span), then use display:inline. If you were to use display:block, then it would appear on a line by itself.
hielo 65 Veteran Poster

...also tried xmlDoc.documentElement.NodeName.

Try lowercase "N" for Node
xmlDoc.documentElement.nodeName.

If the problem persists, verify that the document loaded correctly - on line 4 put: Response.Write(xmlDoc.xml); If you do not see the xml document, then it was not retrieved.

hielo 65 Veteran Poster
$(document).ready(function(){
 
	$("#env").click(function(e) {
 
			e.preventDefault();

			var r1='';
			var r2='';
			$.get("char_con.php?", {act: 'char_con'}, function(data){
				//save the result of the first call onto r2
				r1=data;
			});
			
			$.getJSON("generator.php?", {act: 'char_con', bc: '1'}, function(data){
				//save the result of the second call onto r2
	 			r2=data;
			});

			//take both results and save them onto .q
			$(".q").html( r1 + r2);
	});
	
});
hielo 65 Veteran Poster

at the end of line 7 of your second code block you have: function(data{ It is missing a closing parenthesis. Try:

$(document).ready(function(){

	$("#env").click(function(e) {

		e.preventDefault();

                        // do both
                        $.getJSON("generator.php?", {act: 'char_con', bc: '1'}, function(data){

			$(".quote").html(data);


		});

                        $.get("char_con.php?", {act: 'char_con'}, function(data){							  
        			$(".q").html(data);
         		});

			$(".q").html(data);
			
		});
	});
});
hielo 65 Veteran Poster

try:

function checkAdd(){
	
	var cname = document.getElementById('addname');
	var cpound = document.getElementById('addpound');
	var cpence = document.getElementById('addpence');
	var div = document.getElementById('errormsg');
	var lets = /^[a-zA-Z\s]+$/;
	var nums = /^[0-9]+$/;
	
	if((cname.value == '') || (cname.value == ' '))
	{
		div.innerHTML= "<b>Please fill in the item name</b>";
		cname.focus();
		return false;
	}
	else if(cname.value.match(lets))
	{
	/*
		if(cpound.value == '')
		{
			cpound == 0
		}
/*		
		if(cpound.value.match(nums))
		{
			if((cpence.value == '') || (cpence.value == ' '))
			{
				div.innerHTML= "<b>Please fill in value for pence</b>";
				cpence.focus();
				return false;
			}
			else if((cpound.value.length == 1) && (cpence.value.length == 1))
			{
				div.innerHTML= "<b>Please enter 2 digits for pence</b>";
				cpence.focus();
				return false;
			}
			else if(cpence.value.match(nums))
			{
				return true;
			}
			else
			{
				div.innerHTML= "<b>Only numbers please</b>";
				cpence.focus();
				return false;
			}
		}
		else
		{
				div.innerHTML= "<b>Only numbers please</b>";
				cpound.focus();
				return false;
		}
	}
	else
	{
		div.innerHTML= "<b>Only letters please</b>";
		cname.focus();
		return false;
	}
return true;
}
hielo 65 Veteran Poster

when the pound and pence fields on the form are blank, but the name is filled in

Not from what you coded. The problem is that when the pound is left blank, this condition is true:

if(cpound.value == '')
		{
			cpound == 0
		}

and the rest of your code ( within the else if-else ) will NOT execute, eventually leading to the "return true". Hence the reason it is submitting.

hielo 65 Veteran Poster

you created TWO DIFFERENT objects. One is a Father object. The other is a Son object. The Son object:
a. Sets the value of car and ...
b. inherits from the Father

So try: $obj1->inherited(); to see the value of car. Maybe this will clear things up for you:

<?php
Class Father{

	var $car="Toyota";
	
	Function inherited(){
	print $this->car;
	}
}

Class Son Extends Father{

	Function __Construct(){
	$this->car='Benz';//I'm assuming here that car is still a property of father.
	}
}

$obj= new Father;
$obj1= new Son;

# I expect it to print Benz here, but it doesn't.
$obj->inherited();//father object
echo '<br>';
$obj1->inherited();//son object
#There is no output.
?>
hielo 65 Veteran Poster

http://aquantum-demo.appspot.com/file-upload
http://www.uploadify.com/demos/

PS: Don't forget to mark this thread as solved. Your original problem was solved long ago.

hielo 65 Veteran Poster

Glad to help.

Regards,
Hielo

PS: Don't forget to mark the thread as solved

hielo 65 Veteran Poster

I don't know where your have

<h1>Welcome<?php require ('name.php'); ?> to your private page!</h1>

but the problem is that on the file where you are including FROM, you already send output to the browser (since in your code <h1>Welcome... appears before the include).

Let's assume that the page you are working on is at http://yoursite.com/yourpage.php and that yourpage.php includes name.php.

Then you need to call session_start() at the very top of yourpage.php and NOT at name.php. All this confusion is because you did not provide enough details about your application. When working with sessions and includes, you need to be very clear as to which files are including other files.

hielo 65 Veteran Poster

again

<?php
session_start();
require ('name.php');
?>

needs to be at the BEGINNING of the FILE. You have it in the middle.

hielo 65 Veteran Poster

You need it at the beginning of ALL three files. Also, in Name.php you have: if (isset($_SESSION['email'])) BUT in LOGIN.php you are NOT initializing $_SESSION['email'] anywhere. All you have is:

$_SESSION["login"] = $login;
$_SESSION["username"] = $_POST["username"];

Maybe you meant: if (isset($_SESSION['login']))

hielo 65 Veteran Poster

on EVERY page where you are using $_SESSION, you MUST call session_start() first. So, at the very top of your pages, BEGIN with:

<?php
session_start();
//rest of your code follows
...
?>
hielo 65 Veteran Poster

a comma separated list of email addresses is OK. It is even shown in example 4 on the manual:
http://php.net/manual/en/function.mail.php

cguan_77 commented: thanks +0
hielo 65 Veteran Poster

when I try to download image ...the file gets corrupted

Have you tried sending the appropriate MIME type for the file. Assuming you are dealing with a JPEG image, try sending header("Content-type: image/jpeg"); instead of header("Content-type: application/octet-stream"); Also, be sure to add exit(); right before the closing ?>

hielo 65 Veteran Poster

You need to enclose the expression in parenthesis for the back reference to work. Since you need to replace based on your php array, you also need to use the 'e' switch at the end of the regex:

<?php
$str="String of text containing item1 and item2";
$x['item1']="Item 1";
$x['item2']="Item 2";
$str=preg_replace('/(item\d+)/e','$x[$1]',$str);
print $str;
?>
hielo 65 Veteran Poster
NOTE: On the steps below
">"  mean "click on"
">>" mean "double click on"


>Start	>Control Panel	>>Administrative Tools	>>Services >>MySQL

Change Startup type to Manual

>Apply
hielo 65 Veteran Poster

whenever you see "Warning: mysql_XXX expects XXX to be resource..." typically it means that whatever query you attempted to execute failed. So replace your line 13 with the following instead to find out what is causing the error: $result = mysql_query($query) or die( mysql_error() );

hielo 65 Veteran Poster

try:

$i = 0;
while($row=mysql_fetch_array($result, MYSQL_NUM)) {
    echo "$row[0]";
   if( !(++$i % 2) )
    {
      echo "<br />";
    }
}
hielo 65 Veteran Poster

Glad to help.

Regards,
Hielo

PS: Don't forget to mark the thread as solved.

hielo 65 Veteran Poster

Your problem is that you keep using document.write AFTER the page has loaded. You should only use it WHILE the page is still loading. Try creating a div with an id and whatever you intend to put via document.write, instead insert it into the div. Also, on the <a> tag, just use href="#" instead of href="javascript:" - ex:

<html>
<head>
<title>Hello everyone</title>
</head>
<body>
<script type="text/javascript">
window.onload = initAll;
function initAll(){
actRedirect();
}
function actRedirect(){
var actLink = document.getElementById("activeRedirect");
actLink.onclick = redirectNow;
}
function redirectNow(){
 window.setTimeout(function(){window.location.href='http://google.com';}, 5000);
 document.getElementById('target').innerHTML="Please wait, you will be redirect to google soon!";
}
</script>
<div id="target"></div>
<a href="#" id="activeRedirect"> Redirect to Google now.</a>
</body>
</html>
moonknight33 commented: extractly +0
hielo 65 Veteran Poster

Change line 14 from this: clickLink.onClick = promptWhatsName(); to this: clickLink.onclick = promptWhatsName;