refiking Posted April 23, 2008 Share Posted April 23, 2008 Is this runnable? I want to change the lid of the records using the lid field to identify the records to change. Here is the code as is: mysql_query("UPDATE dreg SET lid = '$newlid' WHERE lid = '$lid' AND sid = '$sid'")or die(mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/102623-query-question/ Share on other sites More sharing options...
947740 Posted April 23, 2008 Share Posted April 23, 2008 Looks fine to me. Quote Link to comment https://forums.phpfreaks.com/topic/102623-query-question/#findComment-525570 Share on other sites More sharing options...
Fadion Posted April 23, 2008 Share Posted April 23, 2008 Why not try it yourself?? ??? Quote Link to comment https://forums.phpfreaks.com/topic/102623-query-question/#findComment-525572 Share on other sites More sharing options...
947740 Posted April 23, 2008 Share Posted April 23, 2008 I was kind of thinking that too, but I thought I would give him an answer. Quote Link to comment https://forums.phpfreaks.com/topic/102623-query-question/#findComment-525575 Share on other sites More sharing options...
refiking Posted April 24, 2008 Author Share Posted April 24, 2008 That's just it. I tried it and it didn't change the record. Quote Link to comment https://forums.phpfreaks.com/topic/102623-query-question/#findComment-525593 Share on other sites More sharing options...
947740 Posted April 24, 2008 Share Posted April 24, 2008 Ah. You made it sound like you had not tried it and were just curious if it would work. Try this: mysql_query("UPDATE dreg SET lid = \"$newlid\" WHERE lid = \"$lid\" AND sid = \"$sid\"")or die(mysql_error()); If that does not work, I would double check all of your table and columnames. Quote Link to comment https://forums.phpfreaks.com/topic/102623-query-question/#findComment-525594 Share on other sites More sharing options...
refiking Posted April 24, 2008 Author Share Posted April 24, 2008 Nope. Didn't work and didn't return an error. Quote Link to comment https://forums.phpfreaks.com/topic/102623-query-question/#findComment-525599 Share on other sites More sharing options...
947740 Posted April 24, 2008 Share Posted April 24, 2008 You need a connection to the database. E.G. $cxn = mysqli_connect($host,$user,$password,$db); $sq1 = "UPDATE messages SET Message=\"$message\" WHERE MessageNumb=\"$id\""; $result = mysqli_query($cxn,$sq1); In this case: $connection = mysqli_connect($host,$user,$password,$db); $query = "UPDATE dreg SET lid = \"$newlid\" WHERE lid = \"$lid\" AND sid = \"$sid\""; $result = mysqli_query($connection,$query); Quote Link to comment https://forums.phpfreaks.com/topic/102623-query-question/#findComment-525602 Share on other sites More sharing options...
refiking Posted April 24, 2008 Author Share Posted April 24, 2008 I've already connected to the db. I have about 8 queries before this one that work fine. Quote Link to comment https://forums.phpfreaks.com/topic/102623-query-question/#findComment-525604 Share on other sites More sharing options...
947740 Posted April 24, 2008 Share Posted April 24, 2008 I doubt this makes a difference, but try removing the spaces on both sides of the = sign in the query. Other than that, I am gathering that some names are wrong, whether it be columnames or something else. It does not make any sense why it is not working. Quote Link to comment https://forums.phpfreaks.com/topic/102623-query-question/#findComment-525608 Share on other sites More sharing options...
Fadion Posted April 24, 2008 Share Posted April 24, 2008 The php/mysql syntax is right. This thread wont get u anywhere with only that code u posted, so check your variables and column/table names, or post the entire code (related to that specific part). Quote Link to comment https://forums.phpfreaks.com/topic/102623-query-question/#findComment-525671 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.