Question : anyone see a reason why mysql would not fire and echo info(maybe a typo my luck)


this is probably a dang typo im missing just my luck
can anyone see a reason why the attached code is not displaying the echoes of id,date,discription,note etc at all

i get
-------------------
id: 2
Record info will go here

all done
-------------------
as return and nothing else

thank you in advance for any code or help you may provide

 
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
<?php
session_start();
//include '../var-dump.php';
echo "id: ".trim($_REQUEST['id'], ",")."<br>\n";
echo "Record info will go here<br>\n";

  /* MySQL connection */
	$gaSql['user']       = "xxxxxxx";
	$gaSql['password']   = "xxxxxxxx";
	$gaSql['db']         = "xxxxxx";
	$gaSql['server']     = "localhost";
	$gaSql['type']       = "mysql";

	$gaSql['link'] =  mysql_pconnect( $gaSql['server'], $gaSql['user'], $gaSql['password']  ) or
		die( 'Could not open connection to server' );

	mysql_select_db( $gaSql['db'], $gaSql['link'] ) or
		die( 'Could not select database '. $gaSql['db'] );

$sql = "SELECT id,date_last_updated, description,note,account_owner FROM contacts_personal_notes WHERE `account_owner`='".$_SESSION['user_name']."' AND `contact_id`='".trim($_REQUEST['id'], ",")."' $where $sort $limit";//
//echo "sql: ".$sql."<br>\n";
$result = mysql_query($sql) or die (mysql_errno($connect) . ": " . mysql_error($connect));

while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
echo "inside while<br>";
echo "id: ".$row['id']."<br>";
echo "date: ".$row['date_last_updated']."<br>";
echo "discrip: ".addslashes($row['description'])."<br>";
echo "note: ".addslashes($row['note'])."<br>";
echo "owner: ".addslashes($row['account_owner'])."<br>";
}

echo "<br>all done";
mysql_close();
?>


sql statement
 
1:
sql: SELECT id,date_last_updated, description,note,account_owner FROM contacts_personal_notes WHERE `account_owner`='Eric Gray' AND `contact_id`='2'

Answer : anyone see a reason why mysql would not fire and echo info(maybe a typo my luck)

If you are getting the id of 2 out of the db then pconnect is not the problem as it is connecting to the db ok (there may be issues later on with a higher number of concurrent connections without tuning apache and mysql though ).

Give the following a go, I changed it to use fetch_row, cleaned the sql select statement a little (didn't know where the $where etc vars came in from though, please check this?), let me know how you go with it,

As per shinug's suggestion I also added the E_ALL error reporting etc into the script which may help a little.

Fingers crossed :)
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
<?php
session_start();
error_reporting(E_ALL);
ini_set("display_errors",1);
//include '../var-dump.php';
echo "id: ".trim($_REQUEST['id'], ",")."<br>\n";
echo "Record info will go here<br>\n";

  /* MySQL connection */
	$gaSql['user']       = "xxxxxxx";
	$gaSql['password']   = "xxxxxxxx";
	$gaSql['db']         = "xxxxxx";
	$gaSql['server']     = "localhost";
	$gaSql['type']       = "mysql";

	$gaSql['link'] =  mysql_pconnect( $gaSql['server'], $gaSql['user'], $gaSql['password']  ) or
		die( 'Could not open connection to server' );

	mysql_select_db( $gaSql['db'], $gaSql['link'] ) or
		die( 'Could not select database '. $gaSql['db'] );

// OLD: $sql = "SELECT id,date_last_updated, description,note,account_owner FROM contacts_personal_notes WHERE `account_owner`='".$_SESSION['user_name']."' AND `contact_id`='".trim($_REQUEST['id'], ",")."' $where $sort $limit";
// note i didn't know where $where etc were coming from, you may need to alter this again to fit your exact requirements
$sql = "SELECT id, date_last_updated, description, note, account_owner FROM contacts_personal_notes WHERE 'account_owner'='".$_SESSION['user_name']."' AND 'contact_id'='".trim($_REQUEST['id'], ",")."' ORDER BY $sort LIMIT $limit";//
$result = mysql_query($sql) or die (mysql_errno($connect) . ": " . mysql_error($connect));
$numRows=mysql_num_rows($result);
if($numRows > 0)
{
	$row=mysql_fetch_row($result); // can be used if only ever expecting one row to be returned
	echo "id: ".$row[0]."<br>";
	echo "date: ".$row[1]."<br>";
	echo "description: ".$row[2]."<br>"; // do 'addslashes' later once this is verified as working
	echo "note: ".$row[3]."<br>";
	echo "owner: ".$row[4]."<br>";
}
else
{
   echo "No results found.<br>";
}
echo "<br>all done";
mysql_close();
?>
Random Solutions  
 
programming4us programming4us