Ask a Question related to Dreamweaver AppDev, Design and Development.
-
joy #1
PHP Update basics
Hello,
I am using the below code to update a database field:
<?php
require_once('Connections/ConModelz.php');
mysql_select_db($database_ConModelz, $ConModelz);
$str="UPDATE pictures SET Showcase = 0";
mysql_query($str) or die("Query failed:<br>".mysql_error());
if ($_SERVER['REQUEST_METHOD']=="POST"){
if (is_array($_POST['selected'])){
$str=$_POST['selected']
$str="UPDATE pictures SET Showcase = 1 WHERE Id IN ($str)";
mysql_query($str) or die("Query failed:<br>".mysql_error());
header ("Location: pics.php");
} else {
echo "Please Hit the back button and check atleast one Radio button. ";
}
}
?>
I need to update a field based on ID and the username.
I modified the line:
$str="UPDATE pictures SET Showcase = 1 WHERE Id IN ($str)";
to
$str="UPDATE pictures SET Showcase = 1 WHERE Username = $name, Id = ($str)";
and also added the code :
session_start();
if(isset($HTTP_SESSION_VARS['MM_Username'])){
$name=$HTTP_SESSION_VARS['MM_Username'];
}
on the top of the page, which is off course no working.
Can anybody please tell me what i am doing wrong and what should i take care
of while coding such scripts?
I thank you for any advices.
joy Guest
-
need basics of FMS
Hi guys, Im new to FMS.so,Can anyone tell me how to install the Flash media server 2 and how to run a sample application in it.and how to build a... -
SSL Basics
Hi there, I'm building a new site and have just dived into SSL - I'm totally lost. My provider has given me two directories to work with. ... -
3D basics
hello i was wondering if someone could tell me about 3D in director 8.5, which i have only recently got. I know you can make 3D text and i saw a... -
[PHP] some html basics please
Chris Shiflett wrote: I knew that ./ was the current directory on a *nix system, but a browser will respect that also? -
Just the basics please...
I'm new to Elements and really not getting much of use in the help or tutorials. The state of A's technical writing is low. I am VERY familiar with... -
joy #2
Re: PHP Update basics
Just a small correction:
the line:
$str=$_POST['selected']
is actually:
$str=join(",",$_POST['selected']);
"joy" <joy@lycos.com> schrieb im Newsbeitrag
news:d2olse$68f$1@forums.macromedia.com...> Hello,
> I am using the below code to update a database field:
>
> <?php
> require_once('Connections/ConModelz.php');
> mysql_select_db($database_ConModelz, $ConModelz);
>
> $str="UPDATE pictures SET Showcase = 0";
> mysql_query($str) or die("Query failed:<br>".mysql_error());
>
>
> if ($_SERVER['REQUEST_METHOD']=="POST"){
> if (is_array($_POST['selected'])){
> $str=$_POST['selected']
> $str="UPDATE pictures SET Showcase = 1 WHERE Id IN ($str)";
> mysql_query($str) or die("Query failed:<br>".mysql_error());
> header ("Location: pics.php");
> } else {
> echo "Please Hit the back button and check atleast one Radio button. ";
> }
> }
> ?>
> I need to update a field based on ID and the username.
> I modified the line:
>
> $str="UPDATE pictures SET Showcase = 1 WHERE Id IN ($str)";
> to
> $str="UPDATE pictures SET Showcase = 1 WHERE Username = $name, Id =
> ($str)";
>
> and also added the code :
> session_start();
> if(isset($HTTP_SESSION_VARS['MM_Username'])){
> $name=$HTTP_SESSION_VARS['MM_Username'];
> }
>
> on the top of the page, which is off course no working.
> Can anybody please tell me what i am doing wrong and what should i take
> care of while coding such scripts?
> I thank you for any advices.
>
>
>
joy Guest
-
gareth #3
Re: PHP Update basics
Your WHERE clause is wrong:
$str="UPDATE pictures SET Showcase = 1 WHERE Username = $name, Id = ($str)";
Should be:
$str="UPDATE pictures SET Showcase = 1 WHERE Username = '$name' AND Id =
'$str' ";
--
Gareth - TMM Dreamweaver
[url]http://www.dreamweavermxsupport.com/[/url]
[url]http://www.garethdp.com/[/url]
PHP Login Suite V2 - 34 Server Behaviors to build a complete Login system.
[url]http://www.phploginsuite.co.uk/[/url]
Co-Author: Dreamweaver MX: Instant Troubleshooter - Apress
Co-Author: Practical Intranet Development - Apress
Co-Author: Dreamweaver MX: Advanced PHP Web Development - Apress
Co-Author: Dreamweaver MX: PHP Web Development - Wrox
gareth Guest
-
Michael Fesser #4
Re: PHP Update basics
.oO(joy)
header("Location: http://$_SERVER[HTTP_HOST]/pics.php");> header ("Location: pics.php");
$str = ">I need to update a field based on ID and the username.
>I modified the line:
>
> $str="UPDATE pictures SET Showcase = 1 WHERE Id IN ($str)";
>to
>$str="UPDATE pictures SET Showcase = 1 WHERE Username = $name, Id = ($str)";
UPDATE pictures
SET Showcase = 1
WHERE Username = '$name'
AND Id = $str";
Use the $_SESSION array instead of the old $HTTP_*.>and also added the code :
>session_start();
>if(isset($HTTP_SESSION_VARS['MM_Username'])){
> $name=$HTTP_SESSION_VARS['MM_Username'];
>}
You should always post the error messages you received from PHP or>on the top of the page, which is off course no working.
MySQL, just saying "doesn't work" isn't of much help.
Micha
Michael Fesser Guest



Reply With Quote

