johny_d 23 Junior Poster in Training

It matters very much; as a principle, try to have the main content as close to the top of the code of page as you can; on the other hand, the repetitive content - that search engines tend to disregard - like the navigation and other blocks that put the same content on many pages, you should put these as down to the bottom of the code as you can.
So, option 1 (Header DIV, Content DIV, Navigation DIV) is clearly better than option 2 (Header DIV, Navigation DIV, Content DIV)

johny_d 23 Junior Poster in Training

Let's think about the logic of things:
First step, we check if the user already voted - we check if the cookie is already set (beware that this is not very secure way to check that a user already voted, since a user can manually delete the cookie on his computer - you should probably combine this with the storage of the user IP and time of vote in a mysql table or a flat file on server side!);
anyway, let's get back to where we were.

if (isset($_COOKIE['mypoll'])) {
 echo "You already voted!";
 }
else {
 //// user hasn't voted yet, so we display the form or process the form if the user pushed the submit
 // we check if the form was submitted
 if (isset($_POST['qid'])) { // if form was submitted
  $mypoll = $_POST['qid'];
  setcookie('mypoll', $mypoll , time()+2592000 );
  // here you should store the value of the vote, together with the IP of user and time, in some mysql table or other sort of storage method so you can process the results later
  echo "Thank you for your vote! Here are the results.....";
  }
 else {
  // the form was not submitted, so you should show it to the user
  // FORM FOR THE VOTE
  }
 }

This should do it.

johny_d 23 Junior Poster in Training

Thanks ;)

johny_d 23 Junior Poster in Training

Regarding the check for cookies enabled or not, I use a different method:
I check for the SID constant - if cookies are enabled, than SID is an empty string, if cookies are disabled, SID is a string like this "session_name()=session_id()".
So,

if (SID == '') {
echo "cookies are enabled";
}
else {
echo "cookies are disabled; SID should be appended to url":
}
Of course, session should be started before all these!!!

johny_d 23 Junior Poster in Training

First, if you have Register Globals = Off in your php.ini (which is recommended), than you have to extract your $status variable from your post data, with a line like:
$status = $_POST; (or $_GET, if your form uses the Get method)
Second, change the Body tag of your html to:
<body onLoad="set_ycontact();">
so you trigger the form fields update on page load.

That's all ;)

johny_d 23 Junior Poster in Training

I'm on Windows, and I have:

# configure the path to php.ini
PHPIniDir "C:/php"

I don't know how it is on Linux; maybe you figure it out from here:
http://www.e-gineer.com/v1/instructions/install-php4x-for-apache1xx-on-linux.htm
It's for php4, but I think configuring the path to php.ini is the same for both php 4 and 5.

johny_d 23 Junior Poster in Training

If I'm not mistaking, you should also define the absolute path to your php.ini in your apache httpd.conf. Try this too, who knows...

johny_d 23 Junior Poster in Training

That is an array of arrays.
That means that each key of the top level array point to an array instead of a string value.
You can write that expression in another way:

$step[$d] = array ([$d] => $d);

or, to simplify:

step_array[process_id] = array (step_id => step_name);

In this expression, "process_id" is a key of the "step_array" and it has an array as value;
After you will iterate through all the values you will have something like this:

step_array[1][1] = step_name_1;
step_array[1][2] = step_name_2;
step_array[1][3] = step_name_3;

step_array[2][1] = step_name_4;
step_array[2][2] = step_name_5;

step_array[3][1] = step_name_6;

which is equivalent to

step_array[1] = array (1=>step_name_1, 2=>step_name_2, 3=>step_name_3);

step_array[2] = array (1=>step_name_4, 2=>step_name_5);

step_array[3] = array (1=>step_name_6);

which in turn is equivalent

step_array = (1=>array (1=>step_name_1, 2=>step_name_2, 3=>step_name_3), 2=>array (1=>step_name_4, 2=>step_name_5), 3=>array (1=>step_name_6));

and that's what I said in the begining:
an array of arrays !

johny_d 23 Junior Poster in Training

I'm glad you found a solution to your problem; see you arround.

johny_d 23 Junior Poster in Training

Try this

$query_1 = "SELECT billingStatementNo, transactionDate, transactionType, subjectCode, clientID, attorneyID, rateHour, consumedHour, currency, legalFees, checkInvoice FROM billingstatement";
 
