cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Below is the code and you will need to rename the username and date columns in the comments table to _username and _date

<?php
//Insert mysql connections here

$r=mysql_query('SELECT * FROM `comments`, `messages` WHERE `comments`.`msg_id_fk` = `messages`.`msg_id` ORDER BY `comments`.`com_id`, `messages`.`msg_id`') or die(mysql_error());
$messagedump='';
while ($row = mysql_fetch_assoc($r)) {
if ($messagedump!=$row['message']) {

echo <<< HTML
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td>{$row['username']}</td>
    <td>{$row['message']}</td>
  </tr>
  <tr>
    <td>{$row['date']}</td>
    <td>nbsp;</td>
  </tr>
</table></td>
  </tr>
HTML;
}

echo <<< HTML
  <tr>
    <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td>{$row['_username']}</td>
    <td>{$row['comment']}</td>
  </tr>
  <tr>
    <td>{$row['_date']}</td>
    <td>&nbsp;</td>
  </tr>
</table></td>
  </tr>
</table>
HTML;

}
?>
cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Do you want me to send you my whole code?

it works
but when i try adding it to my code it don't work

Then send a html template of what the result should look like (but with the echoed data) Then I will place in there the php code. Just mark in the template which $row variable goes where.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Are there any errors or could you explain what is happening so I can fix.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Then try the following:

$r=mysql_query('SELECT * FROM `comments`, `messages` WHERE `comments`.`msg_id_fk` = `messages`.`msg_id` ORDER BY `comments`.`com_id`, `messages`.`msg_id`') or die(mysql_error());
$messagedump='';
while ($row = mysql_fetch_assoc($r)) {
if ($messagedump!=$row['message']) {
$messagedump=$row['message'];
echo '<hr>';
echo $row['message'];
}
echo '<br><br>';
echo $row['comment'];
}
cwarn23 387 Occupation: Genius Team Colleague Featured Poster

So this will display all the comments for each message

Yes but when just rereading your first post I found the code should be more like the following:

$r=mysql_query('SELECT * FROM `comments`, `messages` WHERE `comments`.`msg_id_fk` = `messages`.`msg_id` ORDER BY `comments`.`com_id`, `messages`.`msg_id`') or die(mysql_error());
while ($row = mysql_fetch_assoc($r)) {
echo $row['comment'];
echo '<br><br>';
echo $row['message'];
echo '<hr>';
}

I would suggest trying it and see if it works.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

The classic question with no code. I would like to try and debug it but can't see any code to debug. Could you please post your code and your errors so that we at least have a chance of solving this.

Hey Everyone,

I am getting an error with a PHP script made using the Authorize.net AIM (Advanced Integration Method) API for my donation form. I have gone over the code dozens of times and still do not know why it is not working. Everything works except the most important part...it will not process the credit card. I would like to know if anyone would mind looking over my code for a debug? If you are willing to but need to be compensated please give a link to your portfolio. Thank you

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Try the following:

$r=mysql_query('SELECT * FROM `comments`, `messages` WHERE `comments`.`msg_id_fk` = `messages`.`msg_id`') or die(mysql_error());
while ($row = mysql_fetch_assoc($r)) {
echo $row['comment'];
echo '<br><br>';
echo $row['message'];
echo '<hr>';
}

I think that is what you mean but I haven't tested it for bugs.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Where you use $_SESSION[blah]=$_POST you should place that in an if statement like the following.

if (isset($_POST) && !empty($_POST)) {
$_SESSION['blah']=$_POST['blah'];
$_SESSION['asdf']=$_POST['asdf'];
}

This way if $_POST is empty, session will not be assigned an empty value.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Google is your friend.
I would suggest using preg_match_all to retrieve the data then display the data in the proper formatting with loops.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

i have initially tried that but the problem that i am having with that is that is is only storing the current value. it is not storing the other values when the loop runs another time. ie. when i get a result in $row1 in the first loop it is stored in the array however in the next time it loops the array only contain one value and that value will now be the second course

Try to copy and past my code because I used the [] operator which makes a big difference. That is where your problem would have been.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster
<?php


$hostname = "localhost";
$username = "root";
$password = "hayden";
$database = "ecng3020";



