edwinhermann 57 Junior Poster

My approach would be to create not so much as a database but just a flat file, say tab delimited. You can read the entire thing into memory with PHP and manipulate the data as needed.

You could either run a web server locally (Macs have this already built in) or run it command-line based if suitable.

You'd want it to prompt for a username/password before proceeding.

You would write functions to add a new row of data, delete a row given an id, change a value given an id and column name, etc.

The entire project could be encrypted with PHPshadow. That's the cheapest PHP encryption I've found - only 5 Euros to encrypt (during a 48-hour period) or 0.99 if you do it online. Only thing is it is not available for Windows.

Regarding javascript encryption, remember that if the browser can see it, so can you. In other words, javascript encryption is pointless.

edwinhermann 57 Junior Poster

The dots get changed to underscores. So use this instead:

$linex = $_GET['shapes_image_x'];
$liney = $_GET['shapes_image_y'];
edwinhermann 57 Junior Poster
echo substr($search,0,4); //this would print out "Hello"

Not quite. That would print out "Hell" (4 characters)

decade commented: thank you +1
edwinhermann 57 Junior Poster

I agree with evstevemd.

foreach ($array as $key => $value) {
  echo 'The key is '.$key.' and the value is '.$value; 
 }

$key and $value are created as part of the foreach statement.

edwinhermann 57 Junior Poster

You can use cron to call a php page.
IN your crontab file, the command part would be something like this:

/usr/bin/php /users/me/www/myfile.php
edwinhermann 57 Junior Poster

You came here for a suggestion and got a complete solution. Lucky guy.

I just re-read the original post, and now I realise it was for an assignment. I suppose I shouldn't have provided the complete solution. Oh well :)

edwinhermann 57 Junior Poster

I think this would work reasonably fast:

<?php
$filename = "/path/to/file.txt";
$handle = fopen($filename,"r");
if ($handle === false) {
  exit;
  }
$word = "";
while (false !== ($letter = fgetc($handle))) {
  if ($letter == ' ') {
    $results[$word]++;
    $word = "";
    }
  else {
    $word .= $letter;
    }
}
fclose($handle);
print_r($results);
?>

Note: This assumes the file is in the format <word><space><word><space><word>.... etc.

edwinhermann 57 Junior Poster

Here I'm assuming you will be executing the code as the user logs in. So you can do this:

$random_hour = randbetween(0,23);
$current_hour = date("G",time());
if ($current_hour == $random_hour) {
  // something great happens
  }

If you're trying to implement it on a weekly cycle (i.e. choosing a random hour on a random day) then use this code when the user logs in:

$random_hour = randbetween(0,23);
$random_day = randbetween(1,7);
$current_hour = date("G",time());
$current_day = date("N",time());
if ( ($current_hour == $random_hour) && ($current_day == $random_day) ) {
  // something great happens
  }
edwinhermann 57 Junior Poster

One way is to have a transparent DIV that takes up the whole screen with a high z-index value, but still lower than the sign-in DIV. On that DIV you'd have something like this:

<div onClick="cancelSignIn()">

And the corresponding Javascript:

function cancelSignIn() {
document.getElementById("signin").name=0;
document.getElementById("twitter").style.display='none';
}

A full-page DIV an be achieved by putting it after the <body> tag and applying the following CSS (assuming the DIV's id is "canceltwitter":

div#canceltwitter {
position: absolute;
margin: 0px;
padding: 0px;
border: 0px;
width: 100%;
height: 100%;
z-index: 50;
display: none;
}

You'd need to also set the z-index of the Twitter div to something greater than 50, and use javascript to set the "display" property of the canceltwitter div to block at the same time as displaying the twitter div. (Also putting the canceltwitter div's display property back to none as part of the cancelSignIn() function).

edwinhermann 57 Junior Poster

Just elaborating on twiss's post:

