12 Replies - 516 Views - Last Post: 20 July 2009 - 08:13 AM Rate Topic: -----

#1 ghqwerty  Icon User is offline

  • if($spareTime > 0){ $this->writeCode(); }
  • member icon

Reputation: 40
  • View blog
  • Posts: 876
  • Joined: 08-August 08

message reply

Posted 17 July 2009 - 11:56 AM

why is this not working, well as it should

Quote

billybobjr wrote :
matty wrote :
billybobjr wrote :
lyk this way or antoher way


-------------------------

billybobjr wrote :


matty wrote :


should have fixed it XD


-------------------------

billybobjr wrote :


test


-------------------------


should be

Quote

billybobjr wrote :

lyk this way or antoher way

-------------------------

matty wrote :


should have fixed it XD

-------------------------

billybobjr wrote :

test

-------------------------



this is the code.

			$subject = "RE: ".$dbdata['subject'];
			$str = $dbdata['message'];
			$chars = preg_split('/-------------------------/', $str, -1, PREG_SPLIT_OFFSET_CAPTURE);	
			$message = "";			
			$count = count($chars);
			for($x=0;$x<$count;$x++){
				$array = $chars[$x];
				$message .= $dbdata['sender']." wrote : \n".$array[0]."\n -------------------------\n\n";
			}
		}



anyone see the problem ?

Is This A Good Question/Topic? 0
  • +

Replies To: message reply

#2 ghqwerty  Icon User is offline

  • if($spareTime > 0){ $this->writeCode(); }
  • member icon

Reputation: 40
  • View blog
  • Posts: 876
  • Joined: 08-August 08

Re: message reply

Posted 18 July 2009 - 07:29 AM

bump
Was This Post Helpful? 0
  • +
  • -

#3 Decypher  Icon User is offline

  • D.I.C Regular

Reputation: 2
  • View blog
  • Posts: 400
  • Joined: 28-June 08

Re: message reply

Posted 18 July 2009 - 10:24 AM

shouldn't:
 $message .= $dbdata['sender']."



be:

 $message = .$dbdata['sender']."


Was This Post Helpful? 0
  • +
  • -

#4 CTphpnwb  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2485
  • View blog
  • Posts: 8,526
  • Joined: 08-August 08

Re: message reply

Posted 18 July 2009 - 10:28 AM

I think you're not showing us the pertinent code. What does $dbdata look like? If it's from mysql, there will be duplicate entries as you have associative and numerically indexed values in the array.
Was This Post Helpful? 0
  • +
  • -

#5 ghqwerty  Icon User is offline

  • if($spareTime > 0){ $this->writeCode(); }
  • member icon

Reputation: 40
  • View blog
  • Posts: 876
  • Joined: 08-August 08

Re: message reply

Posted 18 July 2009 - 11:07 AM

		function showSendMessage(){	
		$name = $_GET['name'];
		$reply = $_GET['reply'];
		$query = mysql_query("select * from messages where messageid = '$reply'", $this->dblink);
		$dbdata = mysql_fetch_array($query);
		if($dbdata['receiverid'] == $this->row['id']){
			$subject = "RE: ".$dbdata['subject'];
			$str = $dbdata['message'];
			$chars = preg_split('/-------------------------/', $str, -1, PREG_SPLIT_OFFSET_CAPTURE);	
			$message = "";			
			$count = count($chars);
			for($x=0;$x<$count;$x++){
				$array = $chars[$x];
				$message .= $dbdata['sender']." wrote : \n".$array[0]."\n -------------------------\n\n";
			}
		}	
		echo "<form method='post' action='home.php?page=sendmail'><table border='1'>
			<tr>
				<td>
					To:
				</td>
				<td>					
					<input type='text' name='to'"; if(isset($name)){ echo "value='".$name."'";} echo " >
				</td>
			</tr>
			<tr>
				<td>
					Subject
				</td>
				<td>											
					<input type='text' name='subject' ";if(isset($subject)){ echo "value='".$subject."'";} echo " >							
				</td>
			</tr>
			<tr>
				<td colspan='2'>
					<center>Message:</center>
				</td>
			</tr>
			<tr>
				<td colspan='2'>
					<textarea name='content' cols='30' rows='7'>";if(isset($message)){ echo $message;} echo "</textarea>
				</td>
			</tr>
			<tr>
				<td colspan='2'>
					<p align='right'>
						<input type='submit' name='sendMessage' value='Send'>
					</p>
				</td>
			</tr>
		</table>
		";
	}





