need help in code of php

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
forgun
Forum Commoner
Posts: 61
Joined: Wed Jan 29, 2003 6:05 am
Contact:

need help in code of php

Post by forgun »

the error

Code: Select all

Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/virtual/site13/fst/var/www/html/new/gets.php on line 28

Fatal error: Call to undefined function: build_table() in /home/virtual/site13/fst/var/www/html/new/gets.php on line 18
the code is

Code: Select all

<?php
define('ha' , true);
$root = './';
include ($root .'comm.inc');
function sets($menu) {
	switch ($menu) {
		case "main":
		include($root . 'includes/dbs.php' );
		error_reporting  ( E_ERROR | E_WARNING | E_NOTCIE );
		$lk = mysql_connect($serv,$user,$pass) or die ("unable to do connection \n" .mysql_error());
		mysql_select_db($dbname[0],$lk);
		$qur = "select * from linkssets where loc = 'main' order by id desc";
		$res = mysql_query($qur) or die ("error in the select " .mysql_error());
		while ($row = mysql_fetch_assoc($res)) {
			$out = array ( $row['desc'] => $row['name'] ); 
			$id = array ( $row['id'] );
		}
		build_table($out, $id);
		return $msg;
		close_db($lk,$res);
	}
}
function build_table( $data , $id) {
	foreach ($data as $desc => $menu) {
		foreach ($id as $kay => $val) {
			$msg = "<tr><td width='47%'  style='border-style: double; border-width: 3' height='18'>";
			$msg .= "<A href='index.php?id=" .$id[$kay] . "'><b>" .$menu  ."</b></a></td>";
			$msg .= "<td width='53%' style='border-style: double; border-width: 3' height='18'>" .$desc "</td></tr>";
			return $msg;
		}
	}
}			 
function close_db($lk,$re) {
	mysql_free_result($re);
	mysql_close($lk);
}

?>
the line is

Code: Select all

$msg .= "&lt;td width='53%' style='border-style: double; border-width: 3' height='18'&gt;" .$desc "&lt;/td&gt;&lt;/tr&gt;"; # line 28

Code: Select all

build_table($out, $id); #line 18
User avatar
BDKR
DevNet Resident
Posts: 1207
Joined: Sat Jun 08, 2002 1:24 pm
Location: Florida
Contact:

Post by BDKR »

Line 28 is the line allright. It's a concatenation error.

Cheers,
BDKR
User avatar
forgun
Forum Commoner
Posts: 61
Joined: Wed Jan 29, 2003 6:05 am
Contact:

Post by forgun »

so how i can make at work??
net7
Forum Commoner
Posts: 31
Joined: Wed Mar 12, 2003 1:27 pm

Post by net7 »

The fix for that line is this

Code: Select all

$msg .= "<td width='53%' style='border-style: double; border-width: 3' height='18'>" .$desc. "</td></tr>";

You just needed to add the period after the "$desc" to add the "</td></tr>". See ?
User avatar
forgun
Forum Commoner
Posts: 61
Joined: Wed Jan 29, 2003 6:05 am
Contact:

Post by forgun »

lol 10x
like all ways i dont put a point
Post Reply