hielo 65 Veteran Poster

but the previous, next and the page number links are not there at all

Have you verified that your query actually returns MORE than 10 records? For purposes of testing, change: $display=10; //setting the number of records to display per page to: $display=5; //setting the number of records to display per page

hielo 65 Veteran Poster

but the previous, next and the page number links are not there at all

Have you verified that your query actually returns MORE than 10 records? For purposes of testing, change: $display=10; //setting the number of records to display per page to: $display=5; //setting the number of records to display per page

hielo 65 Veteran Poster

What you have now is fine. Also, regarding:

Humm ... well, i made the changes and amount does get updated but only to the last value available in the select list. So, for example:

$(document).ready(function () {
$('#item_name').change(function () {
	var value = $('#item_name').val();
	if(value == "institutional memberhip"){
		$("#amount").val("349.00");
	} else if(value == "associate memberhip"){
		$("#amount").val("99.00");
	} else {
		$("#amount").val("37.45");
	}
  });
});

The problem with that code is that you misspelled membership in you if clauses. Otherwise it would also work.

hielo 65 Veteran Poster

try changing: var value = $('#item_name').val(); to: var value = $('option:selected',this).attr('value');

hielo 65 Veteran Poster

elseif should be

else if

(you need a space in between).

Also, in your HTML, your <OPTION> tags need to have those values as well and don't forget that js is case sensitive:

<option value="institutional memberhip">Institutional Memberhip</option>
<option value="individual membership">Individual Membership</option>
hielo 65 Veteran Poster

since you are inserting text, change:

...VALUES (%s, %s, %s, %s)

to:

...VALUES ('%s', '%s', '%s', '%s')
hielo 65 Veteran Poster

on the last value you are inserting you have: 'null' Get rid of those apostrophes. It should be just NULL. Also, I suggest you list the fields you are inserting the data into: $query1="INSERT INTO `class`(`field1`,`field2`,`field3`,`field4`) VALUES(NULL,'$a','$grade', NULL)"; Replace the field# with the actual names of the fields in your db table.

hielo 65 Veteran Poster

change: GetSQLValueString $_POST['software[]'], "text") to: GetSQLValueString( implode(',', $_POST['software']), "text")

hielo 65 Veteran Poster

if you want to use just files, from what you posted earlier, try using this as your topics.php (just add more topics to the $topics array)

<?php
//FYI: the 234 and the 745 are meant to be "random". In other words, you can assign whatever numbers you want.
$topics=array(	'234'=>array('file'=>'globalwarming.php','text'=>'Global Warming')
				,'745'=>array('file'=>'child-labour.php','text'=>'Child Labour')
			);
$menu='';
foreach($topics as $key=>$property){
	$menu .=sprintf('|<a href="?id=%s">%s</a>',$key, htmlentities($property['text'],ENT_QUOTES) );
}
echo '<div>'.substr($menu,1).'</div>';
if( isset( $_GET['id']) && isset( $topics[ intval($_GET['id']) ] ) )
{
	require_once( $topics[ intval($_GET['id']) ]['file'] );
}
?>
hielo 65 Veteran Poster

On my previous post change:

$filename = "http://www.empowergroupusa.com/cambiolabs/extension/catalog/files/inspection_886.pdf";

to:

$filename = $_SERVER['DOCUMENT_ROOT'] . ' /cambiolabs/extension/catalog/files/inspection_886.pdf';
hielo 65 Veteran Poster

try:

<?php
$filename = "http://www.empowergroupusa.com/cambiolabs/extension/catalog/files/inspection_886.pdf";
if (file_exists($filename)){
	header('Content-Type: application/pdf');
	header('Content-Disposition: attachment; filename="Inspection.pdf"');
	readfile($filename);
	exit;
}
else
{
	echo "The file $filename does not exist";
}
?>
hielo 65 Veteran Poster

Also, I would like to make the part after inspection variable or dynamic so it will change based upon which page is loaded?

I have no idea what you are talking about. You need to elaborate!

hielo 65 Veteran Poster

try:

<?php
$filename = "http://www.empowergroupusa.com/cambiolabs/extension/catalog/files/inspection_886.pdf";

if (file_exists($filename)) {
echo '<a href="http://www.empowergroupusa.com/cambiolabs/extension/catalog/files/inspection_886.pdf">PDF</a>';
} else {
echo "The file $filename does not exist";
}
?>
hielo 65 Veteran Poster

