hielo 65 Veteran Poster

It looks like you are creating a RADIO AND a TEXT field with the SAME name every time. Give them different names. For example, try using this for line 15:

document.getElementById('segment_form').innerHTML += "<input type='text' name='txt_segment_type_"+j+"' size='10' onFocus='check_other()' />";
hielo 65 Veteran Poster

it should be while ([B]$row[/B] = mysql_fetch_assoc($gar))

balle commented: Thanks it worked like a charm! =) +1
hielo 65 Veteran Poster

lines 15 and 16 should be:

$user = mysql_real_escape_string($_POST['username']);
$pass = mysql_real_escape_string($_POST['password']);

As for your ACTUAL problem, the reason for the error is that you are putting APOSTROPHES around the table and field names. That is wrong. You need backticks (On a standard English keyboard, it is on the same key as the ~ character) NOT apostrophes

if($user && $pass){
        $sql = "SELECT * FROM `users` WHERE `username`='$user'";
        $res = mysql_query($sql) or die(mysql_error());
        
        if(mysql_num_rows($res) == 0){
          $epass = md5($pass);
          $sql2 = "SELECT * FROM `users` WHERE `username`='$user' AND `password`= '$epass'";
hielo 65 Veteran Poster

Replace the previous hielo.php with the following:

<?php
// database connection stuff here

$searchType='AND';
$condition ='';
$condition .= (isset($_GET['year'])  && !empty($_GET['year'])  ? $searchType."  `year`='" . mysql_real_escape_string($_GET['year'])  . "' " : '');
$condition .= (isset($_GET['brand']) && !empty($_GET['brand']) ? $searchType." `brand`='" . mysql_real_escape_string($_GET['brand']) . "' " : '');
$condition .= (isset($_GET['type'])  && !empty($_GET['type'])  ? $searchType."  `type`='" . mysql_real_escape_string($_GET['type'])  . "' " : '');


if(trim($condition)=="")
{
	$query = "(SELECT * FROM `table1`) UNION (SELECT * FROM `table2`) ORDER BY `year` DESC ";
}
else
{ 
	$condition=substr($condition,strlen($searchType));
	$query = "(SELECT * FROM `table1` WHERE $condition) UNION (SELECT * FROM `table2` WHERE $condition) ORDER BY `year` DESC ";
}

$totalQuery="SELECT COUNT(*) as `total` FROM ($query) as t";
echo sprintf(PHP_EOL.'<!-- %s: %s -->',__LINE__,$totalQuery);
$result = mysql_query($totalQuery, $connection) or die("Could not execute query : $totalQuery ." . mysql_error());

$rows = mysql_fetch_assoc($result);

if ($rows['total']==0) { echo "Nothing found."; }

// Start paging variables
$screen = intval($_GET['screen']);
$PHP_SELF = $_SERVER['PHP_SELF'];
$rows_per_page=16; // number of records per page
$total_records=$rows['total'];
$pages = ceil($total_records / $rows_per_page); // calculate number of pages required

if ($screen < 0)
	$screen=0;
$start = $screen * $rows_per_page; // determine start record
$query .= " LIMIT $start, $rows_per_page";
echo sprintf(PHP_EOL.'<!-- %s: %s -->',__LINE__,$query);
$result= mysql_query($query) or die("Could not execute query : $query ." . mysql_error());

$i=1;
while ($row=mysql_fetch_assoc($result))
{

	$id=$row["id"];
	$name=$row["name"];
	$type=$row["type"];
	$year=$row["year"];

	include "(template.php)";

	if ($i==4)
	{
		echo '<div class="clear"></div>';
		$i=0;
	}
	$i++;
}

echo '<div class="clear"></div>
<div class="wardrobe-pagination">';

$year=rawurlencode($_GET['year']);
$brand=rawurlencode($_GET['brand']);
$type=rawurlencode($_GET['type']);

// create the links
//the only parameter that keeps changing in the links below is …
hielo 65 Veteran Poster

the problem is due to a missing apostrophe after $name : (NULL, '$name[B]'[/B], '$username', '2010-10-23', '$password') But I suggest you try the following:

<html>
<head>
<title>Using Default Checkbox Values</title>

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.0/jquery.min.js"></script>
<script type="text/javascript" >
$(function() {
	$(".submit").click(function() {
		var name = encodeURIComponent($.trim($("#name").val()));
		var username = encodeURIComponent($.trim($("#username").val()));
		var password = encodeURIComponent($.trim($("#password").val()));
		var gender = encodeURIComponent($.trim($("#gender").val()));
		var dataString = 'name='+ name + '&username=' + username + '&password=' + password + '&gender=' + gender;

		if(name=='' || username=='' || password=='' || gender=='')
		{
			$('.success').fadeOut(2).hide();
			$('.error').fadeOut(200).show();
		}
		else
		{
			$.ajax({
				type: "POST",
				url: "join.php",
				data: dataString,
				dataType:'json',
				success: function(data)
					{
						if(!data.error)
						{
							$('.success').fadeIn(200).show();
							$('.error').fadeOut(200).hide();
						}
						else
						{
							alert(data.error);
						}
					}
				});
		}
		return false;
	});
});
</script>

</head>
<body>

<form method="post" name="form" action="join.php">
<ul><li>
<input id="name" name="name" type="text" />
</li><li>
<input id="username" name="username" type="text" />
</li><li>
<input id="password" name="password" type="password" />
</li><li>
<select id="gender" name="gender"> 
<option value="">Gender</option>
<option value="1">Male</option>
<option value="2">Female</option>
</select>
</li></ul>
<div >
<input type="submit" value="Submit" class="submit"/>
<span class="error" style="display:none"> Please Enter Valid Data</span>
<span class="success" style="display:none"> Registration Successfully</span>
</div></form>

</body>
</html>


<?php
include('db_login.php');
if( isset($_POST) && !empty($_POST) )
{
	$status='{"status":%d,"error":"%s", "id":%d}';
	$name=$_POST['name'];
	$username=$_POST['username'];
	$password=$_POST['password'];
	$gender=$_POST['gender'];

	$query1 = "INSERT INTO `unknown`.`comments` (`id`, `user`, `comment`, `date`, `other`) VALUES (NULL, '$name', '$username', '2010-10-23', '$password')";
	$result1 = mysql_query( $query1 ) or die( sprintf($status, -1, mysql_error(), -1) );
	echo sprintf($status, 0, '',mysql_insert_id());
}
else
{
	echo sprintf($status, -2,'Nothing was posted',-1);
}
mysql_close($connection);
exit;
?>
hielo 65 Veteran Poster

IF you run the code you posted and look at the browser's source code (CTRL+U in Firefox an Chrome; View -> Source in IE) you should be seeing:

<FORM action='delrec.php?id='. mysql_insert_id() .'' method='post' <table...>

There are a few issues with this:
a. The [B]FORM[/B] tag is NOT closed! You need a [B]>[/B] BEFORE <table> b. It should be obvious that if your browser is receiving php code -ex mysql_insert_id() then you must not be escaping things properly while sending output. The correct way to formulate the beginning of that echo statement is:

echo "<FORM action='delrec.php?id=[B]"[/B]. mysql_insert_id() .[B]"[/B]' method='post'[B]>[/B]<table

c. Even after you have fixed the echo statement, based on what you posted:

- Post update news, insterts it into database
- Reloads page and fetches the update news

you should NOT be using mysql_insert_id() . That function will get you the last inserted id you would expect, but NOT if you have already reloaded the page after insertion.
You can call that function immediately after you insert the record, but as soon as the script that is doing the insertion stops executing, the db connection is closed and you cannot call mysql_insert_id() any more and expect to get the id of the last record you inserted. Thus by the time the page reloads the last inserted id will no longer be available to mysql_insert_id() Instead, what you need is to use the id you got from the SELECT statement:

echo "<FORM action='delrec.php?id=[B]"[/B]. [B]$the->id[/B] .[B]"[/B]' method='post'[B]>[/B]<table

On the …

Craig2231 commented: Thank You +3
hielo 65 Veteran Poster

assuming [0-9a-zA-Z_-] represents the set of allowed characters, and that $url contains the hyperlink you want to "clean", then try:

$url = preg_replace('#[^0-9a-zA-Z_-]#','',$url);
hielo 65 Veteran Poster

try parenthesizing your selects:

...
else
{ $query .= "(select * from `table1` WHERE `year`='$cat') union (select * from `table2` where `year`='$cat') order by `year` desc "; }
...

As for the second part of your question, you could put a dropdown with the list of available categories to sort by. Whenever the user makes a selection it would submit a request to the server with that category.

hielo 65 Veteran Poster

change:
$result = "mysql_query($query)"; to:
$result = mysql_query($query) or die( mysql_error() );

hielo 65 Veteran Poster

...but it gets one of them three times

Well, you originally were (incorrectly) nesting a while() within a for() so you would clearly end up with "duplicate" records. Based on your last feedback, then perhaps you shouldn't even be using the for construct at all:

$note = array();
$i=-1;
			while($n = $db->fetchArray($query)){
					++$i;
					echo "~" . $i . "~";
					$note[$i]['noteID'] = $n['noteID'];
					$note[$i]["title"] = $n['title'];
					$name = $db->getUserName($n['author']);
					$note[$i]["author"] = $name['first'] . " " . $name['last'];
					$note[$i]["date"] = $n['added'];
					$note[$i]["text"] = $n['text'];

			}
			echo "<pre style='text-align:left;'>";print_r($note);echo "</pre>";
			return $note;
hielo 65 Veteran Poster

You need to put quote around strings - words that are NOT PHP keywords - ex: $remark="Excellent"; because Excellent is NOT a php keyword. The same goes for the other remarks.

also, totalg IS a variable, so you MUST prefix it with a dollar sign in every instance of totalg.
WRONG: if(totalg <= 5.00 && totalg >= 4.51){ CORRECT: if($totalg <= 5.00 && $totalg >= 4.51){

hielo 65 Veteran Poster
<HEAD>
   <script type="text/javascript">  
     
   function toggleElement(sel1, element1) {  
     
     element1 = document.frm1.elements[element1];  
     //alert(element1.value);  
     if (sel1.value == 'others') {  
     
       element1.style.display = 'inline';  
   
    }  
     else {  
     element1.value = ''; // input text will be empty  
       element1.style.display = 'none'; // hide text element  
     }  
     
     return;  
  }  
  
  window.onload=function(){
      toggleElement(document.getElementById('city'), 'txt1')
  }
 </script>  
</HEAD>


<BODY>
   <form name="frm1" >  
     
   <select name="city" id="city" onchange="toggleElement(this, 'txt1')">  
    <option value="patna">Choose Payment</option>  
    <option value="mumbai">Credit Card</option>  
    <option value="others" selected="selected">Others</option>  
   </select>  
   <input type="text" name="txt1" id="txt1" value="" /> any text  
      
   </form>  

</body>
FreddieBambino commented: Very helpful comment he made to me about Javascript +1
hielo 65 Veteran Poster
<?php 
if($logged_in) { 
  echo "Welcome back, $logged_row[username]&nbsp"; 
 ?>
<a href="<?= $_SERVER["REQUEST_URI"] . '&amp;action=logout' ?>"><?= $lang['ACC_LOGOUT'] ?></a>
<?php
} 
else {
 print('<a href="http://xxx/login.html">Login</a> / <a href="http://xxx.com/signup.html">Signup</a>');
} 
?>
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

Adding a second column is really NOT the ideal approach/solution. What if you add more groups and a person needs to belong to many groups.

What you need to do is to add a table to list the groups and another table that holds the membership info:

Person
id firstName lastName
1  John      Smith
2  Sally     Jones


Group
id name
1  Directors
2  UK Sales
3  Marketing


PersonGroup
Person_id Group_id
1         1
1         2
2         3

Your query would be:

$sql=sprintf("SELECT p.id as personId, p.firstName, p.lastName
FROM Person p INNER JOIN PersonGroup pg ON p.id=pg.Person_id
INNER JOIN `Group` g on g.id=pg.Group_id
WHERE gp.id=%d", intval($var) );
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

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

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

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

try adding a "fake" field with a fixed valud for each of the selects and use that as your primary sort field:

( SELECT 1 as `temp`, `name`, `date` FROM `events` WHERE `date` >= curdate()  ) UNION ALL ( SELECT 2 as `temp`, `name`, `date` FROM `events` WHERE `date` < curdate()  )
ORDER BY `temp`, `date`
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

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
//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

That typically happens when you have the WRONG path to the image and/or you have misspelled the image name. Also, be aware that some webservers are case-sensitive. So if your image name is "logo.gif", then if you code "logo.GIF", it will not work.

So, your first task is to figure out the full path to your image. Type it directly in the browser's address:
http://www.yoursite.com/Images/logo.gif

If it loads, then you have the right path and you should be able to use that path in your image - <img src="http://www.yoursite.com/Images/logo.gif"> Also, if you are viewing your page via http, but your code uses the file protocol - <img src="file:///..."> then it will not work. You must reference the image using http, so you will need to upload the images to webserver.

hielo 65 Veteran Poster

When you create a table, you need to specify the engine - ex:

CREATE TABLE `dbName`.`tableName` (
 ...
)
ENGINE = INNODB
CHARACTER SET utf8 COLLATE utf8_general_ci;

By default, it is MyIsam. As a matter of fact, line 7 of your post CLEARLY shows that MyISAM IS the default engine on your db server.

Your post simply confirms that your DB "supports" InnoDB IF you choose to use it on your tables, but you have to specify which engine to use on the tables. If you don't it will assume you meant MyISAM, which does NOT support constraints.

All the tables involved in the relationship constraints will need the InnoDB storage engine.

hielo 65 Veteran Poster

Make sure your tables are using InnoDB Storage engine and then try:

ALTER TABLE `ORDERS` ADD FOREIGN KEY(`CUSTOMER_NUM`) REFERENCES `CUSTOMER`(`CUSTOMER_NUM`);
hielo 65 Veteran Poster

{ redirect_to(index.php); } needs to be in quotation marks: { redirect_to("index.php"); } Then go to index.php and make sure the page starts with:
<?php
session_start();

hielo 65 Veteran Poster
<?php
$start = strtotime("{$startdate} {$starthour}:{$startmin}");

$end =strtotime("+{$hour} hours +{$minute} minutes",$start);

echo 'Start Time'. date('Y-m-d H:i:s', $start);
echo 'End Time'. date('Y-m-d H:i:s', $start);
?>
hielo 65 Veteran Poster

what if you do:

<p id="Generate">  
<a href="index.php?act=generate_quotes&cb=<?php echo time();?>" class="main_control">Generate</a></p>
hielo 65 Veteran Poster

[QUOTE]Thanks for the tip, I just fixed it, but we are really on a different page (literally!). This whole topic should be about the page /verify.php, not /index.php[/QUOTE]
I know you were in verify.php but your pages are "interconnected" since you start at one page and as you proceed at a different step, you are posting to another page. Case in point, you fixed the nested form problem in verify.php, but it still persists in index.php. You need to fix that nested form problem everywhere. Also, you are using name="Submitter" in index.php, so you to use a different name in verify.php because it is a different step altogether. I suggest you use name="Submiter2" in verify.php.

<?php
session_start();
//you are arriving from index.php
if( isset(isset($_POST['Submitter']) && !empty($_POST['Submitter'])) )
{
    //save the data you posted from index.php
    foreach($_POST as $k=>$v){
        $_SESSION[$k]=$v;
    }
}
//you submitted from verify.php
elseif( isset($_POST['Submitter2']) && !empty($_POST['Submitter2']) )
{
    //retrieve the previously saved data from index.php
    $carrier = $_SESSION['carrier'];
    $number1 = $_SESSION['number1'];
    $number2 = $_SESSION['number2'];
    $number3 = $_SESSION['number3'];

    $number = $number1.$number2.$number3;

    $pin = rand(1, 9).rand(0, 9).rand(0, 9);
    $code = $pin;



    if($carrier == 1){
        $displaycarrier = "Verison";
        $site = "vtext.com";
    } elseif($carrier == 2){
        $displaycarrier = "AT&amp;T";
        $site = "txt.att.net";
    } elseif($carrier == 3){
        $displaycarrier = "Sprint";
        $site = "messaging.sprintpcs.com";
    } elseif($carrier == 4){
        $displaycarrier = "T-Mobile";
        $site = "tmomail.net";
    } elseif($carrier == 5){
        $displaycarrier = "MetroPCS";
        $site = "mymetropcs.com";
    } elseif($carrier == 6){
        $displaycarrier = "Virgin Mobile";
        $site = "vmobl.com";
    } elseif($carrier == 7){
        $displaycarrier = "Beyond …
hielo 65 Veteran Poster

Make sure that your page STARTS with session_start(); THEN (later on) you can assign to/retrieve values from $_SESSION.

In your case, instead of $sum use $_SESSION - ex:

$_SESSION['sum']=mysql_fetch_assoc($totals);
...
echo $_SESSION['sum']['GP1011_wk1'];
...
echo $_SESSION['sum']['PTS1011_wk1'];
...

Lastly, on the OTHER php page(s) where you want to use those values, you MUST also call session_start() at the beginning of the file first, THEN you can echo the values.

ceeandcee commented: Thank you! +1
hielo 65 Veteran Poster

Generally, when a function/method call returns something, and you need that something later on, you need to "receive/assign" it to something else. Your $post->get_news($user_id); returns an array, but there is NOTHING "receiving" that array. Also, just because your method get_news() returns an array, it does NOT "overwrite" the $post variable. Thus, after the method call, the $post variable is still a 'News' object. So $post[$i] is not valid - again, because $post is NOT an array - it is still a News object. So try:

$post=new News;
$data = $post->get_news($user_id);

//to verify that you got the array you were expecting
print_r($data);

for($i=0; $i<5; $i++){
  foreach($data[$i] as $k=>$v){
      echo $v; //get error: "Cannot use object of type News as array in ..."
   }
}

On another note, the only similarity between your thread and the other was that both of you have the need to retrieve data from the db. You are way ahead of the game since you already have some php code in place that needs minor fixing. The other poster didn't seem to have anything in place yet.

Regards,
Hielo

hielo 65 Veteran Poster

When I go to the link you posted and then look at the browser's source code I am seeing:

<form action="verify.php"...>
   ...
  <form action="javascript:alert('enable');"> 
  <input type="submit" id="Submitter" value="Continue to next step" disabled="disabled" /> 
  </form> 
...
</form>

That is NOT valid html and some browsers "choke" on it. You are NOT allowed to nest form tags:

WRONG:

<form>
  <form>...</form>
</form>

CORRECT:

<form>...</form>
<form>...</form>

So on your code get rid of the inner <form> and leave only the submit button <input type="submit" id="Submitter" value="Continue to next step" disabled="disabled" />

hielo 65 Veteran Poster

Then just get rid of the <html>...</html> . On the page you are submitting FROM you need your submit button to have name="Submitter" for the php code above to work.

hielo 65 Veteran Poster
<?php
if( isset($_POST['Submitter']) && !empty($_POST['Submitter']) )
{
 $to = "reciever@example.com";
 $subject = "Test Subject";
 $body = "Test Body";
 $headers = "From: sender@example.com\r\n" .
     "X-Mailer: php";
 if (mail($to, $subject, $body, $headers)) {
   echo("<p>Message sent!</p>");
  } else {
   echo("<p>Message delivery failed...</p>");
  }
  exit();
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<title>Untitled</title>
</head>
<body>
<form method="post" action="<?php $_SERVER['PHP_SELF']; ?>">
<input type="checkbox" name="agree" value="yes" onclick="Submitter.disabled = !this.checked" />Do you Agree?
<input type="submit" name="Submitter" id="Submitter" value="Submit" disabled="disabled"/>
</form></body>
</html>
keavon commented: It was very fast and worked pretty well. He helped me later on in an other post too. +1
hielo 65 Veteran Poster
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<title>Untitled</title>
</head>
<body>
<form>
<input type="checkbox" name="agree" value="yes" onclick="Submitter.disabled = !this.checked" />Do you Agree?
<input type="submit" name="Submitter" id="Submitter" value="Submit" disabled="disabled"/>
</form></body>
</html>
hielo 65 Veteran Poster

im using this code to make selection field. Here i want to get a Item ID when selecting Item. bt i cant change that Price as the "value=" of the Option. because i need value as a price for the bill counting

OK, so currently for every record you are sending something similar to: <option value="12">...</option> Why not just send something like: <option value="xxx___12">...</option> Where "xxx" is your ItemId and "___" is just a "delimiter".

echo sprintf('<option value="%s___%s">%s</option>' . PHP_EOL, $row['ItemId'], $row['Price'], $row['ItemName']);

Thus, all you would need to do when you get that value, is split the value at the delimiter:

list( $itemId, $itemValue) = explode("___",$_POST['item8']);
echo 'Item: '.$itemId . '=' . $itemValue;
Kadafiz commented: really good +1
hielo 65 Veteran Poster
I am using jQuery $.post to send Ajax requests. It works fine for non redirecting PHP scripts,

There's your problem. From the jQuery manual

jQuery.post( url, [ data ], [ success(data, textStatus, XMLHttpRequest) ], [ dataType ] )

the third argument is a reference to a function which is to be called whenever the request completes "successfully". But this "successful" request equates to a http response status=200. A redirect gives you a 301 request, NOT 200. So you cannot use $.post(). Instead use $.ajax(). Currently you probably have something SIMILAR to:

$.post('page.php',params, function(){
  //here is whatever you are doing on a successful request
  ...
});

change that to:

$.post('page.php',params, function(){
  //here is whatever you are doing on a successful request
  ...
});
$.ajax({
  type: 'POST'
  ,url: 'page.php'
  ,data: params
  ,success: function(){
    //here is whatever you are doing on a successful request
    ...
  }
  ,complete: function(httpObj, textStatus){
     switch( 1*httpObj.status )
     {
          case 301: //here you do whatever you need to do
                    //when your php does a redirection
                    alert("Redirection");
                    break;

          case 404: //here you handle the calls to dead pages
                    alert("Page Not Found");
                    break;
     }
  }
});
hielo 65 Veteran Poster

Just add an hour, literally:

echo ' ' .date('M. d,Y @ g:i A', strtotime( $row['Timestamp'].' +1 hour') );
hielo 65 Veteran Poster
hielo 65 Veteran Poster

You need to make sub-arrays:
'OldValidFrom'=> array("25/08/2010","26/08/2010","27/08/2010"),

'OldValidTo'=> array("26/08/2110","26/08/2110","27/08/2110"),

hielo 65 Veteran Poster

OK, I read your follow-up problems again and I believe I have a clear understanding of your problem. Try:

<?php
error_reporting (E_ERROR);
$query="	SELECT	`Pos`
				,`Last`
				,`First`
				,`CFHL_A` AS `CFHL`
				, `Team`
				,`BDay`
				,`GP0910`
				,`PTS0910` 
			FROM `playerdb` 
			WHERE `CFHL_A`='FREE' 
				AND `Pos`='D' 
	UNION ALL 
		SELECT	`Pos`
				,`Last`
				,`First`
				,`CFHL_B` AS `CFHL`
				, `Team`
				,`BDay`
				,`GP0910`
				,`PTS0910` 
			FROM `playerdb` 
			WHERE `CFHL_B`='FREE' 
				AND `Pos`='D' 
	ORDER BY `PTS0910` DESC, `GP0910` ASC, `Team` ASC";

$result = mysql_query($query) or die("<hr/>Problems executing:<br/>$query<br/>" . mysql_error() );  

echo "<table width='350' border='1' cellspacing='0' cellpadding='1' bgcolor='ffffff'>";
echo "<tr> 
<td width='15' bgcolor='000000' align='center'><font face='arial' size='1' color='ffffff'><b>#</b></td>
<td width='20' bgcolor='000000' align='center'><font face='arial' size='1' color='ffffff'><b>POS</b></td>
<td width='170' bgcolor='000000' align='center'><font face='arial' size='1' color='ffffff'><b>PLAYER</b></td>
<td width='10' bgcolor='000000' align='center'><font face='arial' size='1' color='000000'><b>.</b></td>
<td width='30' bgcolor='000000' align='center'><font face='arial' size='1' color='ffffff'><b>TEAM</b></td>
<td width='20' bgcolor='000000' align='center'><font face='arial' size='1' color='ffffff'><b>AGE</b></td>
<td width='20' bgcolor='000000' align='center'><font face='arial' size='1' color='ffffff'><b>GP</b></td>
<td width='20' bgcolor='000000' align='center'><font face='arial' size='1' color='ffffff'><b>PTS</b></td>
<td width='30' bgcolor='000000' align='center'><font face='arial' size='1' color='ffffff'><b>PPG</b></td>
</tr>";
// keeps getting the next row until there are no more to get

$n=1;
while($row = mysql_fetch_assoc( $result )) {

	// Print out the contents of each row into a table
	
	
	echo "<tr><td width='20' bgcolor='ffffff' align='center'><font face='arial' size='2' color='000000'>"; 
 	
 	echo "".$n++;
	echo "</td><td width='15' bgcolor='ffffff' align='center'><font face='arial' size='2' color='000000'>";
	echo $row['Pos'];
	echo "</td><td width='170' bgcolor='ffffff' align='left'><font face='arial' size='2' color='000000'>"; 
	echo $row['Last'];
	echo ", ";
	echo $row['First'];
	echo "</td><td width='10' bgcolor='ffffff' align='center'><font face='arial' size='1' color='000000'>";  

 	echo $row['CFHL'];

	echo "</td><td width='30' bgcolor='ffffff' align='center'><font face='arial' size='2' color='000000'>";  
	echo $row['Team'];
	echo "</td><td width='20' bgcolor='ffffff' align='center'><font face='arial' size='2' color='000000'>";   
	echo calculateAge($row['BDay']);
	echo "</td><td width='20' …
ceeandcee commented: Great help! thanks so much! +1
hielo 65 Veteran Poster

Since the code that we use for validation is a highly standardized and system-wide class

I thought so, that's why I suggested that you STILL keep the current functionality that is accepting a number, but instead IMPROVE it (add more features to it).

Other than that, you have no choice but to iterate through the nodes as you are already doing in your original post. Since the sourceIndex is supported only by IE, then I suggest you modify your code so that it iterates ONLY when the browser is NOT IE:

function getIndex(element)
{
  if( typeof(element.sourceIndex)!="undefined" )
   return element.sourceIndex;

  for (var i=0; i<document.thisForm.elements.length; i++)
    if (element == document.thisForm.elements[i])
      return i;

  return -1;
}
hielo 65 Veteran Poster
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<title>hielo</title>
<style type="text/css">
.col{float:left;}
.lastCol{float:none}

#product_col1{width:30%;}
#product_col2{width:30%;}
#product_col3{width:30%;}
</style>

	</head>
	<body>
		<div id="product_col1" class="col">
     	<!--Contents of column 1-->a
		</div>

		<div id="product_col2" class="col">
     	<!--Contents of column 2-->b
		</div>

		<div id="product_col3" class="col lastCol">
     	<!--Contents of column 3-->c
		</div>
	</body>
</html>
hielo 65 Veteran Poster

...stripslashes($_POST); did you even bother to read the manual?
a. stripslashes expects a string NOT an array. $_POST is an array
b. it does NOT expect a reference. In other words, I had the following string in a variable $name="O\'malley"; then simply calling stripslashes($name); would not change the value of $name. You have to "receive" the value returned by stripslashes() and reassign it to $name: $name=stripslashes($name); On another note, what you are trying to do is already given at:
http://www.php.net/manual/en/function.get-magic-quotes-gpc.php#82524

hielo 65 Veteran Poster

try:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<title>hielo</title>
	<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
	<script type="text/javascript">
	$(function(){
		$('input[name^="qty"]').each(function(){
			update(this);
		});
	});

function update(el)
{
	var tr = el.parentNode;
	while (tr.nodeName.toLowerCase() != 'tr'){
		tr = tr.parentNode;
	}


	var qty= tr.cells[3].getElementsByTagName('input')[0].value;
	var price = tr.cells[2].getElementsByTagName('input')[0].value;

	var total = Math.round(qty*price*100);


	tr.cells[5].innerHTML = cToD(total);


	var rows = tr.parentNode.rows;
	var i = rows.length;
	var gTotal = 0;
	while (i--){
		gTotal += Math.round(rows[i].cells[5].innerHTML * 100);
	}
	document.getElementById('grandTotal').innerHTML = "<div class=\"field\"><input type=\"hidden\" size=\"3\" class=\"textbox\" id=\"total\" name=\"total\" value=\""+ cToD(gTotal) +"\"/></div>"+ cToD(gTotal) +"";
}


function cToD(c)
{
	if (c<10) return '0.0' + c;
	if (c<100) return '0.' + c;
	c += '';
	return (c.substring(0,c.length-2)) + '.'+(c.substring(c.length-2));
}
	</script>
	</head>
	<body>
	<!-- Your table stuff goes here -->
	</body>
</html>
pietpiraat commented: Coding is spot on! +1
hielo 65 Veteran Poster

how to keep it from being a pop up?

For that, you should NOT be using window.open(). Instead, just assign the url to location.href:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<title>Rotate Marketing</title>

<!-- 
IMPORTANT: Notice that I am importing "cookies.js". Go to:
http://www.quirksmode.org/js/cookies.html

scroll down to the section titled "The Scripts" and grab those three functions.
save them to a file named cookies.js and import them into your page similarly to
the way I am doing below
 -->
<script src="cookies.js" type="text/javascript"></script>

<script type="text/javascript">

      <!--
 
      var Win;

      var page_index = 0;

      var page = new Array();
      page[ page.length ] = "http://www.homebiz.usaloe.com";
      page[ page.length ] = "http://www.makethatmoney.usaloe.com";
      page[ page.length ] = "";
      page[ page.length ] = "";
      page[ page.length ] = "";
      page[ page.length ] = "";
      page[ page.length ] = "";
      page[ page.length ] = "";

      var next_page = function(){

      	//page_index = (( page_index === 8 ) ? 0 : page_index );
		page_index=++page_index % page.length;
      	if ( typeof Win !== "undefined" ) {

      		/* Win.location.href = page[ page_index ]; */
		location.href=page[ page_index ];
		createCookie("lastPage",page_index,30);
      	}
		

      };

      

      window.onload = function() {
	 page_index=readCookie("lastPage");
	 if(!page_index)
	 {
	 	page_index=0;
	 }
	 else
	 {
	 	page_index=++page_index % page.length;
	 }
	 createCookie("lastPage",page_index,30);
      	/* Win = window.open( page[ page_index ], 'Win', 'resize=yes,toolbar=yes, status=yes,scrollbars=yes, screenX=0,screenY=0, width=1000, height=666' ); */
	location.href=page[ page_index ];

      timer = setInterval( "next_page()", 10000000 );

      };

      

      // -->

</script>
</head>
<body>
</body>
</html>
hielo 65 Veteran Poster
preg_match('/user=([-0-9]+)/',$str,$m);

That won't work as desired. It will allow entries such as:
90-345

I believe the poster intends that hyphen to be "OPTIONAL and only at the beginning of the numeric substring, in which case he needs:

preg_match('/user=([-]?\d+)/',$str,$m);

where [-]? indicates an optional hyphen, and \d+ indicates one or more digits

It must be stated that the WON can also be PUSH or LOSS.

in that case search for any of those possible three values:

$str = "<td>102</td><td>Over 196.5</td><td>500</td><td>WON</td><td>+500</td>";

preg_match('\b(WON|PUSH|LOSS)\b',$str,$m);
echo $m[1];//this will echo the actual match
hielo 65 Veteran Poster
$str = '<div class="right"><a id="ctl111_contestProfileLink" href="http://contests.covers.com/Sportscontests/profile.aspx?user=265839&amp;sportid=0">Picks History</a></div>';

preg_match('#user=(\d+)#',$str,$m);
echo "User is: " . $m[1];
hielo 65 Veteran Poster

On my previous post change line 53: if(!page_index) to: if(null===page_index) if you are having difficulty figuring out the path to your cookie.js file, then try typing the full path in the browser's address bar - ex:
http://www.yoursite.com/scripts/cookies.js

If you see the browser trying to download the js file OR if the browser shows you the content of cookies.js, then that IS the correct path. Once you figure out what is that full path, then use that full path as the src attribute of the script tag.

hielo 65 Veteran Poster

The problem is that the page does not reload a different URL when you refresh the page

that's because on every reload, the code executes again from the top, like it is the very first time it is executing. You need to "maintain" state across refreshes. For this you will need to use cookies.

Refer to the code below. Pay special attention to the HTML comment that starts with IMPORTANT...

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<title>Rotate Marketing</title>

<!-- 
IMPORTANT: Notice that I am importing "cookies.js". Go to:
http://www.quirksmode.org/js/cookies.html

scroll down to the section titled "The Scripts" and grab those three functions.
save them to a file named cookies.js and import them into your page similarly to
the way I am doing below
 -->
<script src="cookies.js" type="text/javascript"></script>

<script type="text/javascript">

      <!--
 
      var Win;

      var page_index = 0;

      var page = new Array();
      page[ page.length ] = "http://www.homebiz.usaloe.com";
      page[ page.length ] = "http://www.makethatmoney.usaloe.com";
      page[ page.length ] = "";
      page[ page.length ] = "";
      page[ page.length ] = "";
      page[ page.length ] = "";
      page[ page.length ] = "";
      page[ page.length ] = "";

      var next_page = function(){

      	//page_index = (( page_index === 8 ) ? 0 : page_index );
		page_index=++page_index % page.length;
      	if ( typeof Win !== "undefined" ) {

      		Win.location.href = page[ page_index ];
			createCookie("lastPage",page_index,30);
      	}
		

      };

      

      window.onload = function() {
	 page_index=readCookie("lastPage");
	 if(!page_index)
	 {
	 	page_index=0;
	 }
	 else
	 {
	 	page_index=++page_index % page.length;
	 } …
jreddick82 commented: Great bit of help. Thank you +0