Vivid Lust Posted July 11, 2009 Share Posted July 11, 2009 Hi, the following doesn't seem to be working for some strange reason ??? <?php ... $sql5="UPDATE settings SET ad1='$ad1' WHERE id='1'"; mysql_query($sql5) //execute query or die(mysql_error()); // if error show it .. ?> I printed out $sql5 I ran it directly in the PHPmyAdmin SQL area and it works fine. However the problem, is that the code doesn't display any error however when looking at the database, the field which it should update is blank. I hope someone can help, Jake Quote Link to comment https://forums.phpfreaks.com/topic/165611-strange-query/ Share on other sites More sharing options...
wildteen88 Posted July 11, 2009 Share Posted July 11, 2009 Where is the variable $ad1 definded? And when you echo $sql5; does your query look right? Quote Link to comment https://forums.phpfreaks.com/topic/165611-strange-query/#findComment-873546 Share on other sites More sharing options...
Vivid Lust Posted July 11, 2009 Author Share Posted July 11, 2009 Query echos as: UPDATE settings SET ad1='adhere' WHERE id='1' so its all fine, that works in phpmyadmin too! Quote Link to comment https://forums.phpfreaks.com/topic/165611-strange-query/#findComment-873548 Share on other sites More sharing options...
wildteen88 Posted July 11, 2009 Share Posted July 11, 2009 What data type is your ad1 field set to? Post your table schema here. Quote Link to comment https://forums.phpfreaks.com/topic/165611-strange-query/#findComment-873553 Share on other sites More sharing options...
Vivid Lust Posted July 11, 2009 Author Share Posted July 11, 2009 This what you needed? Campo Tipo Cotejamiento Atributos Nulo Predeterminado Extra Acción id int(50) No auto_increment Navegar los valores distintivos Cambiar Eliminar Primaria Único Índice Texto completo ad1 text latin1_swedish_ci No Navegar los valores distintivos Cambiar Eliminar Primaria Único Índice Texto completo ad2 text latin1_swedish_ci No Navegar los valores distintivos Cambiar Eliminar Primaria Único Índice Texto completo artist text latin1_swedish_ci No Navegar los valores distintivos Cambiar Eliminar Primaria Único Índice Texto completo logo text latin1_swedish_ci No Navegar los valores distintivos Cambiar Eliminar Primaria Único Índice Texto completo status text latin1_swedish_ci No Navegar los valores distintivos Cambiar Eliminar Primaria Único Índice Texto completo winnerText text latin1_swedish_ci No Navegar los valores distintivos Quote Link to comment https://forums.phpfreaks.com/topic/165611-strange-query/#findComment-873559 Share on other sites More sharing options...
Vivid Lust Posted July 11, 2009 Author Share Posted July 11, 2009 Someone please help? I need this sorted urgently. Quote Link to comment https://forums.phpfreaks.com/topic/165611-strange-query/#findComment-873574 Share on other sites More sharing options...
wildteen88 Posted July 11, 2009 Share Posted July 11, 2009 Seeing as your id field is set to int there is no need to wrap the id in your query within quotes. $sql5="UPDATE settings SET ad1='$ad1' WHERE id=1"; if it still does work I dont know what else to suggest. Quote Link to comment https://forums.phpfreaks.com/topic/165611-strange-query/#findComment-873579 Share on other sites More sharing options...
Vivid Lust Posted July 11, 2009 Author Share Posted July 11, 2009 still doesnt work ... this is so strange Quote Link to comment https://forums.phpfreaks.com/topic/165611-strange-query/#findComment-873584 Share on other sites More sharing options...
wildteen88 Posted July 11, 2009 Share Posted July 11, 2009 Is there a field with the id of 1 in your settings table? What is the output of echo mysql_info(); When you place that after mysql_query() Quote Link to comment https://forums.phpfreaks.com/topic/165611-strange-query/#findComment-873591 Share on other sites More sharing options...
Vivid Lust Posted July 11, 2009 Author Share Posted July 11, 2009 Rows matched: 1 Changed: 1 Warnings: 0UPDATE settings SET ad1='dd' WHERE id=1 Quote Link to comment https://forums.phpfreaks.com/topic/165611-strange-query/#findComment-873593 Share on other sites More sharing options...
wildteen88 Posted July 11, 2009 Share Posted July 11, 2009 Yet the field still blank? You sure nothing else in your code is updating the field? Quote Link to comment https://forums.phpfreaks.com/topic/165611-strange-query/#findComment-873595 Share on other sites More sharing options...
Vivid Lust Posted July 11, 2009 Author Share Posted July 11, 2009 full code: <?php session_start(); $session = $_SESSION['member']; ?> <?php ini_set("display_errors","2"); ERROR_REPORTING(E_ALL); if (!isset($_SESSION['member'])){ header('location:http://www.xxxxxxxxxxx.com/'); die; } include('config.php'); $sql2 = "select * from user WHERE email = '$session' "; $result2 = mysql_query($sql2, $connect) or die(mysql_error()); while($row=mysql_fetch_assoc($result2)){ $admin = $row['admin']; } if($admin !== "yes"){ header('location:http://www.fxxxxxxxxxx/user.php'); die; }else{ include('top.php'); $ad1 = $_POST['ad1']; $ad2 = $_POST['ad2']; $artist = $_POST['artist']; $logo = $_POST['topLogo']; $sql5="UPDATE settings SET ad1='$ad1' WHERE id=1"; mysql_query($sql5) //execute query or die(mysql_error()); // if error show it echo mysql_info(); echo $sql5; //$sql6="UPDATE settings SET ad2='$ad2' WHERE id='1'"; // mysql_query($sql6, $connect) //execute query // or die(mysql_error()); // if error show it // // $sql7="UPDATE settings SET artist='$artist' WHERE id='1'"; // mysql_query($sql7, $connect) //execute query // or die(mysql_error()); // if error show it // $sql8="UPDATE settings SET logo='$logo' WHERE id='1'"; /// mysql_query($sql8, $connect) //execute query // or die(mysql_error()); // if error show it ?> <div id="signup"> <strong>Images Updated!</strong> <br /><br /> <center>[ <strong><a href="logout.php">logout</a> </strong>] [ <a href="changeimages.php"><strong>back to change images</strong></a> ] [ <a href="user.php"><strong>back to admin home</strong></a> ]</center> </div> <?php include('bott.php'); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/165611-strange-query/#findComment-873597 Share on other sites More sharing options...
Vivid Lust Posted July 11, 2009 Author Share Posted July 11, 2009 Is this code helpful? Do you want the code before? Quote Link to comment https://forums.phpfreaks.com/topic/165611-strange-query/#findComment-873615 Share on other sites More sharing options...
haku Posted July 11, 2009 Share Posted July 11, 2009 That really looks like it should be working. Some other things to check: * Are you sure you are looking at the right table? You should be looking at the table called 'settings'. * Are you sure you are looking at the right database? Maybe you have two inside your phpmyadmin, and you are looking at the wrong one? * Are you sure you are looking at the right server? Maybe you are making the changes on a local server, and looking through phpmyadmin at a remote server? All of these seem like stupid mistakes, but they are all mistakes I have made in the past myself I've wondered for hours why something that should be working wasn't, and it was one of the above. Quote Link to comment https://forums.phpfreaks.com/topic/165611-strange-query/#findComment-873624 Share on other sites More sharing options...
Vivid Lust Posted July 11, 2009 Author Share Posted July 11, 2009 Would it make any difference if I included the config.php file twice? a file containg db connection. Quote Link to comment https://forums.phpfreaks.com/topic/165611-strange-query/#findComment-873639 Share on other sites More sharing options...
Vivid Lust Posted July 11, 2009 Author Share Posted July 11, 2009 Anyone? I really need this sorted. Quote Link to comment https://forums.phpfreaks.com/topic/165611-strange-query/#findComment-873685 Share on other sites More sharing options...
haku Posted July 11, 2009 Share Posted July 11, 2009 Did you double check those three things I listed? Quote Link to comment https://forums.phpfreaks.com/topic/165611-strange-query/#findComment-873693 Share on other sites More sharing options...
Vivid Lust Posted July 11, 2009 Author Share Posted July 11, 2009 Yes I have and they are correct Quote Link to comment https://forums.phpfreaks.com/topic/165611-strange-query/#findComment-873697 Share on other sites More sharing options...
Vivid Lust Posted July 12, 2009 Author Share Posted July 12, 2009 This still isn't working ... help appreciated :S Quote Link to comment https://forums.phpfreaks.com/topic/165611-strange-query/#findComment-873980 Share on other sites More sharing options...
Vivid Lust Posted July 12, 2009 Author Share Posted July 12, 2009 Instead of using the previous query, I used this instead: UPDATE `settings` SET `ad1`='http://www.xxxxxxxxxxx.com/images/ad.jpg' WHERE `id`=1 And it works like this! However not like this: "UPDATE settings SET ad1='$ad1' WHERE id='1'" When echoing out the above query, it displays correctly as the query at the top here. Anyone know what's going on? Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/165611-strange-query/#findComment-873981 Share on other sites More sharing options...
wildteen88 Posted July 12, 2009 Share Posted July 12, 2009 If you remove $ad1 from query and replace it with a simple string like ad here does it update? Quote Link to comment https://forums.phpfreaks.com/topic/165611-strange-query/#findComment-873983 Share on other sites More sharing options...
Vivid Lust Posted July 12, 2009 Author Share Posted July 12, 2009 Yes, It updates.... :S Quote Link to comment https://forums.phpfreaks.com/topic/165611-strange-query/#findComment-873984 Share on other sites More sharing options...
wildteen88 Posted July 12, 2009 Share Posted July 12, 2009 Ok... Change your query to $sql5="UPDATE settings SET ad1='".mysql_real_escape_string($_POST['ad1'])."' WHERE id=1"; Quote Link to comment https://forums.phpfreaks.com/topic/165611-strange-query/#findComment-873985 Share on other sites More sharing options...
Vivid Lust Posted July 12, 2009 Author Share Posted July 12, 2009 Thanks soo much! It now works Quote Link to comment https://forums.phpfreaks.com/topic/165611-strange-query/#findComment-873986 Share on other sites More sharing options...
wildteen88 Posted July 12, 2009 Share Posted July 12, 2009 How weird. We got there in the end. FYI this code $sql5="UPDATE settings SET ad1='$ad1' WHERE id=1"; mysql_query($sql5) //execute query or die(mysql_error()); // if error show it echo mysql_info(); echo $sql5; //$sql6="UPDATE settings SET ad2='$ad2' WHERE id='1'"; // mysql_query($sql6, $connect) //execute query // or die(mysql_error()); // if error show it // // $sql7="UPDATE settings SET artist='$artist' WHERE id='1'"; // mysql_query($sql7, $connect) //execute query // or die(mysql_error()); // if error show it // $sql8="UPDATE settings SET logo='$logo' WHERE id='1'"; /// mysql_query($sql8, $connect) //execute query // or die(mysql_error()); // if error show it Can combined into just one query $sql5="UPDATE settings SET ad1='".mysql_real_escape_string($_POST['ad1'])."', ad2='".mysql_real_escape_string($_POST['ad2'])."', artist='".mysql_real_escape_string($_POST['artist'])."', logo='".mysql_real_escape_string($_POST['logo'])."' WHERE id=1"; Quote Link to comment https://forums.phpfreaks.com/topic/165611-strange-query/#findComment-873988 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.