<script type="text/javascript">
function doSomething(elem) {
alert ('The ID of the element which triggered this is: ' + elem.id;
}
</script>
<div id="blah" onClick="doSomething(this)">Blah blah blah</div>
edwinhermann 57 Junior Poster

You are welcome. Please don't forget to mark this thread "Solved" when ready.

edwinhermann 57 Junior Poster

Yes, you can for the name attribute but no not for the id attribute.
But in any event, the name attribute is never used because the form is never submitted; from what I can tell you are simply using input boxes to display information. The only reason to keep the name attribute is to produce HTML that is W3C compliant.

edwinhermann 57 Junior Poster

You cannot have multiple tags with the same id. Your code will output multiple instances of <input id="rate"> and <input id="qty">.

You should serialise them, like this:

<?php
	include("config.php");
?>
<script type=text/javascript>
function multiply(id){
var a;
var b;
var c;
a = document.getElementById("rate" + id).value;
b = document.getElementById("qty" + id).value;
document.getElementById("amt" + id).value = a * b;
}
</script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>

</head>

<body>
<form action="" method="get" name="test">
<table width="800" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td align="center">S.No</td>
    <td align="center">Item Name</td>
    <td align="center">Item Code</td>
    <td height="30" align="center">Rate</td>
    <td align="center">QTY</td>
    <td align="center">Amount</td>
    </tr>
  <tr>
  <?php $desr="select * from site_rate where category_code='EWS001' AND sitename='Amber' order by item_code";
		//echo $desr;
	  	$r=mysql_query($desr,$conn);
	  	$i=1;
		while($m=mysql_fetch_array($r))
		{
			?>
    <td><?php echo $i; ?></td>
    <td><textarea name="cat_item" cols="25" rows="2"><?php echo $m['category_item'];?></textarea></td>
    <td><?php echo $m['item_code'];?></td>
    <td><input name="rate<?php echo $i; ?>" type="text" id="rate<?php echo $i; ?>"/></td>
    <td><input name="qty<?php echo $i; ?>" type="text" id="qty<?php echo $i; ?>" onchange="multiply(<?php echo $i; ?>)"/></td>
    <td><input name="amt<?php echo $i; ?>" type="text" id="amt<?php echo $i; ?>" /></td>
    </tr><?php $i++; } ?>
</table>

</form>

</body>
</html>
edwinhermann 57 Junior Poster

Thanks!

edwinhermann, I get this error with your code:
"Fatal error: Class 'DateInterval' not found "

You're probably on an older version of PHP. You'll need 5.3+ for my code.

You may want to try other code offered by other people, though they use "date()" which is best to avoid, so when you upgrade to PHP5.3 you may want to transition your code back to something like what I posted, using the DateTime andDateInterval classes.

edwinhermann 57 Junior Poster

This code does what you've asked, and starts looking from "tomorrow".

<?php
$dt = new DateTime("tomorrow",new DateTimeZone("Pacific/Auckland"));
$di = new DateInterval("P1D");
while ( ($dt -> format("l") != 'Tuesday') && ($dt -> format("l") != 'Saturday') ) {
  $dt -> add($di);
  }
echo 'Next sale: '.$dt->format("l, j F Y");
?>

Just replace the timezone with that of your locale, and of course you can change the format of the output as well.

edwinhermann 57 Junior Poster

Here's how you should be using the Date/Time features in PHP to achieve the same thing:

<?php
$tz = new DateTimeZone('Europe/Paris');
$time = new DateTime("@1303889758",$tz);
$time -> setTimeZone($tz);
$convert = $time -> format("G:i:s d. n. Y. ");
//convert $time to our date: output is 9:35:58 27. 4. 2011. 
echo $convert."<br>";
$con2 = $time -> format("U");
//convert converted time to unix: doesn't work
echo $con2;
?>
edwinhermann 57 Junior Poster

The PHP code should not display to the browser. Your query as to why the XHTML validator is failing your code is not really a PHP question but more an HTML question.

I suggest you post the entire HTML code (copy/pasted from the browser View Source). Some people here may be able to help you work out why the XHTML validator doesn't like your code, but a better forum would be the HTML and CSS one here: http://www.daniweb.com/forums/forum143.html

edwinhermann 57 Junior Poster

That code looks good. Verify in your "View Source" (in the browser) that it comes out as:

<span style="font-size: 80%;"></span></li>
edwinhermann 57 Junior Poster

ive tried all ways of putting this part of the code

.'<strong>$session->username</strong> <span style='font-size: 80%;'></span></li>'
."<strong>$session->username</strong> <span style=\"font-size: 80%;\"></span></li>"
.'<strong>$session->username</strong> <span style="font-size: 80%;"></span></li>'

none of these work the middle one actually throws up 5 more validator errors. Am i using the wrong doctype due to the page having php in.

Can you show us the code which includes that line? THe original code you posted does not contain the <span style> code.

edwinhermann 57 Junior Poster

strong>$session->username</strong> <span style='font-size: 80%;'></span></li>'

The bit that's wrong is the use of single quotes instead of double quotes in HTML.

The "span" tags should read:

<span style="font-size: 80%;"></span>
edwinhermann 57 Junior Poster
<?php
function find_value($input) {
// $input is the word being supplied by the user
$handle = @fopen("/users/edwin/list.txt", "r");
if ($handle) {
  while (!feof($handle)) {
    $entry_array = explode(":",fgets($handle));
    if ($entry_array[0] == $input) {
      return $entry_array[1];
      }
    }
  fclose($handle);
  }
return NULL;
}
?>
edwinhermann 57 Junior Poster

Thank you. I have tried it and it is still only printing the default. The database entry for $perm is Low.

I think it must be to do with $perm not being set properly, because before I posted my solution I tested it first by adding $perm = "Intermediate"; at the beginning.

(By the way, every time I see the variable $perm I think it says "sperm" :-))

edwinhermann 57 Junior Poster
$low = "Low";
$int = "Intermediate"; 
$high = "High "; 

switch($perm) {
     case $low: echo "Low perm <br>"; break;
     case $int: echo "Intermediate perm <br>"; break;
     case $high: echo "High perm <br>"; break;
     default: echo "No information has been provided. ";
}
edwinhermann 57 Junior Poster
$result = substr($string,0,5);
edwinhermann 57 Junior Poster

He must have copy and pasted wrong. It works...

Err - yes sorry copy/paste error :) I only pasted some of the code (it was 2 am when I did this!) As you said, it does indeed work - I just tried it again just to check.

edwinhermann 57 Junior Poster

How about this for a one-liner:

echo preg_replace_callback('/<a ([^>]+)>([^<]*)<\/a>/m',create_function('$matches','return str_replace(" ","_",$matches[0]);'),$string);

BEFORE:

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed in ante nec nisl vulputate faucibus at quis <a href="path/to/page" class="pageLink">felis</a>. Aliquam vel dui orci. Integer eget eros sed lorem vestibulum aliquet. Aliquam tortor lorem, semper et rutrum a, hendrerit non tellus. Donec <a href="path/to/page" class="pageLink">sodales nunc</a> sed justo viverra luctus. Proin magna lectus, posuere sed laoreet dapibus, mattis at odio. Fusce sed ultricies augue. Curabitur id eros eu turpis imperdiet vestibulum. Nam <a href="path/to/page" class="pageLink">vitae ante dolor</a>, et placerat elit. Suspendisse nec dictum lectus. Morbi nisi nunc, porta nec tempor non, mollis sed justo. Sed pulvinar commodo consectetur.

AFTER:

<a_href="path/to/page"_class="pageLink">felis</a>. Aliquam vel dui orci. Integer eget eros sed lorem vestibulum aliquet. Aliquam tortor lorem, semper et rutrum a, hendrerit non tellus. Donec <a_href="path/to/page"_class="pageLink">sodales_nunc</a> sed justo viverra luctus. Proin magna lectus, posuere sed laoreet dapibus, mattis at odio. Fusce sed ultricies augue. Curabitur id eros eu turpis imperdiet vestibulum. Nam <a_href="path/to/page"_class="pageLink">vitae_ante_dolor</a>, et placerat elit. Suspendisse nec dictum lectus. Morbi nisi nunc, porta nec tempor non, mollis sed justo. Sed pulvinar commodo consectetur.

colweb commented: Perfect example of a reg expression in action. +3
Venom Rush commented: Brilliant! Thanks for the help ;) +3
edwinhermann 57 Junior Poster

is there a way to group all of the OR's together so that the statement is true if any one of the OR statements are true.

You can use brackets to group things together.

For example:

WHERE (a = b OR c = d OR d = e) AND (f = g)

or

WHERE (a = b AND c = d) OR (e = f)

These are just a couple of random examples do illustrate the point. By using brackets, everything inside brackets is evaluated first.

THe first example requires either a to be equal to b, or c to be equal to d, or e to be equal to e, and as well as at least one of those being true, f must equal g.

The second example requires that a is equal to be and b is equal to c, or, if not the case, then e must be equal to f.

edwinhermann 57 Junior Poster

The only way I can think is like this:

$sql = "SELECT * FROM something WHERE id LIKE \"%,".$test.",%\" OR id LIKE \"".$test.",%\" OR id LIKE \"%,".$test."\"";
edwinhermann 57 Junior Poster

