cowasockytommy Posted July 8, 2013 Share Posted July 8, 2013 Hello all im new to this been playing with it for a week but i play with c# making games so it's not to different. im having a problem with updating a value in a column in my database. i can get it to work if i use $result1= mysqli_query($con,"UPDATE Customers SET NextExpectedCut = 222 WHERE Name = 'ruth'"); but i entered all the databases information into an array ($rows).. so there for i tested already by doing: echo $rows[0][0]; and i get the first customers name on the browser so why cant i get this to work? am i formatting it wrong or is there a different way to do this? thanks Tommy if(isset($_GET['test']) && $_GET['test'] =="1"){ $result = mysqli_query($con,"SELECT * FROM Customers"); while($row = mysqli_fetch_array($result)) { $rows[]=$row; }echo $rows[0][0] ." is finished";$result1= mysqli_query($con,"UPDATE Customers SET NextExpectedCut = 222 WHERE Name = $rows[0][0]"); Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted July 9, 2013 Share Posted July 9, 2013 presumably your names are strings. you must enclose string data by single-quotes inside the query statement so that is treated as a string instead of a mysql keyword or column name. if you had error checking logic in your code, it would be reporting an undefined column name that is the same as the first name's value. in your hard-coded query - Name = 'ruth'" you have single-quotes around the string value. the query syntax you build where the value comes from a php variable must have the same query syntax. Quote Link to comment 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.