there ya go matey. so how would i fix it to make it work ?
Was This Post Helpful? 0
  • +
  • -

#6 CTphpnwb  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2485
  • View blog
  • Posts: 8,526
  • Joined: 08-August 08

Re: message reply

Posted 18 July 2009 - 12:10 PM

What is this?
$this->row['id']
Was This Post Helpful? 0
  • +
  • -

#7 ghqwerty  Icon User is offline

  • if($spareTime > 0){ $this->writeCode(); }
  • member icon

Reputation: 40
  • View blog
  • Posts: 876
  • Joined: 08-August 08

Re: message reply

Posted 18 July 2009 - 12:15 PM

it is the users id number
Was This Post Helpful? 0
  • +
  • -

#8 CTphpnwb  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2485
  • View blog
  • Posts: 8,526
  • Joined: 08-August 08

Re: message reply

Posted 18 July 2009 - 03:46 PM

Please post a sample of
var_dump($dbdata);
Was This Post Helpful? 0
  • +
  • -

#9 ghqwerty  Icon User is offline

  • if($spareTime > 0){ $this->writeCode(); }
  • member icon

Reputation: 40
  • View blog
  • Posts: 876
  • Joined: 08-August 08

Re: message reply

Posted 19 July 2009 - 09:29 AM

array(18) { [0]=> string(3) "134" ["messageid"]=> string(3) "134" [1]=> string(2) "87" ["senderid"]=> string(2) "87" [2]=> string(10) "billybobjr" ["sender"]=> string(10) "billybobjr" [3]=> string(1) "1" ["receiverid"]=> string(1) "1" [4]=> string(5) "matty" ["receiver"]=> string(5) "matty" [5]=> string(10) "no subject" ["subject"]=> string(10) "no subject" [6]=> string(77) "dude im goin in a bout 10 mins so u no well im gonna go now ny way so cya bud" ["message"]=> string(77) "dude im goin in a bout 10 mins so u no well im gonna go now ny way so cya bud" [7]=> string(1) "1" ["message_read"]=> string(1) "1" [8]=> string(19) "2009-07-17 05:04:49" ["sent"]=> string(19) "2009-07-17 05:04:49" }



--------------------------

why does it say string ? i use mostly ints for like id and status etc?

This post has been edited by ghqwerty: 19 July 2009 - 09:37 AM

Was This Post Helpful? 0
  • +
  • -

#10 CTphpnwb  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2485
  • View blog
  • Posts: 8,526
  • Joined: 08-August 08

Re: message reply

Posted 19 July 2009 - 11:04 AM

This works for me:
<?php
	function showSendMessage(){ 	
	$name = "JOE";
	$reply = "MATT";
	$simdata[0] = array(0=> "134", "messageid"=> "133",1=> "87", "senderid"=> "87", 2=> "Matt", "sender"=> "Matt", 3=> "2", "receiverid"=> "2", 4=> "matty", "receiver"=> "matty", 5=> "no subject", "subject"=> "no subject", 6=> "dude im goin in a bout 10 mins so u no well im gonna go now ny way so cya bud", "message"=> "dude im goin in a bout 10 mins so u no well im gonna go now ny way so cya bud", 7=> "1", "message_read"=> "1", 8=> "2009-07-17 05:04:49", "sent"=> "2009-07-17 05:04:49");
	$simdata[1] = array(0=> "134", "messageid"=> "134",1=> "2", "senderid"=> "2", 2=> "billybobjr", "sender"=> "billybobjr", 3=> "1", "receiverid"=> "1", 4=> "matty", "receiver"=> "matty", 5=> "no subject", "subject"=> "New Sub", 6=> "Ok, im goin in a bout 30 mins so u no well im gonna go now ny way so cya bud", "message"=> "Ok, im goin in a bout 30 mins so u no well im gonna go now ny way so cya bud", 7=> "1", "message_read"=> "1", 8=> "2009-07-17 05:04:49", "sent"=> "2009-07-17 05:04:49");
	$message = "";
	foreach($simdata as $dbdata)
	{
	if($dbdata['receiverid'] != "33"){
		$subject = "RE: ".$dbdata['subject'];
		$str = $dbdata['message'];
		$chars = preg_split('/-------------------------/', $str, -1, PREG_SPLIT_OFFSET_CAPTURE); 
		$count = count($chars);
		for($x=0;$x<$count;$x++){
		$array = $chars[$x];
		$message .= $dbdata['sender']." wrote : \n".$array[0]."\n -------------------------\n\n";
		}
	} 
	}
	echo "<form method='post' action='home.php?page=sendmail'><table border='1'>
		<tr>
		<td>
			To:
		</td>
		<td> 			
			<input type='text' name='to'"; if(isset($name)){ echo "value='".$name."'";} echo " >
		</td>
		</tr>
		<tr>
		<td>
			Subject
		</td>
		<td> 
			<input type='text' name='subject' ";if(isset($subject)){ echo "value='".$subject."'";} echo " > 
		</td>
		</tr>
		<tr>
		<td colspan='2'>
			<center>Message:</center>
		</td>
		</tr>
		<tr>
		<td colspan='2'>
			<textarea name='content' cols='30' rows='7'>";if(isset($message)){ echo $message;} echo "</textarea>
		</td>
		</tr>
		<tr>
		<td colspan='2'>
			<p align='right'>
			<input type='submit' name='sendMessage' value='Send'>
			</p>
		</td>
		</tr>
	</table>
	";
	}
	