or else the sql query is returning some error for sure

which query? He did NOT query the db at all! He simply assigned a string to $result. He needs to remove the red quotation marks I pointed out from line 6 on his second code block.

hielo 65 Veteran Poster

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

hielo 65 Veteran Poster

well turned out to be way easier.... just refreshed the page and it restored the current date values...

When those select fiels are all you have on the form (or they appear at the start of the form) then refreshing works fine. Even easier (IMHO) would be to call the reset() method of the form object. But if you first were to have have a name field followede by your selects, then refreshing would erase what was already entered in the name field.

hielo 65 Veteran Poster

ORIGINALLY you posted: $jobDesc = mysqli_real_escape_string ($dbc, $trimmed['txtJobProfile']); How are you populating/initializing the value of $trimmed?

hielo 65 Veteran Poster

I think I understand what you are asking now. Within your if clause you need to determine the current m/d/y and use that to reset the values of your drop downs:

<script>
//these will be updated upon load with the initially selected options
var initialDate={'date':-1,'month':-1,'year':-1};
window.onload=function(){
	initialDate.date=document.getElementById('daysOfMonth').selectedIndex;
	initialDate.month=document.getElementById('monthOfYear').selectedIndex;
	initialDate.year=document.getElementById('year').selectedIndex;
}


function isValidDate()
{
	var now = new Date();
	
	//advance one day
	now.setDate( now.getDate() - 1 );

	var Day=document.getElementById('daysOfMonth').value;
	var Month=document.getElementById('monthOfYear').value;
	var Year=document.getElementById('year').value;
	
	var str = Month + " " + Day + " " + Year;
	
	var selectedDate= new Date(str);
		
	if(selectedDate < now)
	{
		alert("You may not select dates in the past . . . only future days!!!");
		//now here you reset the selects to the initial values
		document.getElementById('daysOfMonth').selectedIndex=initialDate.date;
		document.getElementById('monthOfYear').selectedIndex=initialDate.month;
		document.getElementById('year').selectedIndex=initialDate.year;
	}	
}
</script>
hielo 65 Veteran Poster

assuming you are NOT saving the value in $_SESSION['jobProfile'] to the DB (just using if to display on browser), then instead of: $_SESSION['jobProfile'] = $jobDesc; try: $_SESSION['jobProfile'] = nl2br($trimmed['txtJobProfile']);

hielo 65 Veteran Poster

Do you at least now how to insert the data into the DB? If not, then I suggest you first read an online tutorial on PHP:
http://www.w3schools.com/php/default.asp

If you are already familiar with the syntax of php, then try skipping to the "forms" section of the tutorial. Be sure the read the MySQL portion.

hielo 65 Veteran Poster

try:

...
          <div align="right">
<?php
if( isset($_POST['daysOfMonth']) &&!empty($_POST['daysOfMonth']) )
{
	$day = $_POST['daysOfMonth']; 
	$month = $_POST['monthOfYear']; 
	$year = $_POST['year'];
}
else
{
	$date = time();

	$day = date('d', $date); 
	$month = date('m', $date); 
	$year = date('Y', $date);
}
//We then determine how many days are in the current month
$days_in_month = cal_days_in_month(0, $month, $year);

$current_month = date('F');
?>		
            <select name="daysOfMonth" id="daysOfMonth" onchange="isValidDate()">
              <option>....</option>
		    <?php 
		    		echo sprintf('<option selected="selected" value="%s">%s</option>',$day,$day); 
				for($i = 1; $i <= $days_in_month; $i++)
				{
					echo "<option value=".$i.">".$i."</option>";
				}
			?>
            </select>
...
hielo 65 Veteran Poster
<script type="text/javascript">
function setValue(field)
{
	if(''!=field.defaultValue)
	{
		if(field.value==field.defaultValue)
		{
			field.value='';
		}
		else if(''==field.value)
		{
			field.value=field.defaultValue;
		}
	}
}
</script>
<input type="text" value="Enter Title" onfocus="setValue(this)" onblur="setValue(this)"/>
hielo 65 Veteran Poster

which part are you having trouble with? I suggest you post what you have thus far and provide more details regarding your problem.

hielo 65 Veteran Poster