$con = mysql_connect("$hostname","$username","$password");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
  mysql_select_db("$database", $con);
  
  $q="SELECT * FROM rules Where type ='course_option'  ";
  if ($result_2=mysql_query($q))
  {
  	echo"nice";
  }
  else
  {
  	echo"shit";
  }
  $first=array();
	while($row = mysql_fetch_assoc($result_2))
	{
			extract($row);
			echo "<p>$parameters</p>";
			$e=explode(",",$parameters);
			print_r($e);
			foreach ($e AS $val) {
			$w="SELECT * FROM student_courses WHERE course_status='pass' AND course_code='".mysql_real_escape_string($val)."' AND id_no=806000169";
			
			if ($result1=mysql_query($w))
			  {
				echo "nice";
			  }
			  else
			  {
				echo "shit";
			  }
			  while($row1 = mysql_fetch_assoc($result1))
			  {
			  	extract($row1);
                $first[]=$course_code;
				echo "<p>$course_status</p>";
			  }
            }
		
	}
    print_r($first);
	
?>
cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Perhaps the following?

<?php


$hostname = "localhost";
$username = "root";
$password = "hayden";
$database = "ecng3020";



$con = mysql_connect("$hostname","$username","$password");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
  mysql_select_db("$database", $con);
  
  $q="SELECT * FROM rules Where type ='course_option'  ";
  if ($result_2=mysql_query($q))
  {
  	echo"nice";
  }
  else
  {
  	echo"shit";
  }
											
	while($row = mysql_fetch_assoc($result_2))
	{
			extract($row);
			echo "<p>$parameters</p>";
			$e=explode(",",$parameters);
			print_r($e);
			foreach ($e AS $val) {
			$w="SELECT * FROM student_courses WHERE course_status='pass' AND course_code='".mysql_real_escape_string($val)."' AND id_no=806000169";
			
			if ($result1=mysql_query($w))
			  {
				echo "nice";
			  }
			  else
			  {
				echo "shit";
			  }
			  while($row1 = mysql_fetch_assoc($result1))
			  {
			  	extract($row1);
				echo "<p>$course_status</p>";
			  }
            }
		
	}
	
?>
cwarn23 387 Occupation: Genius Team Colleague Featured Poster

on line 47 change to

extract($row1);

That will solve your first problem and could you mention the value you would like to store in the array (eg. $course_status).

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Mhh! as I was reading the post the same question came to my mind. Why would it be needed not only in PHP but also in other language like C++? Don't get mad at me cwarn (remember SHA1 cracker?)
That infamous gOtO ;)

The reason I used the goto tag in c++ is because I was too lazy to make an infinit loop. But yes there are methods to use in any language which posses loops. I believe the goto tag was originally used before loops had been invented. But when new/current languages came out with the loop mechanism there was no need to use the goto unless your lazy or unexperienced.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

It means you don't have the latest version of php. The goto element is only available in the latest release (5.3) but I wouldn't recommend it due to incompatibility bugs. Instead try using loops and if statements such as the following:

<?php
if (false) {
echo 'Foo';
}
echo 'Bar';
?>
cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Also on line 10 you need to change to the } type bracket.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

I have completed the script and is as follows:

<?php
session_start();
$dbhost = 'localhost';
$dbname = 'mydatabase';
$dbuser = 'root';
$dbpasswd = '';
$link_id = mysql_connect($dbhost, $dbuser, $dbpasswd);
mysql_select_db($dbname, $link_id);

$fl = "common.php";
$f = file_get_contents($fl);

$sql = mysql_query("SELECT langkey,cy,en FROM pl_terms2 WHERE filename = '$fl'");
$f = str_replace(array("\t",'  ','  ','  '),array(' ',' ',' ',' '),$f);
while($d = mysql_fetch_assoc($sql)){
   $key = $d['langkey'];
   $cy = $d['cy'];
   $en = $d['en'];
   $f=str_replace(' \''.$key.'\' => \''.$en.'\',',"    '".$key.'\''.str_repeat(' ',(40-strlen($key))).'=> \''.$cy.'\',',$f);
}

$f = str_replace("\r\n","\n",$f);
file_put_contents($fl,$f);
?>
diafol commented: To the rescue once again! +5
cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Well could you post as an attachment a sample text file this script may read. Then I may be able to do a better regex for you.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Then it means you have "error=<something>" in the url. Try removing that then the problem should be solved.

Doesn't work.

if (!isset($_GET['error'])) {
 mysql_query($itemsql); 
 $itemid = mysql_insert_id();	
} 
// Nor does this work 
if (!isset($_GET['error'])) {
 mysql_query($itemsql); 	
}
cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Try the following - it will only replace the first instance of that key

$key='THIS_KEY';
$value='New value';
preg_replace("@'$key'.*=>.*\n@Us","'$key' => '$value'\n",$file_input,1);

As for replacing the second instance of the key, how do you plan to identify the second key or in other words separate the first key from the second. It's like having two variables with the same name.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Seems to work very well, although a few niggles with certain key-value lines. Won't mark as solved quite yet, but pretty close.