showSendMessage();
?>


Was This Post Helpful? 1
  • +
  • -

#11 ghqwerty  Icon User is offline

  • if($spareTime > 0){ $this->writeCode(); }
  • member icon

Reputation: 40
  • View blog
  • Posts: 876
  • Joined: 08-August 08

Re: message reply

Posted 20 July 2009 - 01:10 AM

how would i get sim data???
Was This Post Helpful? 0
  • +
  • -

#12 CTphpnwb  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2485
  • View blog
  • Posts: 8,526
  • Joined: 08-August 08

Re: message reply

Posted 20 July 2009 - 07:23 AM

You don't need it. I don't have your database, so I used simdata to simulate the data that could come from it.
Was This Post Helpful? 0
  • +
  • -

#13 ghqwerty  Icon User is offline

  • if($spareTime > 0){ $this->writeCode(); }
  • member icon

Reputation: 40
  • View blog
  • Posts: 876
  • Joined: 08-August 08

Re: message reply

Posted 20 July 2009 - 08:13 AM

final code working perfectly now, thanks CT for the help you guided me in the right direction. i think i spent hours on php.net looking through all the substr strlen preg_split etc lol


 	function showSendMessage(){	
		$name = $_GET['name'];
		$reply = $_GET['reply'];
		$message = "";
		if($reply != ""){
			$query = mysql_query("select * from messages where messageid = '$reply'", $this->dblink);
			$simdata[] = mysql_fetch_array($query);
				foreach($simdata as $dbdata){
					$subject = "RE: ".$dbdata['subject'];
					$str = $dbdata['message'];
					$chars = preg_split('/-------------------------/', $str, -1, PREG_SPLIT_OFFSET_CAPTURE);
					$count = count($chars);													
					for($x=0;$x<$count-1;$x++){
						$array = $chars[$x];
						$message .= $array[0]."\n -------------------------\n";					
					}
					$array = $chars[$count-1];
					$message .= $dbdata['sender']." Wrote : \n". $array[0]."\n -------------------------\n";
				}
		}
		echo "<form method='post' action='home.php?page=sendmail'><table border='1'>
			<tr>
			<td>
				To:
			</td>
			<td>			
				<input type='text' name='to'"; if($name!= ""){ echo "value='".$name."'";} echo " >
			</td>
			</tr>
			<tr>
			<td>
				Subject
			</td>
			<td>
				<input type='text' name='subject' ";if($subject!= ""){ echo "value='".$subject."'";} echo " >
			</td>
			</tr>
			<tr>
			<td colspan='2'>
				<center>Message:</center>
			</td>
			</tr>
			<tr>
			<td colspan='2'>
				<textarea name='content' cols='50' rows='15'>";if($message != ""){ echo $message;} echo "</textarea>
			</td>
			</tr>
			<tr>
			<td colspan='2'>
				<p align='right'>
				<input type='submit' name='sendMessage' value='Send'>
				</p>
			</td>
			</tr>
		</table>
		";
	}

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1