Great, so that confirms the array structure of $players.

So in an earlier post I suggested the following:

Change the five SQL lines to this:

mysql_query("DELETE FROM buddies WHERE characterid = ".$players['id']);
mysql_query("DELETE FROM inventoryitems WHERE characterid = ".$players['id']);
mysql_query("DELETE FROM skills WHERE characterid = ".$players['id']);
mysql_query("DELETE FROM keymap WHERE characterid = ".$players['id']);
mysql_query("DELETE FROM characters WHERE characterid = ".$players['id']);

Did this work for you? If not, were error messages generated?

edwinhermann 57 Junior Poster

Did you try the code I posted (just before i-hate-blue)? If so, what were the results?
Also i-hate-blue has asked a question for which you haven't provided an answer yet.

edwinhermann 57 Junior Poster

What is stored in that array is ids and what i need to do is go into the table "buddies" and go to the row with that id and delete the entire row

You state you're getting errors. What exactly are the error messages?

I can take a guess at what you're trying to achieve:
Change the five SQL lines to this:

mysql_query("DELETE FROM buddies WHERE characterid = ".$players['id']);
mysql_query("DELETE FROM inventoryitems WHERE characterid = ".$players['id']);
mysql_query("DELETE FROM skills WHERE characterid = ".$players['id']);
mysql_query("DELETE FROM keymap WHERE characterid = ".$players['id']);
mysql_query("DELETE FROM characters WHERE characterid = ".$players['id']);

I'll explain what this does:

Line 21 (in your original code listing) produces an array, with the indexes of the array being the names of the columns in your database. This array is stored in the variable $players.

Based on what you have in Line 18, the array with the key 'id' will be the ID of the player to delete.

Therefore, $players is what represents the ID of the player whose data is to be deleted.

The only thing I'm dubious about is your logic for determining which players should be purged (i.e. the WHERE clause in line 18). I don't know enough about your data to be able to say whether or not your logic is correct, but to check whether it's selecting the right players you can always insert a

print_r($players);

line after the while statement. That will show you a print out of …

edwinhermann 57 Junior Poster

The code should take the IDs and delete them from the tables but it isn't we are getting errors. Anyone see anything wrong?

In your code, $players is an array. You can't specify an array in your SQL string. So you need to reference the correct array element, such as:

mysql_query("DELETE FROM buddies WHERE characterid = $players['characterid']");

Also I noticed that line 25 has $result (which should also be $players).

edwinhermann 57 Junior Poster

You have to replace $title with htmlspecialchars($title) when you output.

i.e.:

$more_button='  <input type="button" id="button_help1"  value="Summary" onClick="window.location=\'some_infos_research_en.php?title='.htmlspecialchars($title).'\'">
				<input type="button" id="button_help1"  value="Full description" onClick="window.location=\'upload/publications/en/'.$file.'\'">';
edwinhermann 57 Junior Poster

Hi,

my problem is in regular expression. I need to catch from html code hyperlink tag's href atribute content if this hyperlink contains search condition.

Here's what you want:

$a = "nail"; //search ctriteria between <a></a>
$s =<<<EOF
<a class="level2" onmouseout="this.style.background = '';" onmouseover="this.style.background ='#2c7cf4';" href="index.php?item&amp;module=1&amp;category=11" style="">  kaut kas cits </a>
<img> </img>
<br>
<a class="level2" onmouseout="this.style.background = '';" onmouseover="this.style.background ='#2c7cf4';" href="index.php?item&amp;module=1&amp;category=13" style="">  nails </a>
<a class="level2" onmouseout="this.style.background = '';" onmouseover="this.style.background ='#2c7cf4';" href="index.php?item&amp;module=1&amp;category=15" style="">  kaut kas cits2 </a>
EOF;
//this is how far i figured it out
$regexp = "/<a[^>]*href=\\\"([^\\\"]*)\\\"[^>]*>[^<]*".$a."[^<]*<\\/a>/miU";
//finding all hyperlinks
preg_match_all($regexp, $s, $matches);
// result must be 'index.php?item&amp;module=1&amp;category=13'
print_r($matches);

OUTPUT:

Array
(
    [0] => Array
        (
            [0] => <a class="level2" onmouseout="this.style.background = '';" onmouseover="this.style.background ='#2c7cf4';" href="index.php?item&amp;module=1&amp;category=13" style="">  nails </a>
        )

    [1] => Array
        (
            [0] => index.php?item&amp;module=1&amp;category=13
        )

)

