my sql select id and then update problem.


Posted on 16th Feb 2014 07:03 pm by admin

I need to select some auto incremented ids out of a database and then use those id in a where statement which updates the database at the id's location the below code works up to the update statements where it just dies without coughing up an error or anything......can you spot whats wrong and help me fix it?


Code: $current = Array();
$currsel = mysql_query("select id from page0.page0 where refnum ='$newnum' AND username!='admin'")
or die(mysql_error());
while($currrow = mysql_fetch_array($currsel)){
array_push($current,$currrow['id']);
}
print_r($current);

$current1 = Array();
$currsel1 = mysql_query("select id from page0.page0 where refnum ='$oldnum' AND username!='admin'")
or die(mysql_error());
while($currrow1 = mysql_fetch_array($currsel1)){
array_push($current1,$currrow1['id']);
}
print_r($current1);

$upref1= mysql_query("update page0.page0 SET refnum='$newnum' where id='$current[0]' OR id='$current[1]'OR id='$current[2]'OR'id=$current[3]'")
or die(mysql_error());




$upref11= mysql_query("update page0.page0 SET refnum='$oldnum' where id='$current1[0]'OR id='$current1[1]'OR id='$current1[2]'OR id='$current1[3]'")
or die(mysql_error());

No comments posted yet

Your Answer:

Login to answer
286 Like 35 Dislike
Previous forums Next forums
Other forums

SESSION CHECK WORKS "MOST" of the time... whats going on?
i have a sign in check thats included in every page that is a members only page which is basically a

Need help making a blockquote and line items conditional
I have some code I bought a few years ago that allows my clients to update content on their site usi

Inserting into MySQL Newbie
Hi ive got a slight problem where ive made a simple web form where the customer inserts the ammount

GMail like Chat in ASP.NET
Hi,Can anyone suggest me, how to incorporate GMail like chat in my existing ASP.Net application.I wa

Agency Business Process
Hi,

I don’t understand the process of the agency business in SAP.

In my

SCRIPT ERROR
Here is the CONTACT FORM I made for our website:

<form id="form1" name="

Encrypt php code?
Is it possible to encrypt php code in files,
so that it displays a load of unreadable characters

upload form file types....
Hey all, I am learning PHP and I am writing a script from the W3C Schools tutorials for uploading fi

retrieving images from mysql database using php
So I've been trying to figure out how to store images in a mysql database, and as far as i can tell

Does design fit in FPGA ?
Hi all,

I've made a large HCC-Design. Because of the program-size the compile process with th

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash