Jump to content

OldWest

Members
  • Posts

    296
  • Joined

  • Last visited

    Never

Everything posted by OldWest

  1. The table has the name "update" in it separated by underscores... That would cause this?
  2. Here is my code: // Start MySQL Query for Records $query = "SELECT codes_update_no_join_1b" . "SET orig_code_1 = new_code_1, orig_code_2 = new_code_2" . "WHERE concat(orig_code_1, orig_code_2) = concat(old_code_1, old_code_2)"; $results = mysql_query($query) or die(mysql_error()); // End MySQL Query for Records This query runs perfectly fine when run direct as SQL in phpMyAdmin, but throws this error when running in my script??? Why is this??? You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '= new_code_1, orig_code_2 = new_code_2WHERE concat(orig_code_1, orig_c' at line 1
  3. This does not throw any errors! Thats a milestone for me on this BUT it also returns 0 results when there of course should be based on the table data UPDATE codes_update_no_join_1a SET orig_code_1 = new_code_1, orig_code_2 = new_code_2 WHERE concat(orig_code_1, orig_code_2) = concat(old_code_1, old_code_2)
  4. Another of many variations I am testing. Of course not working UPDATE codes_update_no_join_1a WHERE concat(orig_code_1, orig_code_2) = concat(old_code_1, old_code_2), SET orig_code_1 = new_code_1, orig_code_2 = new_code_2
  5. Well I've managed to keep the SQL error near the SET (hopefully the rest of the SQL is OK).. But this is what I've come to , and of course is still not working properly. I cant see any reason why this would not work as expected: SELECT concat(orig_code_1, orig_code_2) = concat(old_code_1, old_code_2) FROM codes_update_no_join_1a SET orig_code_1 = new_code_1, orig_code_2 = new_code_2 ERROR: #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SET orig_code_1 = new_code_1, orig_code_2 = new_code_2 LIMIT 0, 30' at line 3
  6. mikosiko, Well. I am trying to process all of these records in one table for simplicity reasons, and based on a working example, I removed what I felt was not needed - which of course is not working! UPDATE codes_update_no_join_1a concat(orig_code_1, orig_code_2) = concat(old_code_1, old_code_2) SET orig_code_1 = new_code_1, orig_code_2 = new_code_2
  7. Alright.. Well I am running the query that was provided for a great peace of mind now and it works great BUT now I am trying to add 00000 (5 zeros) WHERE a.prod_code_1 != b.old_code_1 and trying to SET b.prod_code_1 = '00000' .... Obviously with my luck and research it's not working! But it seems like it should be according to the references I've been reading.. SO basically the original query is perfectly fine, but I want to add 00000 to any prod_codes_1's that do not have a match to old_prod_code_1.. What am I doing wrong?
  8. mikosiko, Thank you for easing my mind... If I understand your note correct, my second approach - using the same table, has some ground to actually work?? And am I right in my understanding that the "." in prod_code_1.prod_code_ is a concatenation operator in SQL? UPDATE codes WHERE (old_code_1.old_code_2 = prod_code_1.prod_code_2) SET prod_code_1.prod_code_2 WHERE (old_code_1.old_code_2 = new_code_1.new_code_2)
  9. Here is another variation I am working out. Does not work. Don't tell me what to do!, just what I might be doing wrong please: UPDATE codes WHERE (old_code_1.old_code_2 = prod_code_1.prod_code_2) SET prod_code_1.prod_code_2 WHERE (old_code_1.old_code_2 = new_code_1.new_code_2)
  10. This is what I have got so far. I decided to combine all fields into one table for simplicity. SELECT codes WHERE prod_code_1="*" AND prod_code_2="*"; LIKE old_code_1 AND old_tax_code_1; REPLACE prod_code_1 AND WITH prod_code_ new_code_1 AND new_code_1; This is not working as it stands, but I will describe my logic for critique: Line 1: Selecting all prod codes. Line 2: Prod codes matching old codes. Line 3: Replacing matching old codes with new codes. Am I at all on the right track here? SOS.
  11. Hi mikosiko, I lost a job offer because I could not solve this problem in time. I started writing a php app to do this for me, but that was taking too long. I've tried various VB scripts in excel and other find and replace methods to no avail. I've got about 11 hours in this and at this point, for the sake of learning, I am just trying to get off my feet on how to do this with a SQL query. I don't know what a LEFT JOIN would have to do with finding and replacing records, so that does not make much sense at all. Of course the table would need to be joined, but as far as searching, finding and updating as required - I don't think a JOIN can do all that out of the box!
  12. I am very new to writing SQL queries direct into phpMyAdmin. Honestly. I am not sure where I should start from where I am now with SQL to properly run my query and update the records as I need to, so any advice is much appreciated on this. This is what I've got: Table A. Table B. Table A has 2 (1,2) Columns. Table B has 4 (1,2,3,4) Columns. Each column in both tables has 5 digits. There are 3 sets of 5 digits: Table A 1,2 - Table B 1,2 & 3,4. Each of these 3 groups should act as a full ten digits. So if Table A: Field 1 - 14325 :: Field 2 - 78467 - In my query, the result would be 1432578467. I need to write an query that: 1) Scans Table B Columns 1 & 2. 2) Finds matches in Table A Columns 1 & 2. 3) Replaces any matched values with Table B Columns 3 & 4. I was told this can be easily done in a few minutes with a LEFT JOIN, but that does not make much sense to me.
  13. I should note I do not need the Concatenate to output any new data. I just need it Concatenated in an array or the likes for processing, so the prod_codes can be updated in their respective fields.
  14. Although I am deciding on the best route to go on this, I was hoping for any feedback or ideas on the best and simplest approach to the below problem: Here is my table structure: old_code_1 old_code_2 new_code_1 new_code_2 prod_code_1 prod_code_2 Each of the following fields has 5 digits e.g. 00045, 12654, etc. What I need to achieve is this: Concatenate each set (of the 3 sets above) data into one variable e.g. old_code_1 + old_code_2 = 0004512654. So old_code_1 & old_code_2 would become a combined data and the same for the othe 2 sets. Then. Once concatenated, I need to compare: prod_code_1+prod_code_2 with old_code_1+old_code_2 and replace prod_code_1+prod_code_2 with new_code_1+new_code_2 where matches are found. The new_code_1 & 2 are in the same row as the old_code 1 & 2. So the data is in alignment that way for comparison. Thanks for any insight or suggestions on how to make this happen in the simplest form possible.
  15. Hello. I want to say thanks for the help with this session problem I was having. I was able to get it all working, and I was hoping anyone could look it over and critique my code to let me know if it should be improved or changed for better performance or just plain better coding practice. Thanks in advance. Page 1 <?php session_start(); ?> <?php $PHPSESSID = session_id(); echo "<strong>Session ID:</strong> $PHPSESSID"; "<br /><br />"; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>0</title> </head> <body> <form method="post" action="multi_page_post_2.php"> <label>First Name</label> <input name="first_name" value="" width="50" type="text" /> <br /><br /> <label>Last Name</label> <input name="last_name" value="" width="50" type="text" /> <br /><br /> <input type="submit" name="submit" value="Enter your Data - Continue to Step 2 >>" /> </form> </body> </html> Page 2 <?php session_start(); ?> <?php $PHPSESSID = session_id(); echo "<strong>Session ID:</strong> $PHPSESSID"; ?> <?php echo "<br /><br />"; print_r($_SESSION); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Step 2</title> </head> <body> <h2>Step 2 - Is this data correct?</h2> <hr /> <strong>First Name:</strong> <?php echo $_SESSION['first_name'] = $_REQUEST['first_name']; ?> <br /><br /> <strong>Last Name:</strong> <?php echo $_SESSION['last_name'] = $_REQUEST['last_name']; ?> <br /><br /> <form method="post" action="multi_page_post_3.php"> <label>Sons First Name: </label> <input name="sons_first_name" value="" width="50" type="text" /> <br /><br /> <input type="submit" name="submit" value="YES! Continue to Step 3 >>" /> <input type="hidden" name="PHPSESSID" value="<?php echo $PHPSESSID ?>" /> <input type="button" value="No! Back to Previous Page" onClick="javascript: history.go(-1)"> </form> </body> </html> Page 3 <?php session_start(); ?> <?php $PHPSESSID = session_id(); echo "<strong>Session ID:</strong> $PHPSESSID"; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Step 3</title> </head> <body> <h2>Step 3 - Is this data correct?</h2> <hr /> <strong>First Name:</strong> <?php echo $_SESSION['first_name']; ?> <br /><br /> <strong>Last Name:</strong> <?php echo $_SESSION['last_name']; ?> <br /><br /> <strong>Sons First Name:</strong> <?php echo $_REQUEST['sons_first_name']; ?> <br /><br /> <form method="post" action="multi_page_post_4.php"> <input type="submit" name="submit" value="Destroy the Session! - Step 4 >>" /> <input type="hidden" name="PHPSESSID" value="<?php echo $PHPSESSID ?>" /> </form> <br /><br /> <a href="" onclick="<?php //session_destroy(); ?>">Session D E S T R O Y !</a> </body> </html> Page 4 <?php session_start(); ?> <?php $PHPSESSID = session_id(); echo "<strong>Session ID:</strong> $PHPSESSID"; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Step 4</title> </head> <body> <h2>Step 4 - Session Evaporation</h2> <?php if ($_SESSION[''] = 1) { session_destroy(); echo "Toast!"; } else { echo "Not Toast!"; }; ?> </body> </html>
  16. Hi Pikachu2000, I am trying to echo the data entered on the first page, have it show on the second page, added a new field for entry on the 2nd page, and ALL data be echoed on the 3rd page. What you see in my code is mixed and matched chunks of code trying to resolve this issue.. I don't think my session would be destroyed on the 3rd page as that requires an "onclick" as the previous poster stated. Thanks for any tips on this. I'm still trying to resolve it!
  17. Hello, I've been hacking at this for about 5 hours, and have been unable to get my session data to pass through to the 3rd page. Here is my code. As you can see I've been trying all types of variation of retrieval. On page 2 I can pull the data from page 1 fine with REQUEST or the longer version.. But for some reason page 3 will not display the first_name and last_name... I'm desperate at this point. I have not been able to find a working answer. I'm running php 5 w/ trans... OFF (default) in .ini. Page 1 <?php session_start(); ?> <?php $PHPSESSID = session_id(); echo "<strong>Session ID:</strong> $PHPSESSID"; "<br /><br />"; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>0</title> </head> <body> <form method="post" action="multi_page_post_2.php"> <label>First Name</label> <input name="first_name" value="" width="50" type="text" /> <br /><br /> <label>Last Name</label> <input name="last_name" value="" width="50" type="text" /> <br /><br /> <input type="submit" name="submit" value="Enter your Data - Continue to Step 2 >>" /> </form> </body> </html> Page 2 <?php session_start(); ?> <?php $PHPSESSID = session_id(); echo "<strong>Session ID:</strong> $PHPSESSID"; $first_name = $_REQUEST['first_name']; echo $first_name; ?> <?php echo "<br /><br />"; print_r($_SESSION); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Step 2</title> </head> <body> <h2>Step 2 - Is this data correct?</h2> <hr /> <strong>First Name:</strong> <?php echo $_SESSION['first_name'] = $_POST['first_name']; ?> <br /><br /> <strong>Last Name:</strong> <?php echo $_SESSION['last_name'] = $_POST['last_name']; ?> <br /><br /> <form method="post" action="multi_page_post_3.php"> <label>Sons First Name: </label> <input name="sons_first_name" value="" width="50" type="text" /> <br /><br /> <input type="submit" name="submit" value="YES! Continue to Step 3 >>" /> <input type="hidden" name="PHPSESSID" value="<?php echo $PHPSESSID ?>" /> <input type="button" value="No! Back to Previous Page" onClick="javascript: history.go(-1)"> </form> <br /><br /> <a href="" onclick="<?php session_destroy(); ?>">Session D E S T R O Y !</a> </body> </html> Page 3 <?php session_start(); ?> <?php $PHPSESSID = session_id(); echo "<strong>Session ID:</strong> $PHPSESSID"; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Step 3</title> </head> <body> <h2>Step 3 - Is this data correct?</h2> <hr /> <strong>First Name:</strong> <?php echo $_SESSION['first_name'] = $_REQUEST['first_name']; ?> <br /><br /> <strong>Last Name:</strong> <?php echo $_SESSION['last_name']; ?> <br /><br /> <strong>Sons First Name:</strong> <?php echo $_REQUEST['sons_first_name']; ?> <br /><br /> <form method="post" action="multi_page_post_4.php"> <input type="hidden" name="PHPSESSID" value="<?php echo $PHPSESSID ?>" /> </form> <br /><br /> <a href="" onclick="<?php session_destroy(); ?>">Session D E S T R O Y !</a> </body> </html>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.