Re: passing variables
| From: | Paul DuBois | Date: | Mon, 19 Jun 2000 19:22:04 +0000 |
| Subject: | Re: passing variables | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-2231@lists.php.net to get a copy of this message | ||
At 3:07 PM -0700 2000-06-19, Erik Dawson wrote:
I understand that much. I guess it is the scope that I am having problems with. maybe you can take a look to see where I am going wrong. The error is coming from the "$cnote="... line. If I put data in place of the $thismsg variable the whole thing works.What happens if $thismsg is blank or non-numeric or contains spaces, etc.? You'll get a syntax error. You should probably place it between quotes (... where msgtype= '$thismsg').
Thanks Erik <-----------------------------------> $mtype = mysql_query("select distinct msgtype from ticket"); if ($mtyperow=mysql_fetch_array($mtype)) do { $thismsg = $mtyperow["msgtype"]; echo "<table width=780px bgcolor=ivory border=1>-- Paul DuBois, paul@snake.net<tr><th colspan=9 align=left bgcolor=black><font color=ivory>", $thismsg, "</font> <tr> <th>Ticket # <th>Message <th>Date Open <th>Date Closed <th>Status <th colspan=3>Impact<br> Current/<fontcolor=blue>Planned</font>/<font color=red>Actual Max</font><th>Last Modified";/* list each ticket once */ $ticketno = mysql_query ("select distinct ticket from ticket"); if ($tickrow = mysql_fetch_array($ticketno)) do{ $tickno=$tickrow["ticket"]; /* find newest record of ticket*/ $newest = mysql_query ("select max(ID) as maxid from ticket where ticket=$tickno"); if($newestrow = mysql_fetch_array($newest)) do{ $thisid=$newestrow["maxid"]; /* print each ticket by msgtype*/ $cnote = mysql_query ("select * from ticketwhere msgtype= $thismsg and close_tick is NULL andlogaction<>\"Deleted\" and ID = $thisid"); if ($cnoterow = mysql_fetch_array($cnote)) do{ echo "<tr>"; echo "<td valign=top> ", $cnoterow["ticket"]; echo "<td valign=top width=30%> <b>", $cnoterow["subject"],"</b><br><font size=-1>",$cnoterow["message"], "</font>";echo "<td valign=top> ", substr($cnoterow["open_tick"],5,5); echo "<td valign=top> ", substr($cnoterow["close_tick"],5,5); echo "<td valign=top> ", $cnoterow["status"]; echo "<td valign=top width=10%> ", $cnoterow["impact_now"]; echo "<td valign=top width=10%>&n bsp;<font color=blue>", $cnoterow["impact_plan"], "</font>"; echo "<td valign=top width = 10%> <font color=red>", $cnoterow["impact_max"], "</font>"; echo "<td valign=top> ", substr($cnoterow["lastmod"],4,2), "-",substr($cnoterow["lastmod"],6,2);}while($cnoterow= mysql_fetch_array($cnote)); }while($newsetrow=mysql_fetch_array($newest)); }while($tickrow=mysql_fetch_array($ticketno)); echo "</table>"; }while($mtyperow=mysql_fetch_array($mtype)); ?> ----- Original Message ----- From: Sam Masiello <smasiello@chekinc.com> To: Erik Dawson <erik@gmservices.com>; <php-general@lists.php.net> Sent: Monday, June 19, 2000 11:47 AM Subject: RE: [PHP-GENERAL] passing variablesIf the variable exists within the scope of your page, you can create a SQL string like this: $sqlstr = "SELECT * FROM table WHERE field = '$variable' " ; Sam Masiello System Analyst Chek.Com (716) 853-1362 x289 smasiello@chekinc.com -----Original Message----- From: Erik Dawson [mailto:erik@gmservices.com] Sent: Monday, June 19, 2000 5:29 PM To: php-general@lists.php.net Subject: [PHP-GENERAL] passing variables Hello, I have been enjoying this forum for a few weeks now and learning verymuch,thank you to all who answer everyones questions. I now have a question. I need to pass a variable to an sql query that is nested inside 3 "do... while" statements. I am sure there is even an easier way to do this thanallthe "do... while" 's but this is the only idea that I had. I am still learning php and eager to learn more. Any help is greatly appreciated. Thanks Erik-- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net