473,386 Members | 1,706 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Data won't Update via PHP/MySQL UPDATE

Hi,

I've been wrestling with this for a while and finally decided to ask for outside assistance.

I'm getting no errors with my code. If I print all the of the variables they have values but when I run my script to update the table it doesn't input them. The loop is iterating all the way through but the data just isn't making it's way into the table. I've never encountered this before and I'm hoping someone may have an answer for me.

PHP 4.3.2 / MySQL 3.23.58


[PHP]for ($i = 0; $i < $length; $i++)
{
$query = "UPDATE microcpus SET netBios = '".$a_result[$i][2]."', memory = '".$a_result[$i][4]."', os = '".$a_result[$i][6]."', csd = '".$a_result[$i][7]."', user = '".$a_result[$i][8]."', lastscan = '".$a_result[$i][9]."', vidio = '".$a_result[$i][10]."', processor = '".$a_result[$i][11]."', disk = '".$a_result[$i][12]."', netcard = '".$a_result[$i][13]."', network = '".$a_result[$i][14]."' WHERE serial = '".$a_result[$i][3]."'";
$result = mysql_query($query);
}
[/PHP]

Thanks,
Steve
Oct 10 '07 #1
5 3119
ronverdonk
4,258 Expert 4TB
Get the result of the query by expanding the mysql_query statement as follows:
Expand|Select|Wrap|Line Numbers
  1. $result = mysql_query($query) or die ("UPDATE error: ".mysql_errror());
  2.  
then investigate any error message returned.

Ronald
Oct 10 '07 #2
Atli
5,058 Expert 4TB
Hi Steve. Welcome to TSDN!

Do you have the debug messages turned on?

Try adding die() to your mysql_query() function:
Expand|Select|Wrap|Line Numbers
  1. $result = mysql_query($sql) or die("Query failed : ". mysql_error());
  2.  
Oct 10 '07 #3
Thanks!

I had already tried that with no luck...

It produced no errors.
Oct 10 '07 #4
Atli
5,058 Expert 4TB
Have you tried echoing the query, just to see if it looks like you expect it to?
Oct 10 '07 #5
You know, I hadn't done that. And what do you know, the html page I was stripping data from was formatted poorly and because of that it was inserting a blank space as the first character in some of the fields of my array.

I added some code to strip the character out of my array elements, reran the script and all the data imported.

Thanks, I knew I just needed another perspective.
Oct 10 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: dave | last post by:
Hello there, I am at my wit's end ! I have used the following script succesfully to upload an image to my web space. But what I really want to be able to do is to update an existing record in a...
0
by: Donald Tyler | last post by:
Then the only way you can do it that I can think of is to write a PHP script to do basically what PHPMyAdmin is trying to do but without the LOCAL in there. However to do that you would need to...
2
by: Carlos Eduardo Peralta | last post by:
Hello: Can i update a MySQL database with just copy the files MYI MYD and FRM in the right dir? I know this work. The question is how MySQL manage the user that are usig that database in that...
0
by: David Linsin | last post by:
I created a simple test case to reproduce the problem (also check Bug #15500): import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.Statement;...
1
by: roger.rigsby | last post by:
Ok I know how to get the data I want from mysql but I need to actually do something with this data and then send it back to mySQL. Company heads love the spreadsheet view so this is serious...
4
by: dac | last post by:
I am quietly going insane on this project. I've never worked on a project like this one before. All my previous sticky forms were for data entry, not editing. I don't know how to display the form...
11
by: stantron | last post by:
Setup: I only have one database with one table in it. The first page has a form that adds a record (w/ 6 fields in it) to the mySQL database's lone table via PHP. This works fine. I also have a PHP...
6
by: clark070 | last post by:
Hi Guys, I mainly develop my program on a package tool provided by PHP Triad (from a long time ago) and I was running them solely on my notebook with no problem at all. I have this code that...
9
by: Gilles Ganault | last post by:
Hello Some data are common to all user sessions, and to improve performance/save resources, I'd like to share those data between all sessions, so that each user doesn't have to hit MySQL for the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.