hielo 65 Veteran Poster

it seems to work fine for me:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 "http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<title></title>
</head>
<body>
<script type="text/javascript">

function isAlphabet(elem, helperMsg){
    var alphaExp = /[a-z]+/i;
    var nums=/\d+/;
    var alnum=/^[a-z\d]+$/i;
    if(elem.value.match(alnum) && elem.value.match(alphaExp) && elem.value.match(nums) ){
        return true;
    }else{
        alert(helperMsg);
        setTimeout(function(){elem.focus();},20);
    return false;
    }
}
</script>
<input type="text" id="Username" name="username" onchange="isAlphabet(this, this.id+' is not valid. It must contain at least one letter and one number') "/>
</body>
</html>
hielo 65 Veteran Poster

try:

function isAlphabet(elem, helperMsg){
    var alphaExp = /[a-z]+/i;
    var nums=/\d+/;
    var alnum=/^[a-z\d]+$/i;
    if(elem.value.match(alnum) && elem.value.match(alphaExp) && elem.value.match(nums) ){
        return true;
    }else{
        alert(helperMsg);
        setTimeout(function(){elem.focus();},20);
    return false;
    }
}
hielo 65 Veteran Poster

apart from whether the extra is free or not, it just enters 0 into each column.

which input element determines this? What html markup is your script generating? It would be easier to understand the problem is you post a link to your page.

hielo 65 Veteran Poster

instead of requesting:

$url='http://example.com/vast/1/73188';

try requesting

$url='http://example.com/vast/1/73188?cb=' . time();
hielo 65 Veteran Poster

try:

if( isset($_POST['Submit']) && $_POST['Submit']=='Submit' )
{
    foreach($_POST['GP1011_wk1'] as $playerID=>$v)
    {
        //initialize to empty string and add field=value only if something was submitted
        $update="";

        $GP1011_wk1=mysql_real_escape_string(  trim($_POST['GP1011_wk1'][$playerID]) );
        $PTS1011_wk1=mysql_real_escape_string( trim($_POST['PTS1011_wk1'][$playerID]) );
  

        if( !empty($GP1011_wk1) ) {
            $update.="`GP1011_wk1`='" . $GP1011_wk1 . "'";
        }

        if( !empty($PTS1011_wk1) )
        {
            $update.=",`PTS1011_wk1`='".$PTS1011_wk1."'";
        }

        if(!empty($update))
        {
            $update = 'UPDATE `stats1011` SET '. $update . " WHERE `playerID` ='".$playerID."'";
            mysql_query($update) or die( sprintf('Error @Line %d while trying to execute<br/>%s<br/>%s',__LINE__,$update, mysql_error() ) );
        }
    }

}
// Get all the data from the "player" table
error_reporting (E_ERROR);
$GETQ="SELECT
Sum(stats1011.GP1011_wk1+stats1011.GP1011_wk2+stats1011.GP1011_wk3+stats1011.GP1011_wk4+stats1011.GP1011_wk5+stats1011.GP1011_wk6+stats1011.GP1011_wk7+stats1011.GP1011_wk8+stats1011.GP1011_wk9+stats1011.GP1011_wk10+stats1011.GP1011_wk11+stats1011.GP1011_wk12+stats1011.GP1011_wk13+stats1011.GP1011_wk14+stats1011.GP1011_wk15+stats1011.GP1011_wk16+stats1011.GP1011_wk17+stats1011.GP1011_wk18+stats1011.GP1011_wk19+stats1011.GP1011_wk20+stats1011.GP1011_wk21+stats1011.GP1011_wk22+stats1011.GP1011_wk23+stats1011.GP1011_wk24+stats1011.GP1011_wk25+stats1011.GP1011_wk26) AS `GP_TTL_1011`,