<option><?php if($day == 32){$day = 1; echo $day;}else{ echo $day;} ?></option> <!--problem-->

Where did you initialize $day ? BEFORE the if clause you should have:

$day = isset($_POST['daysOfMonth']) && !empty($_POST['daysOfMonth']) ? $_POST['daysOfMonth'] : 1;
hielo 65 Veteran Poster

Is it because they are both types of loops?

No. There is nothing inherently wrong with nesting looping constructs. In your case it is wrong because with what you originally posted it was going to make duplicates of each of the db records in your array, which is what you did NOT want (based on your follow-up comment).

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

however, when I use a refresh on my div it does refresh but does not change the image...

That's because that auto_refresh is NOT making an ajax call to the server. You should INITIALLY have an empty DIV: <div id="update"></div> Then when you make your ajax call, upon completion you insert the result of the ajax call. This means that your php code should be sending back ONLY the <img>, not the <img> wrapped in a div.

Lastly, your SELECT can be reduced to:

$gathercalls = mysql_query("SELECT * FROM `contact` WHERE `status`='open' AND (`staff`='moderator' OR `staff`='admin')");

but if all you need is to know how many rows are there, then a SELECT COUNT(*) query is a better choice if you do not actually need the row data.

See code below:

<?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></title>
<script>
var auto_refresh = setInterval(
	function ()
	{
		$.get('yourScript.php',function(data){
			$('#update').html(data).fadeIn("slow");
		});
	}, 60000); // refresh every 10000 milliseconds
</script>

</head>
<body>
	<div id="update"></div>
</body>
</html>
//yourScript.php
//using SELECT *
<?php
mysql_connect("localhost","username","password") or die( mysql_error() );
mysql_select_db("dbname") or die( mysql_error() );
	$gathercalls = mysql_query("SELECT * FROM `contact` WHERE `status`='open' AND (`staff`='moderator' OR `staff`='admin')") or die( mysql_error() );
	$gcalls = mysql_fetch_assoc($gathercalls);
	$gcall = mysql_num_rows($gathercalls);
}
if($gcall >=1)
{
?>
	<img src="images/new.gif" align="right" border="0">
<?php
}
else
{
?>
	<img src="images/normal.gif" align="right" border="0">
<?php
}
?>