You can then just read off the match(es) from $matches[1].

So, in other words, $matches[1][0] is your first match, $matches[1][1] is your second match (if it exists), $matches[1][2] is your third match (if it exists), and so on.

edwinhermann 57 Junior Poster

Thanks! This has been informative to say the least and I apologize about the lack of details.

I DO know the names of all the variables, it's the values and the combination that I won't know.

The form is an order processing script, where the user selects one of the known products, selects if it's going to be Net30 or Credit Card, then submits information depending on Net30 or CC chosen as the payment method.

In that case you just build the logic by checking whether certain information has been submitted, e.g.

if (isset($_POST["FirstName"))

or whether it's empty:

if ($_POST["FirstName"] == "")

and other such logic.

Since I know the variables, I usually use:

<?php
$FirstName = $_POST['FirstName'];
$LastName = $_POST['LastName'];
// rest of post items...

And so on. The problem that I have with this is that I'm declaring all of the variables one-by-one and I feel that it's being far more tedious than it should be. I also feel that calling "$_POST" everytime I need it is excessive, but I may be incorrect on this one.

There are two approaches:

1. You can turn on Register Globals (see http://php.net/manual/en/security.globals.php) but I advise against it because of its security implications, and it's also just not a very clean method. Register Globals allows you to reference $_POST["abc"] as just $abc. You can probably guess the dangers of this. Also worth noting is that Register Globals is deprecated as of version 5.3.0 and removed in PHP 6.0.0, so even …

edwinhermann 57 Junior Poster

Your could should work but I don't see the link between processing the form variables at the beginning and the mailing code.

You might need to provide more information as to what you are wanting to do. The nature of your logic will determine the logic required in your code.

Just to clarify: If you know what the names of the POST variables will be you don't need the foreach loop. But (if I've understood you correctly) your form is dynamic and you don't know what the names of the variables will be, in which case the best thing to do is to use a foreach() loop.

If you DO know all the possible variable names, just that some might not be present, you can do it differently, like this:

$use_name = "";
if (isset($_POST["FirstName"])) {
  $use_name = $_POST["FirstName"];
  if (isset($_POST["LastName"])) {
    $use_name .= " ".$_POST["LastName"];
    }
  }
elseif (isset($_POST["Title"]) || isset($_POST["LastName"])) {
  $use_name = $_POST["Title"]." ".$_POST["LastName"];
  }
else {
  $use_name = "Customer";
  }

and later in your code when you send the email:

$email_message = "Dear ".$use_uame.",\nThank you for signing up to our newsletter....";
// more code to determine the rest of $email_message
if (!mail($email_to,$email_subject,$email_message,$email_headers)) {
  echo "An error occurred!";
  }
else {
  echo "We have sent you a welcome email.";
  }

The two pieces of code determine how to write the greeting line of an email. It will produce:
Dear John Smith (if both names are available)
Dear John (if only the first …

edwinhermann 57 Junior Poster

That would be the best way. You'd do something like this:

foreach($_POST as $name => $value) {
  switch ($name) {
    case "colour":
    // logic here to handle the colour
    break;
    case "size":
    // logic here to handle the type
    break;
    case "type":
    // logic here to handle the type
    break;
  }
}

foreach is the best way of stepping through an array (such as $_POST) to find all the values and keys

edwinhermann 57 Junior Poster

The site you showed uses images. Here's one of the rounded corner images on that site:
http://www.mtibwasugar.com/images/modtbo_t.gif

Rounded corners (other than by images) is something that is part of CSS3. Check out http://www.w3.org/TR/css3-background/

edwinhermann 57 Junior Poster

hi, i've got a problem,
hmm...there are three groups (A,B, and C) and their IP address are:
A ==> 10.204.xxx.xxx
B ==> 10.205.xxx.xxx
C ==> 10.206.xxx.xxx

how to read an IP Address, but only for 2 octet, (10.204, 10.205, 10.206)?
I want to put them on index.php, so:
if user IP come from 10.204.xxx.xxx, it will directing to: www.portalA.com,
10.205.xxx.xxx www.portalB.com

The following will work so long as there's no proxy in the way. If there is, you'll need to first check whether $_SERVER["X_FORWARDED_FOR"] exists, and if so, assign $ip that value, otherwise assign S_SERVER["REMOTE_ADDR"].

Not all proxies forward on the original IP address, in which case it will be impossible to tell the real IP address.

However, if you're on a LAN or there's no proxy, the following will work:

<?php

$ip = $_SERVER["SERVER_ADDR"];
$twoOctets = substr($ip,0,strpos($ip,".",strpos($ip,".")+1));
switch ($twoOctets) {
  case "10.204":
  header("Location: http://www.portalA.com");
  exit;
  break;
  case "10.205":
  header("Location: http://www.portalB.com");
  exit;
  break;
  case "10.206":
  header("Location: http://www.portalC.com");
  exit;
  default:
  // put code here to cover no match
}

?>
danang commented: solved my problem +0
edwinhermann 57 Junior Poster

Just to add to Chris's reply, there's also PHPshadow (http://www.phpshadow.com) if you're deploying on Linux/BSD/Mac OS servers.

edwinhermann 57 Junior Poster

That's a short way of assigning a variable a value that spans multiple lines and includes special characters that would normally interfere with the PHP language.

It's called NOWDOC (see http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.nowdoc)

Consider this example:

$text = <<<SPECIAL_LABEL
The quick brown
fox jumps over
the lazy dog.
SPECIAL_LABEL

This assigns the sentence (including line breaks) to the variable $text.

The syntax is:

$variable = <<<LABEL
contents go here....
LABEL

So, in your example, the value stored in $post is:

<form method="post" action="">
</form>

edwinhermann 57 Junior Poster

You forgot a } before "catch". Try:

function connect($db_host,$db_database,$db_user,$db_pass) {
global $db_connection;
try {
  $db_connection = mysql_connect($DB_HOST,$db_user,$db_pass, true);
  if(!$db_connection) {
    throw new Exception('MYQSL Connection Database Error: ' . mysql_error());
    }
  else {
    $connection = true;
    }
  }
catch (Exception $e) {
  echo $e->GetMessage();
  }
}
edwinhermann 57 Junior Poster

Hello, I'm working on a recursive loop subcategory system. The code below is ALMOST where I need it. The last thing I'd like to do is indent each subcategory based on levels deep, rather than just separate by commas. I can't seem to wrap my head around it. Any suggestions?

Not sure if you're wanting to return HTML code or plaintext.

Try this for plaintext:

function showlist($parent, &$catlistids="",$depth = 0) {
  $result = mysql_query("SELECT component_part_id, component_part_quantity_used FROM builds WHERE build_part_id='$parent'");
  while ($line = mysql_fetch_array($result)) {
    for ($i=0;$i<$depth;$i++) {
      $catlistids .= "  ";
    }
    $catlistids .= get_part($line["component_part_id"]) . ' ' .  $line["component_part_quantity_used"]."\n";
    showlist($line["component_part_id"], &$catlistids,$depth+1);
  }
return $catlistids;
}

Or for HTML:

function showlist($parent, &$catlistids="",$depth = 0) {
  $result = mysql_query("SELECT component_part_id, component_part_quantity_used FROM builds WHERE build_part_id='$parent'");
  while ($line = mysql_fetch_array($result)) {
    for ($i=0;$i<$depth;$i++) {
      $catlistids .= "&nbsp;&nbsp;";
    }
    $catlistids .= get_part($line["component_part_id"]) . ' ' .  $line["component_part_quantity_used"]."<br>";
    showlist($line["component_part_id"], &$catlistids,$depth+1);
  }
return $catlistids;
}
edwinhermann 57 Junior Poster

foreach ($rows as $rows) is invalid - you can't use the same variable name twice.

Try this:

$result = $database->query('SELECT * FROM testtable ORDER BY timestp DESC;');
		
$rows = array(array());

while ( $tmp = $db->fetch_assoc( $result ) )
  {
  $rows[] = $tmp;
  }
		
foreach ( $rows as $row)
  {
  echo '<br />';
  echo $row['id']." --> ".$row['timestp']." --- ".$row['val'];
  }

reset($rows);
edwinhermann 57 Junior Poster

It's difficult to know your setup, so I'm only guessing, but one possibility is that your server doesn't accept short tags.

I notice that in process.php, after <body> you open your PHP code with <?

Try using <?php instead.

You need to get it such that if someone browses to http://yoursite/process.php, the code does NOT show up. If it's not fixed by my suggestion, I suspect it's a server setting somewhere.