Could you give examples of the keys that won't work. Perhaps I could fix that for you.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

On what line in your script is your mysql_query('INSERT...'); That is where the problem lies. Around that mysql query you should have the following

if (!isset($_GET['error'])) {
mysql_query('INSERT...');
}
cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Could you post the file with your insert mysql querys because at the moment it is like if I'm blindfolded not being able to see the related code. I suspect you will need to add an if statement around your mysql query.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Try the following

if(isset($adres) || $adres == "")  
{                  		
 header("Location: " . $config_basedir . "/newitem.php?   error=adres"); 
}
cwarn23 387 Occupation: Genius Team Colleague Featured Poster

The following is an example of how to use my example.

$key='THIS_KEY';
$value='New value';
preg_replace("@'$key'.*=>.*\n@Us","'$key' => '$value'\n",$file_input);
cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Do you mean when you input empty strings or strings only containing spaces then it should pass. Then I would suggest using the isset() function instead of the empty() function at problem areas.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Do you mean that if age=0 should pass true well the reason why it currently doesn't is because of a bug or feature in the empty function. The work around is as follows.

if (empty($_POST['age']) || $_POST['age']===0) {
cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Then it would be as follows.

preg_replace("@'THIS_KEY'.*=>.*'My string',@Us","'THIS_KEY' => 'My new value'",$file_input);
cwarn23 387 Occupation: Genius Team Colleague Featured Poster

I would suggest using the following:

str_replace("'THIS_KEY' => 'My string',","'THIS_KEY' => 'My new value'",$file_input);
cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Could you explain more clearly because it is hard to understand what you are asking for. From what I can tell you want to check if all values in $_POST are not empty. If that is correct then you would use the following.

if ((!empty($_POST['hour']) || $_POST['hour']===0) && (!empty($_POST['minute'])  || $_POST['minute']===0)) {

And remember to add the rest of the post variables.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

All answers on a post card...... :-)

Sending a post card your way lol. Below are the details.
There are several libraries that may be used to create pdf files and yes not all examples work due to incompatibility on updated versions since the tutorial/example was written for an older version. To find reliable examples I would suggest going to php.net and check the function references for their pdf library. Then make sure you have that same library installed. Alternatively you may find a pdf extension in pear. Generally the official documentation is the best reference as it is usually the most accurate. Enjoy.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

I'm not very familiar with mysqli that is with the i at the end but I will give you an example that doesn't use mysql.

<?php
$heading=array(0=>'Heading 1',1=>'heading 2');
for ($i=0;$i<count($heading);$i++) {
echo '<div style="background-color:orange;text-align:center">
<p>'.$heading[$i].'</p>
</div>
<div style="border:1px solid black">
<p>Content section</p>
</div>';
}

That should give you something to base your code on.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

I receive for yor code

Warning: mysql_fetch_assoc() expects parameter 1 to be resource, object given

That was because you were meant to add the rest of the code which included a mysql query. $result is assigned to $result=mysql_query('SELECT blah...

cwarn23 387 Occupation: Genius Team Colleague Featured Poster
<?php
$heading=array(0=>'Heading 1',1=>'heading 2');
for ($i=0;$row=mysql_fetch_assoc($result);$i++) {
echo '<div style="background-color:orange;text-align:center">
<p>'.$heading[$i].'</p>
</div>
<div style="border:1px solid black">
<p>Content section</p>
</div>';
}
cwarn23 387 Occupation: Genius Team Colleague Featured Poster

I believe there are some custom scripts/functions that you can be downloaded so perhaps a google search for "php uniord function" might reveal a few functions.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

مرحب

They are non-ascii characters and are unable to convert with the ord function. I would suggest finding a replacement for the ord function as the ascii table ranges from 0 to 255 and those characters are out of that range.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

That function works perfectly. A hex is made of the values 0-9 and A-F. When I test that function it seem to follow those rules and does it perfectly. But are you after a function that converts string to decimal and not string to hex? Because that's a completely different thing.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Do you mean like this?

$result = mysql_query("SELECT Fieldvalue FROM kid_rsform_submission_values WHERE SubmissionId IN (SELECT SubmissionId FROM kid_rsform_submission_values WHERE FieldValue = '850830126317') LIMIT 14");
cwarn23 387 Occupation: Genius Team Colleague Featured Poster

It would be better to place all the data into a database and perhaps you could make a script that will insert it into the database for you. Then to display the content you just select from the database and display the contents from the database.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

The scanned by signature is added by the virus scanner and therefore needs to be disabled by the virus scanner. So if you go into your servers virus scanner configurations you would untick the box for showing the scanned by in the signature. You would also do the same with the virus scanner on your local computer.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

My code was just a brief outline that shows the hard stuff but all you need to do is create the ajax function with the row input and to do the mysql query. I would suggest following an ajax tutorial for that bit so you can get an understanding of how it works.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

This is a brief code...

echo '<table border=1 cellpadding=5 cellspacing=0>';
for ($i=0;$row=mysql_fetch_assoc($sql_result);$i++) {
echo '<tr id="'.$i.'">';
echo '<td>'.$row['column1'].'</td>';
echo '<td>'.$row['column2'].'</td>';
echo '<td><a href=# onclick="javascript:ajaxfunction(\''.$i.'\');">Send</a></td>';
}
echo '</table>';
cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Yes, all you need to do is give each row a unique id (eg number) and use ajax to make the php request.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

The only problem with inserting the <p> tags is that unless there are two blank lines to represent a removed <p> tag then it would be impossible to reverse because how would the computer know where to insert these tags? It is best not to strip them in the first place.

But we need a code that will reverse what has been posted
and then selected from and to the database.

The text area posts carrige returns and line breaks to the database
and spits all that into the text div. The tags you suggest I keep are the ones I want to get rid of they will just appear as <p>paragraph</p>.

I'm looking for output - or update to a text field where html tags are output to a textarea just like

this

not like<br />this

I may be barking up the wrong tree but I've done some solid code on this and appreciate your input and output, He He :^) Thanks to date().

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

May I suggest googling for a tutorial. I myself have written one if you want to read.
http://syntax.cwarn23.net/PHP/Making_a_basic_blog

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Why don't you use strip_tags like the following?

$input='input<br><b>string</b>';
strip_tags($input,'<p><br>');

That will strip every tag except the <p> and <br> tags. I believe that is the solution to your problem...

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Try this.

<?php
 
$a = 0;
 
if($handle = opendir('./images/new_images')) {
  while(false !==  ($file = readdir($handle))) {
    if(trim($file,"\r\n\t/\\")!= '.' && trim($file,"\r\n\t/\\")!= '..') {
    echo $nfile[] = $file;
    }
  }
}
 
foreach($nfile as $key => $value)
  {
  $add .= $value."\n";
  $a = $a + 1;
  }
 
$add1 = "[PICTURES]\n";
 
$INIadd = $add1 . $add;
 
echo $INIadd;
closedir($handle);
 
?>
cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Were any of those three files meant to have the access denied/granted if statement because I noticed you didn't use the if statement on any of those files. I would suggest following the example if statement in my previous post and embed it where necessary and just to make it easier below is the if statement I am talking about.

if ($idsec != $propsec) {
	echo "NOT allowed" . "<br>";
}else {
	echo "Allowed" . "<br>";
}

I will be signing off now but will be back sometime tomorrow as it is getting late where I am. So following the above example is the answer but as I am unfamiliar with your design I'm not sure where exactly to place these if statements.

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

But isn't that what the if statement is for. I mean doesn't the if statement prevent other users seeing things they shouldn't? For example.

<?php
session_start();
echo "i am propsec.php" . "<br>";
$emailsec = $_SESSION['user_email'];
$idsec = $_SESSION['user_id'];
$host="localhost"; // Host name
$username="un"; // Mysql username
$password="pw"; // Mysql password
$db_name="db"; // Database name


// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");

$_GET['id']=mysql_real_escape_string((int) $_GET['id']);
$sql="SELECT owner_id FROM tbl_sellers WHERE id=".$_GET['id'];

//$_SESSION['user_type'] = $user_type;
$result=mysql_query($sql);
$row = mysql_fetch_array($result);

$propsec = $row['owner_id'];
echo $idsec;
echo $propsec;
if ($idsec != $propsec) {
	echo "NOT allowed" . "<br>";
}else {
	echo "Allowed" . "<br>";
}
// If result matched $myusername and $mypassword, table row must be 1 row
//if (!$checkemail = $emailsec) { 
//	echo "You are not authorised to view this record/page.  Very naughty of you";
//}else{
//	exit();

?>

...
the url shows http://URL/edit.php?id=20

the id is taken and that shows the details. say id 20 to 23 are mine, i can change it to 24 and see something thats not mine

cwarn23 387 Occupation: Genius Team Colleague Featured Poster

Your sql string, shouldn't it be modified with a WHERE clause so it only matches one row?

$sql="SELECT owner_id FROM tbl_sellers";