Sum(stats1011.PTS1011_wk1+stats1011.PTS1011_wk2+stats1011.PTS1011_wk3+stats1011.PTS1011_wk4+stats1011.PTS1011_wk5+stats1011.PTS1011_wk6+stats1011.PTS1011_wk7+stats1011.PTS1011_wk8+stats1011.PTS1011_wk9+stats1011.PTS1011_wk10+stats1011.PTS1011_wk11+stats1011.PTS1011_wk12+stats1011.PTS1011_wk13+stats1011.PTS1011_wk14+stats1011.PTS1011_wk15+stats1011.PTS1011_wk16+stats1011.PTS1011_wk17+stats1011.PTS1011_wk18+stats1011.PTS1011_wk19+stats1011.PTS1011_wk20+stats1011.PTS1011_wk21+stats1011.PTS1011_wk22+stats1011.PTS1011_wk23+stats1011.PTS1011_wk24+stats1011.PTS1011_wk25+stats1011.PTS1011_wk26) AS `PTS_TTL_1011`,

`stats1011`.`Last`,
`stats1011`.`First`,
`stats1011`.`playerID`,
`stats1011`.`Pos`,
`stats1011`.`No`,
`stats1011`.`GP1011_wk1`,
`stats1011`.`PTS1011_wk1`,
`stats1011`.`Team`

FROM
`stats1011`

WHERE
`stats1011`.`Team` = 'tor'

GROUP BY
`stats1011`.`playerID`

ORDER BY
field(pos,'LW','C','RW','D','G'), last";


$result = mysql_query($GETQ)
or die(mysql_error());
ceeandcee commented: Thank you! +1
hielo 65 Veteran Poster

are you being redirected to contractorlogin.php at least? Assuming you are, then in contractorlogin.php you MUST be storing the username in a session.

As for the code you posted, you may want to use an EQUAL instead of a LIKE in your query:

<?php
session_start();  
 
if (!isset($_SESSION['memberusername'])){  
	header("Location: contractorlogin.php");  
	exit();  
}

mysql_connect('localhost','username','password') or die( mysql_error() );
mysql_select_db('dbname') or die( mysql_error() );
$user = mysql_real_escape_string($_SESSION['memberusername']);
$sql = "SELECT * FROM contractors WHERE Username='" . $user . "'";
$result = mysql_query($sql) or die( 'Unable to execute<br>'.$sql.'<br>'.mysql_error());
if( !mysql_num_rows($result) )
{
	echo '<p>No Records found!</p>';
}
else
{
	$row=mysql_fetch_assoc($result);
	echo '<table><tr><th>' .implode('</th><th>', array_keys($row) ).'</th></tr>';
	do
	{
		echo '<tr><td>'.implode('</td><td>',$row).'</td></tr>';
	}while($row=mysql_fetch_assoc($result));
	echo '</table>';
}

?>
hielo 65 Veteran Poster

use notepad and save the text with ANSI encoding. If you have a utf-8 encoded file, chance are there are some leading characters being sent to the browser before the header() function sends its output.

hielo 65 Veteran Poster

For your script to work, you need to use the header() function in order to send the proper headers. However, it will NOT work if you send ANY output before you call header - ex:

<?php //WRONG: There is space BEFORE the php opening tag
header(...);
...
?>

In your case, currently I am seeing:


which is typically found in utf-8 encoded files, so it is probably the text editor you are using. To clarify, basically the actual content of your php file is most likely:

<?php //WRONG: Those characters are sent to the browser before the header() output is sent
header(...);
...
?>

So, take your php code above, paste it onto Notepad and when you are saving it choose ANSI encoding. THEN upload the file again. (You may have to do the same procedure for the other php file - reg_dbc.php).

hielo 65 Veteran Poster

I already told you that this:

list($name, $type, $size, $content) = mysql_fetch_array($result);

needs to be using mysql_fetch_assoc() , even if you get a blank screen. The blank screen is due to some other issue.

In your case, if you open firefox, go the link you provided, then click on test.php. Press CTRL+U.

Do you see that HTML <table> markup? That is your problem. You cannot send ANY output to the browser before the header() calls. Somewhere you are sending what looks like "debugging" information in a "tabular" HTML format. My guess is reg_dbc.php.

hielo 65 Veteran Poster

Open FF, and install the following:
https://addons.mozilla.org/en-US/firefox/addon/60/

Restart FF and then open your page. Once your page loads, on the developer bar click on "Information > View Javascript"

You should see ALL the javascript code of that page OR an error indicating if the file did not load.

Make sure all the js is loaded properly. It seems to be working fine for me when I linked to the cookie.js file AND I used

$('#tabs').tabs({cookie:{expires:30}});
hielo 65 Veteran Poster

my previous comment has a direct link to it (I just updated it).

hielo 65 Veteran Poster
Just need to know how to rank in google , I have done keywords , but its not coming up and not sure what I am doing wrong.

I don't know, but that is a completely different issue that is perhaps more suitable if posted under "Internet Marketing > Search Engine Optimization"

hielo 65 Veteran Poster

Read ALL my comments on my post from Sep 20th, 2010, 23:43

http://plugins.jquery.com/files/jquery.cookie.js.txt

Be sure to save it as a js file

hielo 65 Veteran Poster

I noticed your source code on the original post, but I don't have all those file you are using nor an available server to upload them to.

On another note, I clearly stated that you should be including the jquery COOKIE plugin. I don't see that in your code anywhere. Without it, my previous suggestion will never work.

hielo 65 Veteran Poster

Is this a mime-type issue in the header section?

It sure sounds like it. On line 11, try changing:

mysql_fetch_array($result)

to:

mysql_fetch_assoc($result)
hielo 65 Veteran Poster

are you using the html entity for the pound symbol?
&#+163;
(remove the + sign. I added it because it was being interpreted as html on this site's editor)

http://htmlhelp.com/reference/html40/entities/latin1.html

Also, try adding this to your document's <head>:

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
hielo 65 Veteran Poster

do you have a link to your page?

hielo 65 Veteran Poster

The variables YOU declare are not visible within the functions. But others like $_GET, $_POST, $_SERVER, etc, are "special". They are visible everywhere without the need to "declare them"/"use the global keyword" within functions.

As for your include, consider this:

file1.php
<?php
$greeting="Hello";
?>

file2.php
<?php
include("file1.php");

echo $greeting;//variable from file1.php visible here

sayItAgainIfYouCan();

function sayItAgainIfYouCan()
{
  echo $greeting;//but NOT visible here. You will need "global" keyword
}
?>
hielo 65 Veteran Poster
the firts code dont work because you return $cell, you MUST return $cell but printed or echoed, dont do

He is returning $cell and saving it onto $test, THEN he has print($test); . So in his case he needs to return $cell. His problem is related to variable scoping.

hielo 65 Veteran Poster

Glad to help.

Regards,
Hielo

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

jackparsana commented: thanks for help +1
hielo 65 Veteran Poster

the variables declared OUTSIDE the function do NOT exist within the function. So you need to pass all of them (INCLUDING the connection to the db - assuming somewhere you did [B]$dbConnection[/B]=mysql_connect(...) :

$test = date_sched($month,$date,$num_teachers,$timeslot,$dbConnection);

function date_sched($month,$date,$num_teachers,$slot,$dbConnection){
...
}

ALTERNATIVELY, you can use the global keyword to instruct the php engine to look for those variables OUTSIDE of the function:

function date_sched($slot){
  global $month,$date,$num_teachers,$dbConnection;
 ...
}
hielo 65 Veteran Poster

it sounds like your "main" page is index.php and you are posting to search.php. It that is the case your pagination links should have href="search.php..." , NOT href="index.php..." . It sounds like your links are posting to the "main" page (index.php in my example).

hielo 65 Veteran Poster

actually, instead of:

<script type="text/javascript">
    $(function() {
        $("#tabs").tabs();
    });
    </script>

use:

<script type="text/javascript">
    $(function() {
        $("#tabs").tabs({ cookie: { expires: 30 } });
    });
    </script>

BUT make sure you also import a copy of the cookie.js plugin:
http://plugins.jquery.com/project/cookie

hielo 65 Veteran Poster

assuming your pagination script is generating links SIMILAR to:

<a href="search.php?page=1">1</a>
<a href="search.php?page=2">2</a>

try changing it so the output is:

<a href="search.php?page=1" onclick="return ajaxSearch(document.getElementById('search'), this.href)">1</a>
<a href="search.php?page=2" onclick="return ajaxSearch(document.getElementById('search'), this.href)">2</a>

Then in your script tag, instead of the $(document).ready(...) you have, try the modified version below (include the ajaxSearch() function I am providing):

<script type="text/javascript">
function ajaxSearch(f,u)
{
     var ajax_div = $(f).attr("id")+"_results";
     var data = $(f).serialize() +'&search_button=Search';
     var url = u?u:$(f).attr("action");
     var type = $(f).attr("method").toUpperCase();
     $.ajax({
        url: url,
        data: data,
        type: type,
        success: function(data){
            $("#"+ajax_div).html(data);
        }
     });
     return false;
}

$(document).ready(function(){

  $("form.ajax").submit(function(){
  	ajaxSearch(this,'');
	return false;
  });

});
</script>
hielo 65 Veteran Poster

In your ajax code, try changing:
if you alert() the value of data before the ajax request is sent, are you seeing the search_button? IF not change:

var data = $(this).serialize();

to:

var data = $(this).serialize() +'&search_button=Search';
andrewliu commented: Excellent help! brilliant! +0
hielo 65 Veteran Poster

>>Does it matter about my pagination page?
That depends on whether or not it is producing html code that would "break" your initial markup. Do you have a link to your page?

hielo 65 Veteran Poster

FYI: on your original post, you are trying to insert the result into '#search_results', BUT I did not see any element with id="search_results" . Be sure to provide a target element:

<div id="search_results"></div>
hielo 65 Veteran Poster

and HTML CLOSING comment tag does NOT have a "!" symbol. The proper comment should be:

<!-- the html tag -->

WRONG:

<!--require("includes/pagination.php")!-->

CORRECT:

<!-- require("includes/pagination.php"); -->

Fix that and try again.

hielo 65 Veteran Poster

but now when I test my alerts, I get div tag alerts in my SUCCESS alert, and for COMPLETE: success

OK, but does the SUCCESS alert also have the output of your php search script?

try:

$(document).ready(function(){

 $("form.ajax").submit(function(){
     var ajax_div = $(this).attr("id")+"_results";
     var data = $(this).serialize();
     var url  = $(this).attr("action");
     var type = "GET";//$(this).attr("method").toUpperCase();
    // alert([url, data, type].join("\n"));//debug alert
     $.ajax({
        url: url,
        data: data,
        type: type,
        success: function(data){
            alert("SUCCESS: " + data);//debug alert
            if( document.getElementById(ajax_div) )
            {
             $("#"+ajax_div).html(data);
            }
            else
            {
              alert('I was not able to locate any element with id=' + ajax_div +'. You must provide a "target" element in which to dump/load the results!');
            }
        },
	        complete: function(XMLHttpRequest, textStatus){
          //  alert("COMPLETE: " + textStatus);//debug alert
        },
        error: function(XMLHttpRequest, textStatus){
           // alert("ERROR: " + textStatus);//debug alert
        }
     });
     return false;
  });

});
hielo 65 Veteran Poster

>>Thank you hielo!
You are welcome!

>>Your solution worked perfectly. Do you have time to educate me a bit more?
Not really :)

Why did I need to create a new variable from the onclick event?
In an HTML document, ALL the id's MUST be unique throughout the document. Due to this requirement, getElementById('charID') should get you a reference to THE one and only node with said id. So this would be wrong:

<input type='radio' id='charID' name='charID' value="1"/>
<input type='radio' id='charID' name='charID' value="2"/>

Because now getElementById() cannot determine accurately which element you want/need. That's why I "recorded" the clicked item into a "common/global" variable. Every time you click on any of those charID buttons, the variable gets updated.

It is OK for the names to be the same, but NOT the id. Correct:

<input type='radio' id='charID1' name='charID' value="1"/>
<input type='radio' id='charID2' name='charID' value="2"/>

>>When I used document.getElementById("charID").value I would get a different ID number each time. Why is the charID getting garbles / changed / modified?
Again, it must be unique. It sounds like you were probably re-using that id for multiple elements.

hielo 65 Veteran Poster

the browser submits the NAME of your input fields, NOT the id. So you MUST give your fields a name="..." attribute:

<input type=text id="usrName" name="usrName" size="20">

the same goes for the other fields.

hielo 65 Veteran Poster

Before answering your question, make sure you close your <FORM> tags at the end of each tab. Otherwise you will get unexpected behaviour across browsers.

As for your problem, the easiest approach to your problem is to bind an onsubmit method to your forms and submit an ajax request. That way the browser would not reload the page.

Alternatively, you can bind an onclick method/function to each of your tabs and create a cookie. When the page reloads, you will need to read that cookie and in init code for your tabs use that cookie to specify which tab to show first.

hielo 65 Veteran Poster

see code below. Notice that there is a leading space:

<input type="text" onchange="this.className+=' YourNewClassNameHere'" value="" />
hielo 65 Veteran Poster

Glad to help.

Regards,
Hielo

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

hielo 65 Veteran Poster

instead of:

echo "<input type='radio' id='charID' name='charID' value='" . $row['characteristicID']
                  . "'/> " . $row['characteristic'] . "<br />" ;

try:

echo "<input onclick='window.clickedCharID=this.value' type='radio' id='charID' name='charID' value='" . $row['characteristicID']
                  . "'/> " . $row['characteristic'] . "<br />" ;

then on the function that you need to know which of the radio buttons was checked all you need to do is test to see if it the variable clickedCharID exists:

if(typeof(window.clickedCharID)!="undefined"){
 alert(window.clickedCharID);
}
hielo 65 Veteran Poster
function ajaxpage(url,container)
{
 if(/\.(gif|png|jpg)$/i.test(url))
 {
   document.getElementById(container).innerHTML='<img src="'+url+'" alt="" />';
  return;
 }
 //whatever you currently have, should remain untouched
 ...
}
hielo 65 Veteran Poster

What you are actually (incorrectly) doing now is inserting the "BINARY" image content into the div. What you need to do is to insert and <IMG> tag into the div and set the SRC attribute to the path of the image. The browser will take care of the rendering.

qazplm114477 commented: nice, getting all that from such a short post +1
hielo 65 Veteran Poster

you need to prefix the double quote with a slash if your echo command uses the double
quotes:

echo "Welcome Guest!<br><a href='#' onclick=\"javascript:ajaxpage('login.php', 'ajax');\">"

Here's another implementation:

echo 'Welcome Guest!<br><a href="#" onclick="javascript:ajaxpage(\'login.php\', \'ajax\');">'

and another (look up the sprintf() function on the php.net site if it is not obvious to you what it is doing):

echo sprintf('Welcome Guest!<br><a href="#" onclick="%s">'
              ,"javascript:ajaxpage('login.php', 'ajax');");

and another one:

//begin echoing UNTIL you find the line that STARTS with the matching MYLINK+semicolon
echo <<<MYLINK
               Welcome Guest!<br><a href="javascript:ajaxpage('login.php', 'ajax');">
MYLINK;
/*on the line above, there MUST be a newline IMMEDIATELY after the semicolon. You cannot have any blanks between the semicolon and the newline; otherwise you will get a runtime error.*/
hielo 65 Veteran Poster

If you are using MySQL and the data type of your fields in your table are DATETIME, then what you need to know is that the dates are stored in the following format: yyyy-mm-dd, NOT in mm/dd/yyyy. So try:

$validFrom =date('Y-m-d');
$validTo=date('Y-m-d',strtotime("now +2 years"));
hielo 65 Veteran Poster

On index.php, when you call ajaxpage('page1.php', 'rightcolumn');

then your rightcolumn will have html - the html from page1.php:

<div id="rightcolumn">
<a href="javascript:ajaxpage('page4.php', 'rightcolumn');">page4</a>
</div>

When you click on page4, it should load it into the rightdiv of index.php because that link now exists within index.php.

On another note, page1.php should NOT send any element with id="rightcolumn" because index.php already has an element with that id. An id MUST be unique throughout the document even if you are populating elements via ajax.

hielo 65 Veteran Poster

try $date=date('m-d-Y');

hielo 65 Veteran Poster

without regex, the alternative is to list ALL the characters you don't want and use str_replace() to remove them - ex assuming you do not want any of the following:
# _ -

then use:

$str=str_replace('#_-','',$str);
echo $str;

but it is easier if you list only the ones that you DO want and use a regex to do the filtering.

hielo 65 Veteran Poster

Glad to help.

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

hielo 65 Veteran Poster

instead of simply executing mysql_query("..."); use mysql_query("...") or die( mysql_error() ); . This way you will get details about the error.

As for your ACTUAL problem, I am seeing field named "by", which is a keyword. To avoid this "beginner's mistake" (no offense), ALWAYS enclose the db name, table and field names in backticks:

mysql_query("INSERT INTO `markyourcard` (`date`, `link`, `by`, `time1`, `tip1`, `time2`, `tip2`, `time3`, `tip3`, `time4`, `tip4`, `time5`, `tip5`, `time6`, `tip6`, `time7`, `tip7`, `time8`, `tip8`)
        VALUES ('$date', '$link', '$by','$time1','$tip1','$time2','$tip2','$time3','$tip3','$time4','$tip4','$time5','$tip5','$time6','$tip6','$time7','$tip7','$time8','$tip8')") or die(mysql_error());

Lastly, to avoid "SQL injection" (if you don't know what that is, search it - there are tons of articles out there on the subject), instead of these:

$date        =     $_POST['date'];
            $link        =     $_POST['link'];
...

use these:

$date        =     mysql_real_escape_string($_POST['date']);
            $link        =     mysql_real_escape_string($_POST['link']);
...
hielo 65 Veteran Poster

Assuming you are using PHP to process your form, when you create your form
give all your checkboxes the same name BUT add the following suffix "[]" -ex:

<form method="post" ...>
<input type="checkbox" name="hobbies[]" value="Reading"/>
<input type="checkbox" name="hobbies[]" value="Biking"/>
<input type="checkbox" name="hobbies[]" value="Traveling"/>
...
</form>

Then when you submit your form then:

if( isset($_POST['hobbies']) )
  echo 'Total Hobbies: '.count($_POST['hobbies']);
else
  echo 'No Hobbies checked';
hielo 65 Veteran Poster

Yes, it is a keyword:
http://dev.mysql.com/doc/refman/5.0/en/reserved-words.html

However, if you really want to use that, enclose with backticks:
create table emp2 (`Leave` decimal(12,2) default NULL)

and when you do any operation on that field (SELECT/UPDATE/INSERT,etc) don't forget to ALSO put the backticks around it as well.

hielo 65 Veteran Poster

I think that result of ajax call cannot be assigned to variable.

Wrong, you can. In your case, it is in the "result" variable within the post callback function. You can simply take what's in it and assign it so whatever other variable you want.
Do you have a link to your page? There might be some incorrect reference to an element somewhere, but can't know for sure without looking at your markup.

hielo 65 Veteran Poster

line 2 is missing an equal sign. It should be:

$js=<<<SCRIPT

>>Hey Thanks Great Help
Glad to help

PS: Be sure to mark the thread as solved.

hielo 65 Veteran Poster
//save everything up to "SCRIPT;" in the variable $js
$js<<<SCRIPT
<script language="javascript" type="text/javascript">
			jQuery(document).ready(function() {
				$('#countdown_dashboard').countDown({
					targetDate: {
						'day': 		17,
						'month': 	9,
						'year': 	2010,
						'hour': 	1,
						'min': 		0,
						'sec': 		0
					}
				});
				
						});
		</script>
SCRIPT;
/*note the line where you see "SCRIPT;" MUST end with a semicolon IMMEDIATELY followed by a NEWLINE. If you leave spaces, you will get a runtime error. */

//now echo the javascript.
echo $js;
qazplm114477 commented: just learnt something new, thanks for that +1
hielo 65 Veteran Poster

try:

$("#ka").change(function(){
	var nadkat=$("#ka").val();
	$.post("uzmi_podkategorije.php", { nk: nadkat },  function(result){   
			$("#pka1").show();
			var niz=podaci.split("+");
			var i=-1,limit=niz.length;
			while(++i<limit){
				$('<option value="'+niz[i]+'">' + niz[i] + '</option>').appendTo('#pka');
			}
	});
});