PHP to mysql changes

I’m struggling with this and need a little help. What I want to be able to do is have an text box where I insert a file name for example “myphoto.jpg” and that then replaces the “@@” at the end of the query below and updates the database, this will be once done daily.

Here is the file.


$chandle = mysql_connect(“localhost”, $dbuser, $dbpass)
or die(“Connection Failure to Database”);
echo “Connected to database server
mysql_select_db($dbname, $chandle) or die ($dbname . " Database not found." . $dbuser);

$sql = 'update ‘.$CONFIG[‘TABLE_PICTURES’].’ SET potd = 2, WHERE potd = 1 AND SET potd = 1 WHERE filename = @@;



The sql is more than likely incorrect, but the field “potd” will be set as “1” and will need to be changed to “2”, then the filename field should dictate which row the “potd” field needs to be set at “1”

Can you help me or do you need more information to facillitate this request?

Many thanks in advance!


You can just use the variable holding the picture name if it’s available when creating/running the query:

$sql = 'update '.$CONFIG['TABLE_PICTURES'].' SET `potd` = 2, WHERE `potd` = 1 AND SET `potd` = 1 WHERE `filename` = '.$picturename;
Sponsor our Newsletter | Privacy Policy | Terms of Service