p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

beginning_php thread: code mod :( (displaying data from mysql via php script)


Message #1 by "jon woods" <jonwoods@a...> on Tue, 19 Feb 2002 20:28:50
hi, 



dont know if anyone has looked at the following site b4: 



http://www.phphelp.com/article/43p1.php 





i have altered the code slightly to incorparate different data but when i 

call the functions the following error occurs.. 



to call the functions from the host script i have put 



print make_users_table_start(); 

print browse_users($valid_user); 

print make_users_table_end(); 



?Warning: Undefined variable: content in C:\Inetpub\e3\functions.php on 

line 391? 



also the function browse_users doesnt return any results when using the 

structure used on line 391. however the db def. returns the appro. values 

as if i perform echo $row[0]; the desired result is there.





do you have any suggestions on how to get it working? 



thanx in advance 



jk. 







_____________________________________________ 



function make_users_table_start() 



{ 

?> 

<br> 

<p><font face=?Verdana? size=?1?><strong>You are registered as a contact 

for the following offices...</strong></font></p> 

<br> 

<? 



$content = '<table width=?60%? border=?0? cellspacing=?1? cellpadding=?2? 

bgcolor=?#000000?> 

<tr bgcolor=?#e7e7d6?> 

<td><font face=?Verdana? size=?1?><strong>Office </strong></font> 

</td><td><font face=?Verdana? size=?1?><strong>Address Line 

One</strong></font></td> 

<td><font face=?Verdana? size=?1?><strong>Reception</strong></font></td> 

<td><font face=?Verdana? size=?1?><strong>Country</strong></font></td>'; 

return $content; 

} 





________________________________________________ 





function get_alt_row_color

($i,$light_color=?#ffffff?,$dark_color=?#E6EFFD?) { 

if ($i % 2 == 0) { 

return $light_color; 

} else { 

return $dark_color; 

} 

} 



_______________________________________________ 





function browse_users($cid) 



{ 



if (!($conn = db_connect())) 

return false; 



$result = mysql_query( ?select office.did,office.name,contact.name, 

office.reception, coid from office, 

contact_office, contact 

where contact.cid = '$cid' and contact_office.cid = contact.cid 

and contact_office.oid = office.oid?); 





$num_results = mysql_num_rows($result); 





if (!$result) 



{ 

print mysql_error().? ERROR - browse query failed.?; 

} 





for ($i = 0; $i < $num_results; $i++) 

{ 

$row = mysql_fetch_array($result); 



// the line below is 391 



$content .= '<tr bgcolor=?'. get_alt_row_color($num_results). '?>'; 

$content .= '<td class=?normalprint?><font face=?Verdana,Arial,sans-serif? 

size=?-1?>' .?\n?; 

$content .= $row[0]; 





} 



} 



______________________________________________ 



function make_users_table_end() 

{ 

$content = '</table>'; 

return $content; 

} 



______________________________________________

 
Message #2 by "Nikolai Devereaux" <yomama@u...> on Tue, 19 Feb 2002 13:53:14 -0800

Yes...



(this should really be one of my canned responses by now.)



Check error_reporting in php.ini.  If you're reporting E_WARNING level

notices, you'll see it.  If you are reporting E_ALL & ~E_NOTICE, you won't.



PHP 4.0.6 and before suppressed warning level notices.  4.1.0 and greater

outputs them by default, which causes a lot of people grief since SOOOOoo

much code has been published in examples and books that suddenly doesn't

work anymore.



take care,



nik



> -----Original Message-----

> From: jon woods [mailto:jonwoods@a...]

> Sent: Tuesday, February 19, 2002 8:29 PM

> To: beginning php

> Subject: [beginning_php] code mod :( (displaying data from mysql via php

> script)

>

>

> hi,

>

> dont know if anyone has looked at the following site b4:

>

> http://www.phphelp.com/article/43p1.php

>

>

> i have altered the code slightly to incorparate different data but when i

> call the functions the following error occurs..

>

> to call the functions from the host script i have put

>

> print make_users_table_start();

> print browse_users($valid_user);

> print make_users_table_end();

>

> ?Warning: Undefined variable: content in C:\Inetpub\e3\functions.php on

> line 391?

>

> also the function browse_users doesnt return any results when using the

> structure used on line 391. however the db def. returns the appro. values

> as if i perform echo $row[0]; the desired result is there.

>

>

> do you have any suggestions on how to get it working?

>

> thanx in advance

>

> jk.




  Return to Index