[PHP-DB] Array Trouble
Hi, I e-mailed this before, but the attachments didnt go through. I am designing something that my tech team can use to track the maintenancing of our school district computers. I have a table of data (formitems) that contains tasks that must be completed for that computer depending on the platform. I loaded the results from the apple.php form into an array ($item). I need to make a row ($makerow) then, assuming all of the proper columns are there, load each value in the array into its corresponding column in the database. For some reason, PHP is not returning the current value of the array, it is handing MySQL the whole array. Any help would be appreciated. -Tyler Web and Database Administrator East Valley School District ? include './include/dbconnect.php'; include 'accessConnect.php'; include './include/vars.php'; $sql = select * from inventory where ID like $id and notNetworked IS NULL;; $row = odbc_exec($db, $sql) or die (Could not execute SQL query); ? html head title?= $title ?/title script language=javascript function checkAll() { ? $sql = SELECT * FROM FORMITEMS WHERE PLATFORM LIKE '%mac%' ORDER BY ID;; $result = mysql_query($sql); while($list = mysql_fetch_array($result)) { echo if(document.form.item$list[id].value == \1\)\n{\ndocument.$list[id].value = \2\;\n}\n; } ? } /script /head body bgcolor=#CBe5Db link=#405266 vlink=#3F593E alink=#3F593E div align=center center table border=0 cellspacing=0 cellpadding=0 width=780 tr td width=15 height=15img border=0 src=images/corner_tl.gif width=15 height=15/td td bgcolor=#FF height=15img border=0 src=images/clear.gif width=1 height=1/td td width=15 height=15img border=0 src=images/corner_tr.gif width=15 height=15/td /tr tr td bgcolor=#FF width=15img border=0 src=images/clear.gif width=1 height=1/td td bgcolor=#FF table border=0 width=100% cellpadding=0 cellspacing=0 /tr tr td valign=top rowspan=3 bgcolor=#C0C0C0 background=images/main_bg.gifimg border=0 src=images/clear.gif width=18 height=1 /td td valign=topimg border=0 src=./images/logo.png hspace=2 alt=Computer Maintenance align=top /td !--WebAdmin Info--- td valign=top align=rightimg src=./images/macos.gif align=lefttable cellpadding=0 cellspacing=0 border=0trtdApple - ? echo ID b/tdtdb; echo $id; echo /b/td/trtrtdLocation: /tdtdb; echo odbc_result($row, location); echo - ; echo odbc_result($row, roomNo); echo /b/td/trtrtdTeacher: /tdtdb; echo odbc_result($row, teacher); echo /b/td/trtrtdModel: /tdtdb; echo odbc_result($row, modelNo); echo /b/td/trtrtdSerial: /tdtdb; echo odbc_result($row, serialNo); echo /b/td/trtrtdMac Address: nbsp;/tdtdb; echo odbc_result($row, macAddress); echo /b/td/trtrtdDrop: /tdtdb; echo odbc_result($row, dropID); echo /b/td/trtrtdOS: /tdtdb; echo odbc_result($row, OS); echo /b/td/trtrtdProcessor: /tdtdb; echo odbc_result($row, processor); echo /b/td/tr; echo trtda href='http://support.evsd.org/webadmin/edit_entry.asp?database=newDBfound=singledeviceNum=1autoNo=; . odbc_result($row, autoNo) . 'Edit This Info/a/td/tr; ? /table !--End WebAdmin Info--- /td /tr tr td valign=bottom colspan=2 img border=0 src=images/clear.gif width=5 height=5 /td /tr tr td valign=top colspan=2 !-Empty Cell--- table border=0 cellpadding=5 cellspacing=7 tr td valign=top !-Maintenance Form--- form method=post action=data.php name=form table trtd align=bottomNotbrDone nbsp;nbsp;/tdtdN/A nbsp;nbsp;/tdtdDone/tr/tr ? $sql = SELECT * FROM FORMITEMS WHERE PLATFORM LIKE '%mac%' ORDER BY ID;; $result = mysql_query($sql); while($list = mysql_fetch_array($result)) { echo trtdinput type=radio name=item$list[id] value=\1\ checked/tdtdinput type=radio name=item$list[id] value=\2\/tdtdinput type=radio name=item$list[id] value=\3\/tdtd$list[item]/td/tr\n; } ?
[PHP-DB] Array trouble
Hi, I have been having a lot of trouble getting an array into the MySQL table like I want it. This is supposed to take the current maintenance tasks from a table in the database on apple.php each of these is given a name $item[autoNo] where autoNo is the auto_increment id that task is associated with. This is passed to data.php where it is supposed to make a row in the maintenanceditems table, then in a loop directly below that it is supposed to run the array and place each array value into its associated column in the database. Considering all of the columns exist, I think the problem just has to do with how I am pulling the array values out and placing them into their column. Any help would be appreciated. Thanks in advance, Tyler -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Array trouble
Hi, I have been having a lot of trouble getting an array into the MySQL table like I want it. This is supposed to take the current maintenance tasks from a table in the database on apple.php each of these is given a name $item[autoNo] where autoNo is the auto_increment id that task is associated with. This is passed to data.php where it is supposed to make a row in the maintenanceditems table, then in a loop directly below that it is supposed to run the array and place each array value into its associated column in the database. Considering all of the columns exist, I think the problem just has to do with how I am pulling the array values out and placing them into their column. Any help would be appreciated. Thanks in advance, Tyler -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] mysql-windows xp
Hi, If you want MySQL to work in XP, make sure that you have the proper version (XP/2000/NT) and in the advanced settings of your firewall, make sure to allow TCP port 3306 to have full internet access from inside as well as out. Good luck, Tyler - Original Message - From: SELPH,JASON (HP-Richardson,ex1) [EMAIL PROTECTED] To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Friday, December 13, 2002 6:28 AM Subject: RE: [PHP-DB] mysql-windows xp I honestly can't give you an answer on that as I haven't installed mysql on XP. On linux there are 2 ways to connect to your server, socket or tcp. I am not sure on the windows version. I just know that trying to access anything on a firewalled machine, even from itself, via tcp with XP didn't work until I disable ICF. Try running winmysqladmin though if you haven't already. or give a more detailed error message. Jason -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Friday, December 13, 2002 8:35 AM To: [EMAIL PROTECTED] Subject: RE: [PHP-DB] mysql-windows xp Forgive me if this is a dumb question but is that still the case if mysql is on the same machine? Thanks, Eddie -Original Message- From: SELPH,JASON (HP-Richardson,ex1) [mailto:[EMAIL PROTECTED]] Sent: Friday, December 13, 2002 9:01 AM To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Cc: SELPH,JASON (HP-Richardson,ex1) Subject: RE: [PHP-DB] mysql-windows xp by default on a new xp install the firewall is enabled. stops everything on your network from getting thru. if port 3306 is blocked then accessing mysql thru ip would be denied. To disable internet connection firewall... I have not installed mysql on xp, but the same thing happens with irc, http servers, ftp servers, netbios, file sharing, etc. In Control Panel, double-click Networking and Internet Connections, and then click Network Connections. Right-click the connection on which you would like to disable ICF, and then click Properties. On the Advanced tab, click the box to clear the option to Protect my computer or network. Jason -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Friday, December 13, 2002 7:54 AM To: SELPH,JASON (HP-Richardson,ex1) Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: RE: [PHP-DB] mysql-windows xp that didn't cause me any issues on my install. why do you have to turn that off. i'm not doubting you, just curious? Jeff SELPH,JASON (HP-Richardson To: '[EMAIL PROTECTED]' [EMAIL PROTECTED], ,ex1)[EMAIL PROTECTED] jason.selph@h cc: [EMAIL PROTECTED] p.com Subject: RE: [PHP-DB] mysql-windows xp 12/13/2002 08:44 AM turn off the xp firewall as well. Jason -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Friday, December 13, 2002 7:29 AM To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: Re: [PHP-DB] mysql-windows xp probably b/c of grants/rights did you run a -- grant all on *.* to user@localhost ? or something of the sort. or set up root to have access can you connect via command line? HTH Jeff epeloke@echoma n.com (EdwardTo: [EMAIL PROTECTED] Peloke) cc: Subject: [PHP-DB] mysql-windows xp 12/13/2002 08:54 AM I got a new laptop yesterday that has xp home loaded. I installed mysql last night but get errors that I can't connect to 'localhost'. Any ideas? Thanks, Eddie -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Undefined Constant
Hi, Thank you all for your quick help, it was just a Youve been up too long working on this and it is the middle of the night mistakes. Once I put quotes around my constant, everything worked. Thanks again, Tyler - Original Message - From: Jason Wong [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, November 26, 2002 11:39 PM Subject: Re: [PHP-DB] Undefined Constant On Wednesday 27 November 2002 15:24, Tyler Whitesides wrote: Hi, Although I have been working with PHP for a while, working with Databases is something that I am only so so at. This code is supposed to grab the price from the database given the auto_increment id is inside of $casing. I am trying to get the $row[price] to echo so that Javascript recieves a string, converts it to an integer, and later on in the code, gives the user a total. Any ideas? Use: $row['price'] -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * /* The world really isn't any worse. It's just that the news coverage is so much better. */ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Undefined Constant
Hi, Although I have been working with PHP for a while, working with Databases is something that I am only so so at. This code is supposed to grab the price from the database given the auto_increment id is inside of $casing. I am trying to get the $row[price] to echo so that Javascript recieves a string, converts it to an integer, and later on in the code, gives the user a total. Any ideas? Thanks, Tyler ? $grab = select * from parts where id = '$casing';; //This is line 17 $get = mysql_query($grab); $row = mysql_fetch_row($get); ? var casing = parseInt(form1.?= $row[price]; ?.value); ? $grab = select * from parts where id = '$processor';; $get = mysql_query($grab); $row = mysql_fetch_row($get); ?
[PHP-DB] mysql_num_rows()
Hi, I have been having some trouble with this, I mysql_num_rows() to find out how many rows there are and do an insert statement in the for loop for every row returned. So, if mysql_num_rows returns 17 then the for loops does an insert statement for every instance, when the 17 turns into zero the loop stops. For some reason the $insert never recieves any value. Thanks in advance, Tyler Whitesides East Valley School District WebAdministrator -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Select Fields
Hi, Sorry if this is ametuer, but I have been staring at this code for so long, trying to find out why my selection fields are gathering values, and I cant find the problem. Thanks, Tyler -- ? include './include/vars.php'; include './include/dbconnect.php'; ? html head title?= $title ?/title script languauge=javascript function totalCost() { var form = document.system; var casing = form.casing.value; var processor = form.processor.value; var ram = form.ram.value; var hdd = form.hdd.value; var video = form.video.value; var sound = form.sound.value; var nic = form.nic.value; var monitor = form.monitor.value; var speakers = form.speakers.value; var interfaces = form.interfaces.value; var total = casing + processor + ram + hdd + video + sound + nic + monitor + speakers + interfaces; form.price.value = total; } /script /head body bgcolor=#CBD5DA link=#405266 vlink=#3F593E alink=#3F593E div align=center center table border=0 cellspacing=0 cellpadding=0 width=780 tr td width=15 height=15img border=0 src=images/corner_tl.gif width=15 height=15/td td bgcolor=#FF height=15img border=0 src=images/clear.gif width=1 height=1/td td width=15 height=15img border=0 src=images/corner_tr.gif width=15 height=15/td /tr tr td bgcolor=#FF width=15img border=0 src=images/clear.gif width=1 height=1/td td bgcolor=#FF table border=0 width=100% cellpadding=0 cellspacing=0 /tr tr td valign=top rowspan=3 bgcolor=#C0C0C0img border=0 src=images/clear.gif width=10 height=1 /td td valign=topimg border=0 src=./images/main.png hspace=2 alt=Computer Service /td td valign=top align=right table name=login border=0 cellpadding=0 cellspacing=0 tr td bgcolor=#cococo centerbServices/b/center /td/tr trtd center ? include './include/links.php'; ? /center /td/tr /table br /td /tr tr td valign=bottom colspan=2 !---Main Body h2centerBuild Your Custom System/center/h2 form name=system action=customSystems.php method=post ? $parts = mysql_query(select part,price from parts where type like case;); ? ul Case: select name=casing ? while($item = mysql_fetch_array($parts)) { echo option name='$item[part]' value=$item[price]$item[part]/option; } ? /select /ul div align=rightTotal Cost Of Parts: input type=text name=price size=6/div /form !-End Main Body-- /td /tr tr td valign=top colspan=2 !-Empty Cell--- table border=0 cellpadding=5 cellspacing=7 tr td /td td /td td valign=top /td /tr /table /td /tr tr td valign=top bgcolor=#C0C0C0nbsp; /td td valign=top bgcolor=#C0C0C0 colspan=2 /td /tr /table /td td bgcolor=#c0c0c0/td /tr tr td valign=top align=right width=15 height=15img border=0 src=images/corner_bl.gif width=15 height=15/td td bgcolor=#FF height=15/td td valign=top align=left width=15 height=15img border=0 src=images/corner_br.gif width=15 height=15/td /tr /table /div /body /html
Re: [PHP-DB] Select Fields
Thank you putting '%case%' instead of case worked! - Original Message - From: David Smith [EMAIL PROTECTED] To: Tyler Whitesides [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Wednesday, November 06, 2002 10:47 PM Subject: Re: [PHP-DB] Select Fields Tyler, You probably need one or two of the following: 1. Put single-quotes around case in your SQL (where type like 'case') 2. Use wild-cards in your where statement (where type like '%case%') Good luck! --Dave On Wed, 2002-11-06 at 23:31, Tyler Whitesides wrote: Hi, Sorry if this is ametuer, but I have been staring at this code for so long, trying to find out why my selection fields are gathering values, and I cant find the problem. Thanks, Tyler -- ? include './include/vars.php'; include './include/dbconnect.php'; ? html head title?= $title ?/title script languauge=javascript function totalCost() { var form = document.system; var casing = form.casing.value; var processor = form.processor.value; var ram = form.ram.value; var hdd = form.hdd.value; var video = form.video.value; var sound = form.sound.value; var nic = form.nic.value; var monitor = form.monitor.value; var speakers = form.speakers.value; var interfaces = form.interfaces.value; var total = casing + processor + ram + hdd + video + sound + nic + monitor + speakers + interfaces; form.price.value = total; } /script /head body bgcolor=#CBD5DA link=#405266 vlink=#3F593E alink=#3F593E div align=center center table border=0 cellspacing=0 cellpadding=0 width=780 tr td width=15 height=15img border=0 src=images/corner_tl.gif width=15 height=15/td td bgcolor=#FF height=15img border=0 src=images/clear.gif width=1 height=1/td td width=15 height=15img border=0 src=images/corner_tr.gif width=15 height=15/td /tr tr td bgcolor=#FF width=15img border=0 src=images/clear.gif width=1 height=1/td td bgcolor=#FF table border=0 width=100% cellpadding=0 cellspacing=0 /tr tr td valign=top rowspan=3 bgcolor=#C0C0C0img border=0 src=images/clear.gif width=10 height=1 /td td valign=topimg border=0 src=./images/main.png hspace=2 alt=Computer Service /td td valign=top align=right table name=login border=0 cellpadding=0 cellspacing=0 tr td bgcolor=#cococo centerbServices/b/center /td/tr trtd center ? include './include/links.php'; ? /center /td/tr /table br /td /tr tr td valign=bottom colspan=2 !---Main Body h2centerBuild Your Custom System/center/h2 form name=system action=customSystems.php method=post ? $parts = mysql_query(select part,price from parts where type like case;); ? ul Case: select name=casing ? while($item = mysql_fetch_array($parts)) { echo option name='$item[part]' value=$item[price]$item[part]/option; } ? /select /ul div align=rightTotal Cost Of Parts: input type=text name=price size=6/div /form !-End Main Body-- /td /tr tr td valign=top colspan=2 !-Empty Cell--- table border=0 cellpadding=5 cellspacing=7 tr td /td td /td td valign=top /td /tr /table /td /tr tr td valign=top bgcolor=#C0C0C0nbsp; /td td valign=top bgcolor=#C0C0C0 colspan=2 /td /tr /table /td td bgcolor=#c0c0c0/td /tr tr td valign=top align=right width=15 height=15img border=0 src=images/corner_bl.gif width=15 height=15/td td bgcolor=#FF height=15/td td valign=top align=left width=15 height=15img border=0 src=images/corner_br.gif width=15 height=15/td /tr /table /div /body /html -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php