//yourScript.php
//using SELECT COUNT(*)
<?php
mysql_connect("localhost","username","password") or die( mysql_error() );
mysql_select_db("dbname") or die( …
hielo 65 Veteran Poster

The trouble I am having is that the variable $i in the for loop is only recognized as 0 inside of the while, but it shows as the number it is supposed to outside the while.

On the first iteration (when $i equals zero) BEFORE the while() you have NOT yet fetched any db records. As soon as the while() FINISHES executing the first time (again, when $i equals zero), then $query (assuming that it is a resource that "points" to the the result set of a previously executed sql command - a SELECT to be specific) is NO longer pointing to a valid result set. So on the next iteration of your for construct (when $i equals 1), then $db->fetchArray($query) NO longer returns an array.

So, instead of:

for(...){
 while(...){
 ...
 }
}

do:

while(...){
 for(...){
 }
}
hielo 65 Veteran Poster

In your ORIGINAL code, instead of document.quiz , try using document.[B]forms.[/B]quiz (since you have <form id="quiz"...> )

hielo 65 Veteran Poster

try:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html>
<head>
	<title>JQuery Form Example</title> 
	<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.2.min.js"></script>
	<script type="text/javascript">
	$(function(){
		$('#myform').bind('submit',function(){
				$.post('process.php', $("#myform").serialize(), function(data) {
					$('#results').html(data);
				});
		});
	})
	</script>
</head>
<body>
<form name="myform" id="myform" action="" method="POST">  
<!-- The Name form field -->
    <label for="name" id="name_label">Name</label>  
    <input type="text" name="name" id="name" size="30" value=""/>  
	<br>
<!-- The Email form field -->
    <label for="email" id="email_label">Email</label>  
    <input type="text" name="email" id="email" size="30" value=""/> 
	<br>
<!-- The Submit button -->
	<input type="submit" name="Submit" value="Submit"> 
</form>
<!-- We will output the results from process.php here -->
<div id="results"><div>
</body>
</html>
hielo 65 Veteran Poster

tab is already an array. If you want to see everything as a single string then you need implode() not explode()

hielo 65 Veteran Poster

at the end of your first regex you have: ...(\#[-a-z!//\d_]*)?$/i Try escaping those slashes: ...(\#[-a-z!\/\/\d_]*)?$/i ALSO, instead of:
$valid_url="...";

try using apostrophes:
$valid_url='...';

hielo 65 Veteran Poster

should be created < DATE_SUB(NOW(), INTERVAL 30 DAY) ( no '<=', simply use'<' )

as for the deletion, the function is named unlink()
http://us3.php.net/manual/en/function.unlink.php

hielo 65 Veteran Poster

It's because your SELECT query failed. Instead of: $sql_query = mysql_query("SELECT * FROM blog WHERE MATCH(title,post) AGAINST('$search_term')"); try using the following you you can find out WHY the error ocurred: $sql_query = mysql_query("SELECT * FROM blog WHERE MATCH(title,post) AGAINST('$search_term')")[B] or die(mysql_error())[/B] ;

hielo 65 Veteran Poster

there is no such thing as:
else OPEN_PARENTHESIS condition CLOSE_PARENTHESIS { ... }

the proper syntax for an else is a "braced block" with NO condition:
else{
...
}

there is:
if OPEN_PARENTHESIS condition CLOSE_PARENTHESIS { ... }

and also
elseif OPEN_PARENTHESIS condition CLOSE_PARENTHESIS { ... }

so if you really want to include that condition, you should use and elseif

hielo 65 Veteran Poster

after this is executed:

$r = mysql_query("select userid from dept_user where dept_id=$dept LIMIT 0, 30 ");

$r does NOT have the userid. It "points" to "something" (a resource) which contains the actual data from the result set (assuming some result was actually returned). What you need to do is EXTRACT the column value from that resource:

...
$r = mysql_query("select userid from dept_user where dept_id=$dept LIMIT 0, 30 ") or die( mysql_error() );

//here you "Extract" the data from the resource
while( $row=mysql_fetch_assoc($r) );
{
$qry = "INSERT INTO course_detail(userid, course_id, date_assign, expected_end_date, owner) VALUES('" . $row['userid'] . "','$name','$sdate', '$edate', '$m_name')" ;
  echo 'executing '.$qry.'<br/>';
  mysql_query($qry) or die( mysql_error() );

};
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
Iv had a go at that, the key I need to override is backspace but entering the backspace code (8) does not seem to work. How should that work?

it will be better if you post what you have

@Airshow: I suspect he's developing something similar to a Greasemonkey script/"extension"

hielo 65 Veteran Poster

try:

<?php
if ( isset($_POST['seo']) && $_POST['seo'] == 'Save' )
{
	foreach($_POST['title'] as $index=>$value)
	{
		$title = mysql_real_escape_string(trim($_POST['title'][$index])); 
		$description = mysql_real_escape_string(trim($_POST['description'][$index])); 
		$keywords = mysql_real_escape_string(trim($_POST['keywords'][$index])); 
		$res = mysql_query("UPDATE `content_en` SET `title`='$title',`description`='$description',`keywords`='$keywords' WHERE `id`=1");
		if (!$res) 
			die("Error saving the record!  Mysql said: ".mysql_error()); 
		header("Location: home.php");
	exit;
	}
}
$query = mysql_query("SELECT `id`, `title`, `description`, `keywords` FROM `content_en` WHERE `id` = 1") or die( mysql_error() ); 
echo '<form name="seo" action="home.php" method="post">';
while( $data = mysql_fetch_assoc($query) )
{
?>

	<div>Title: <input size="66" type="text" name="title[<?php echo $data['id']; ?>]" id="title[<?php echo $data['id']; ?>]" value="<? echo htmlentities($data['title'],ENT_QUOTES); ?>"></div>
	<div>Description: <input size="100" type="text" name="description[<?php echo $data['id']; ?>]" id="description[<?php echo $data['id']; ?>]" value="<? echo htmlentities($data['description'],ENT_QUOTES); ?>"></div>
	<div>Keywords: <input size="100" type="text" name="keywords[<?php echo $data['id']; ?>]" id="keywords[<?php echo $data['id']; ?>]" value="<? echo htmlentities($data['keywords'],ENT_QUOTES); ?>"></div>
<?php
}
?>
	<div><input type="submit" name="seo" value="Save" /></div>
</form>
hielo 65 Veteran Poster
You put the wrong type of single quotes on the line:
Here's the correction:
      $sql="UPDATE 'Sample' SET 'Fname'='$a','Lname'='$b'";

WRONG! databases, tables names and field names may NOT be enclosed in apostrophes in MySQL. You need to use backticks. The problem was that the FORM tag was NOT around the fields she was editing!

hielo 65 Veteran Poster

if (allSelect.className == "optionLinks")
allSelect.push(allSelect);

No. IF allSelect originally has TWO SELECT elements - due to getElementsByTagName() - and one of them has a class="optionLinks" , then what you are doing is taking that same SELECT (the one with class="optionLinks") and adding ANOTHER reference to it at the end of allSelect. Thus allSelect now has three elements. Eventually your loop will check this new added element and see that it TOO has class="optionLinks" and another reference to it at the end of allSelect. Thus, will keep doing this infinitely.

To fix your problem, all you have to do is REPLACE line 33 with line 35.

hielo 65 Veteran Poster

>> $username = $USERNAME; Where did you initialize $USERNAME? Most likely your query is not returning any results.

hielo 65 Veteran Poster

then you will need to do so AFTER the page has loaded. To clarify, basically this is what needs to be done:

//assuming this is what is there initially
document.body.onkeypress=function(){
 //code that "listens" for "H"
 ...
};

then you need to override that listener after page load:

onload=function(){
 //assuming this is what is there initially
 document.body.onkeypress=function(){
  //YOUR function definition here.
  ...
 };
}
hielo 65 Veteran Poster

OK. I thought you were referring to multiple files but using only html. Try:
http://www.uploadify.com/

hielo 65 Veteran Poster

Read http://www.php.net/manual/en/info.configuration.php#ini.magic-quotes-gpc
if that directive is enabled on your server and you typed/submitted the following:
O'Brian/O'Malley

then the server will auto-convert it to:
O\'Brian\/O\'Malley

then if you call stripslashes() it will change it back to what you originally typed:
O'Brian/O'Malley

notice that it removes only BACK slashes, not forward slashes.

Also, htmlentities() will first change <span>...</span> to &lt;span&gt; , but strip_tags() does NOT "understand" &lt;span&gt; . It will remove the tags only if they are "unencoded". So swap lines 53 and 54.

hielo 65 Veteran Poster

...the down side is that I have to browse to each and every picture to select it.

if you rephrase that sentence to "the down side is that I have to manually select each and every picture..."

then clearly you are looking for a way to select the pictures programatically. For security reasons, the browser does NOT allow you to "select" files programatically. Otherwise, there would be tons of sites out there that upon page load would automatically upload your files programatically to a remote server (auto-steal your files)!

So, your option would be to have the individual create a zip file of the photos and that way he/she would only upload one file. You can then unzip the file on your server once it is uploaded and then process all the pictures at once.

hielo 65 Veteran Poster

If your page contains a frame, and THAT frame contains and EXTERNAL/REMOTE page that contains the javascript that is "listening" for the "H" keypress, then you will NOT be able to rebind the event. In other words, what you are trying to do is not possible. The security restrictions imposed by the browser will not give you access to the iframe content/objects if it is from a different domain.

hielo 65 Veteran Poster

My question is whether there is any possibility for an user to override my validation and get away with an invalid entry ?

No. The expression allows exactly 10 characters, of which the first MUST be a zero and the remaining nine may be any of 1...9.

hielo 65 Veteran Poster

...var req = new Request.JSON where did you define the Request object? It looks like you forgot to "include/import/ling to" a javascript file!

hielo 65 Veteran Poster

...echo '<a href="deleted.php?id='.$row['id'].'">Delete</a>'; where did $row come from?
a. An INSERT query does NOT return any records - NOT even the auto id of the new record.
b. Even IF it returned records, you would still need to retrieve the actual columns with statement such as:

<?php
$row=mysql_fetch_assoc($results);
?>

but like I said, an INSERT does not return any records, so $results does NOT "point" to a recordset!

Instead what you need is mysql_insert_id():
http://us2.php.net/manual/en/function.mysql-insert-id.php

So change:

echo '<a href="deleted.php?id='.$row['id'].'">Delete</a>';

to:

echo '<a href="deleted.php?id='. mysql_insert_id() .'">Delete</a>';