$result_1 = mysql_query ($query_1) or die (mysql_error());
if (mysql_num_rows($result_1) <1) {
die ('No data to transfer');
}
else {
while ($src_row = mysql_fetch_row($result_1)) {
$row = implode ("','",$src_row);
$query_2 = "insert into billingstatementhistory(billingStatementNo, transactionDate, transactionType, subjectCode, clientID, attorneyID, rateHour, consumedHour, currency, legalFees, checkInvoice) values ('$row')";
$result_2 = mysql_query($query_2) or die (mysql_error());
}
}
johny_d 23 Junior Poster in Training

Well, all that's there are basic tables that you can find in php manual.
The way you structure the tables is another thing and that you don't find in books. First, you have to understand what you want to accomplish and than how to put it in maths matrixes (which I think tables expressions are).

So, let's start with what we want to get:
we have 3 levels of info, each level being the parent of the next one.

level 0: PROCESS
level 1: STEP; has PROCESS as parent
level 2: SUBSTEP; has STEP as parent

so, we want 3 arrays, each with information from one level and the connection to its parent, so we can see later who's child is each table; (for the sake of the clearness I'll write without $ and quotes and any other php grammar; all I want is to emphasize the structure)

first one: process array
process[process_id] = process_name

second one: step array
What we want next is to create an array of steps (children) for each process;
step[process_id] (eg: step[1], step[2], step[3], where 1,2,3 are the ids of the parent processes
)
so if we have 3 processes in the process array, we'll have 3 step arrays, each one with its own pairs of keys=>values, which are the steps corresponding to the respective process.
Eg:
step[1] = array(s1_key_1=>s1_value_1, s1_key_2=>s1_value_2, ....);
This translates as: the steps for process …

johny_d 23 Junior Poster in Training

As long as the content is unique and comes up naturally (not 1000 pages over-night), than you'll be ok, no matter how many sites you have on one server.

johny_d 23 Junior Poster in Training

I'm glad to be of help ;)

johny_d 23 Junior Poster in Training

There would be something to say:
1. You don't have a DOCTYPE declaration, whitch I think is very important; you must correct that. Check http://validator.w3.org/check?uri=http%3A%2F%2Fwww.thenerds.net%2Findex.php for details.

2. In your home and category page the title of your products are in H1 tags; using H1 is very SEO if you use it once on a page, usually the same or simillar to the TITLE tag of that page; using H1 many more times could actually hurt your SEO or even get you penalized; I suggest you put the category name in H1, subcats in H2 and product names in H3

3. The TITLE tag on product detail page: you lose a lot of precious space and character position with the product code: get rid of it. It doesn't help your SEO in any way and it pushes your keywords further from the start of the tag, which is very bad for SEO

4. The product images ALT tag: same as with the title - get rid of the product code from there; you could add the short description near the name of the product

You should aply these principles to all your pages.

A more subtle thing is the way your content is placed on the page: if you look at your code you'll see that the upmost thing on (all) your pages is the left menu which is veeeeeery long and the same on all pages, while your main content (product …

johny_d 23 Junior Poster in Training

Say you have a subdomain based site that does well in the search engines, and you need to change the subdomain name (only). Will your new subdomain site be starting from scratch with the search engines? (not even indexed?)

If you want to move your site from one subdomain(domain) to another subdomain(domain), you should use a 301 redirect (permanently moved redirect) - do a query on google for that and you will find plenty of info about it and how to implement.

