RE: 2nd Pair of eyes please

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



 

> -----Original Message-----
> From: Donovan Brooke [mailto:lists@xxxxxxx] 
> Sent: Wednesday, January 26, 2011 2:35 PM
> To: php-db@xxxxxxxxxxxxx
> Subject:  2nd Pair of eyes please
> 
> O.K., I give up.. I can't seem to find why this breaks the page to
> a point where nothing gets displayed in the browser (no error 
> reporting).
> 
> Sorry for any email line breaks:
> 
> 
> -------start---------
> if ($t_dataon) {
>    $query = "SELECT 
> s_sitename,s_logopath,s_headinfo,s_head_moreinfo,s_rightpic_path FROM 
> site WHERE (s_id=31) LIMIT 1";
> 
>    if ($a_r = @mysql_query($query)) {
>      while (list($tname, $tlogo, $thead, $tmorehead, $trpic) = 
> mysql_fetch_row($a_r)) {
>        $t_sitename = "$tname";
>        $t_logopath = "$tlogo";
>        $t_headinfo = "$thead";
>        $t_moreheadinfo = "$tmorehead";
>        $t_rpic = "$trpic";
>      }
>    } else {
>      // Problem with query
>      print = "<!-- problem -->";
>    }
> }
> --------end---------

I didn't see anything that jumps out as obvious enough to break your page
render, but...

What's with this stuff... 

You already have a string don't put it in " again.

	$t_sitename = "$tname";

It should just be:

	$t_sitename = $tname;

But even that is silly since you JUST pulled it out in your list(). Cut to
the chase...

	list($t_sitename, $t_logopath, $t_headinfo, $t_moreheadinfo,
$t_rpic)

Next, calling the mysql stuff directly like that is not going to scale and
you're asking for troubles down the line. Make a wrapper around the mysql_*
calls so you can do things like error handling on each query (since you
have to do it anyways), escaping the SQL, returning the results in an
array, etc. Search the archives -- I've posted mine a couple of times
already (db.inc.php).


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux