Jump to content

strange query


Vivid Lust

Recommended Posts

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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');

}

?>

Link to comment
Share on other sites

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  :D I've wondered for hours why something that should be working wasn't, and it was one of the above.

Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

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";

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.