This way, your new domain (subdomain) will get the visitors from the old one (you won't lose traffic) and search engines will replace the old site with the new one in their index, so you won't lose SE indexing and PR. As far as I know, it takes 2-3 weeks for google to transfer the PR from the old domain to the new one.

johny_d 23 Junior Poster in Training

here's your code:

$query = "SELECT `process`.`process`,`process`.id as pid,step.step,step.id as sid,substep.substep, substep.id as bid FROM `process`, step, substep WHERE `process`.id =step.process_id AND step.id=substep.step_id";
$rows = mysql_query ($query);
     
while ($d  = mysql_fetch_assoc ($rows)) {
 $process[$d['pid']] = $d['process'];
 $step[$d['pid']][$d['sid']] = $d['step'];
 $substep[$d['sid']][$d['bid']] = $d['substep'];
 }
 
$result = "<ul>";
foreach ($process as $kp => $vp) {
 $result .= "<li>".$vp."\r\n <ul>\r\n";
 foreach ($step[$kp] as $ks => $vs) {
  $result .= "  <li>".$vs."\r\n  <ul>\r\n";
  foreach ($substep[$ks] as $kb => $vb) {
   $result .= "   <li>".$vb."</li>\r\n";
   }
  $result .= "  </ul></li>\r\n";
  }
 $result .= " </ul></li>\r\n";
 }
$result .= "</ul>\r\n";
 
echo $result;
johny_d 23 Junior Poster in Training

Depends on how you think your users first name and surname would be.
For example, let's say the first name would be a single word, 4 to 20 letters and surname would be one or two words, each between 3 to 20 letters.
You would have something like this:

<?php
$name = 'Jackson';
$surname = 'George Michael';
if (preg_match ('/^[a-z]{4,20}$/i',$name)) {
 echo "Good name";
 }
else {
 echo "Bad name";
 }
 
if (preg_match ('/^[a-z]{3,20}(| [a-z]{3,20})$/i',$surname)) {
 echo "Good surname";
 }
else {
 echo "Bad surname";
 }

?>
johny_d 23 Junior Poster in Training

The error you get (...unexpected T_STRING ...) means you try to use an unquoted string; the mysql_query (the part between parenthesis) must be quoted.
Anyway, I'm not sure the mysql statement works that way!!!

johny_d 23 Junior Poster in Training

Try this:

$query = "SELECT `order`.`order`,`order`.id as oid,genus.genus,genus.id as gid,species.species, species.id as sid FROM `order`, genus, species WHERE `order`.id =genus.order_id AND genus.id=species.genus_id";
$rows = mysql_query ($query);
     
while ($v  = mysql_fetch_assoc ($rows)) {
 $order[$v['oid']] = $v['order'];
 $genus[$v['oid']][$v['gid']] = $v['genus'];
 $species[$v['gid']][$v['sid']] = $v['species'];
 }
 
$result = "<ul>";
foreach ($order as $ko => $vo) {
 $result .= "<li>".$vo."\r\n <ul>\r\n";
 foreach ($genus[$ko] as $kg => $vg) {
  $result .= "  <li>".$vg."\r\n  <ul>\r\n";
  foreach ($species[$kg] as $ks => $vs) {
   $result .= "   <li>".$vs."</li>\r\n";
   }
  $result .= "  </ul></li>\r\n";
  }
 $result .= " </ul></li>\r\n";
 }
$result .= "</ul>\r\n";
 
echo $result;

It worked on my comp.

johny_d 23 Junior Poster in Training

I may be wrong, but I think there is no way you can authenticate to a mail server using just the mail() function in php.
You should set your server to allow emails from localhost/ local IP without authentication.
I use phpMailer class from here: http://phpmailer.sourceforge.net/
It is open source and has a lot of functionality, including authentication on smtp servers.

johny_d 23 Junior Poster in Training

I don't understand what you mean by "creating a template using FCkeditor"; as far as I know, FCkeditor is an online text editor.
Can you explain in more detail what you try to accomplish?

johny_d 23 Junior Poster in Training

You're welcome

johny_d 23 Junior Poster in Training

The way I wrote it

... [\d]{4}...

, it works.
The way you wrote it

... \\d{4} ...

, it doesn't.

johny_d 23 Junior Poster in Training
<?php
$string = '2005-03-IT-31';
if (preg_match ('/^[\d]{4}-[\d]{2}-[a-z]{2}-[\d]{2}$/i',$string)) {
 echo "Right format";
 }
else {
 echo "Wrong format";
 }
 
?>
johny_d 23 Junior Poster in Training
<?php
$string = 'But i am not looking this simple one. what i am looking here is i searched a keyword (for eg php ). After searching I got some results from the database. if the result has a keyword php, then that all (php) word should be highlited. please help me';
$search_str = 'php';
function str_highlight ($string, $search_str) {
 if (trim($string) == '') {
  $return_str = 'Empty string';
  }
 elseif (trim($search_str) == '') {
  $return_str = 'Empty search string';
  }
 else {
// i put style="...." because i don't have a class="highlight" defined
  $return_str = preg_replace ("/$search_str/i",'<span class="highlight" style="background:#f00; color:#fff; font-weight:bold; padding:0 2px;">'.$search_str.'</span>',$string);
  }
 return $return_str;
 }
$new_str = str_highlight ($string, $search_str);
echo $new_str;
 
?>
stymiee commented: kudos +5
Shanti C commented: good +2
johny_d 23 Junior Poster in Training
johny_d 23 Junior Poster in Training

You're welcome! :)

johny_d 23 Junior Poster in Training

The problem is here:
@mysql_connect(localhost, onelastr_simba, ...........)

You define some constants in the first lines, but you try to put the constant values in your connection string, instead of the constant names

you should have:

@mysql_connect(dbHOST, dbUSER, dbPASS)

:icon_wink:

johny_d 23 Junior Poster in Training

You're welcome :)

johny_d 23 Junior Poster in Training

Ir runs only when viewed by a user and will run in continuous loop until the user closes the browser.

Of course, you can setup a $_GET variable to count the loops and stop at some point

Thanks, good idea, can I use a timevalue, like refresh 12:00:xx

As far as I know, in header(refresh...) you can only specify the number of seconds the script has to wait untill refresh, not a certain hour.

johny_d 23 Junior Poster in Training

Or you can simply ad

header('refresh:10; url=same_page.php');
johny_d 23 Junior Poster in Training

You can find it in the php manual if you do a little search :)
Here is that code adjusted to what you need:

<?php
 
/// here is your database connection
 
/// than the query
$result = mysql_query ("select field_1, field_2, field_3 from table") or die (mysql_error());
 
$filename = $_SERVER['DOCUMENT_ROOT'].'/test.xls'; //// or whatever.txt
 
if (!$handle = fopen($filename, 'a')) { 
        print "Cannot open file ($filename)"; 
        exit; 
   } 
// Let's make sure the file exists and is writable first. 
if (is_writable($filename)) { 
 
while ($row = mysql_fetch_row($result)) {
 $row_content = implode ("\t",$row)."\r\n";
   // Write $row_content to our opened file. 
   if (!fwrite($handle, $row_content)) { 
       print "Cannot write to file ($filename)"; 
       exit; 
   } 
   }
 
   print "Success, content wrote to file ($filename)"; 
 
   fclose($handle); 
 
} else { 
   print "The file $filename is not writable"; 
} 
 
?>

Try to do the basics first (like reading the manual) ;)

johny_d 23 Junior Poster in Training

;)

johny_d 23 Junior Poster in Training

You're most welcome ;)

jbennet commented: good job +12
johny_d 23 Junior Poster in Training

Well, you have to have a server running on the first PC

johny_d 23 Junior Poster in Training

That's because you try to use short_open_tag (<? instead of <?php ) as your php openning tag in

<form action="<?=$_SERVER['PHP_SELF']?>" method="post">

while you probably have it set in your php.ini to off:
short_open_tag = Off

That's why, when you run the script, your form looks like this:

<form action="<?=$_SERVER['PHP_SELF']?>" method="post">

instead of

<form action="/path_to_your_file.php" method="post">

hence the error.

On your previous server (configuration) (2 months ago), you probably had short_open_tag = On , and that's why the same script worked.

Php reccomends in php.ini to avoid using short_open_tag in your scripts, exactly beacuse of this. On some servers this option is not enabled and you get in a lot of trouble, the way you did.

So, to solve your problem, try to use:

<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">

:)

johny_d 23 Junior Poster in Training

The quotes are ok.
I think your problem comes from that

htmlspecialchars

piece of code, because if you give an echo to

[B]htmlspecialchars([/B]$_POST[B][[/B]'username'[B]][/B], ENT_QUOTES[B])[/B];

before entering it in the mysql query you will probably see your username string contains at least one # charcater (the password is hashed anyway so doesn't have this problem).

Anyway, if your username string contains a # character, in mysql everything after that char is considered a comment so your sql statement is broken in that point and that's why you get this error.

I suggest you test it first with some simple, clean strings (user: abcd, pass: xyzw) and without

[B]htmlspecialchars[/B]

and see if it works and after that go to more complicated stuff.

johny_d 23 Junior Poster in Training

Here's the php code

<?php
header('refresh:5; url=new_page.php');
?>

Be very careful NOT to output anything (not even a blank space before the php tag) to the browser before you call the refresh beacause it will give you an error.

johny_d 23 Junior Poster in Training

I think it depends on how often the information that populates the drop-downs changes. If it doesn't change often (once a week, a month etc...), than the javascript may actually work faster and better for both user and server, because once the js file is cache, there is no more loading on the server.
If the data for the drop-downs changes regularly, than ajax is probably the best option; anyway, it seems there are some browsers that don't support ajax yet, so... some of the users may have problems using that form.

johny_d 23 Junior Poster in Training

There is at least one other solution to the problem: you save all your data in javascript tables and use onchange() event on one drop down to populate another from respective javascript table. The javascript can be put in an external file (if the information doesn't change to often, so it can be cached by the browsers and load faster) or can be generated on the fly from php, every time the script loads, if it updates often.
I've done this for a site few years ago, when ajax wasn't an option. And it works like a charm :)