Sponsored by NuSphere - PHP Software for PHP Application Developers - On Sale This Week for $100



Go Back   PHP-Editors > Linux, Apache, MySQL > MySQL Help

MySQL Help Post any question relating to MySQL here and hopefully someone can help

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 2004-06-24, 10:56 PM
chrometix
Guest
 
Posts: n/a
Default

ok, ive spent who knows how many hours trying to figure this out, but this script just wont update my database, it seems to "skip over" the red part:

<form action="<? echo $PHP_SELF ?>" method="post">

<?
mysql_connect("localhost","****","****"); //enter name and password
mysql_select_db("****"); //select the database
if(!$cmd)
{
$result = mysql_query("select * from aff"); //replace news with your table name
while($r=mysql_fetch_array($result))
{
$name=$r["name"]; // name
$id=$r["ID"]; //id
?>
<INPUT TYPE="RADIO" NAME="id" VALUE="<?php echo $id;?>"><? echo $id;?> <? echo $name ?>

<? } ?>
<input type="submit" name="cmd" value="edit"></form>
<? }




if($cmd=="edit")
{
if (!$submit)
{
mysql_connect("localhost","****","****"); //enter name and password
mysql_select_db("****"); //select the database
$sql = "SELECT * FROM aff WHERE ID=$id";

$result = mysql_query($sql);
$myrow = mysql_fetch_array($result);
?>
<form method="post" action="<? echo $PHP_SELF ?>">
<input type="hidden" name="shortname" value="<?php echo $myrow["short"] ?>">
<input type="hidden" name="id" value="<?php echo $myrow["ID"] ?>"> <?php echo "Affiliate number $id"; ?>

Site Name:<INPUT TYPE="TEXT" NAME="sname" VALUE="<?php echo $myrow["name"] ?>" SIZE=30>

Site URL:<INPUT TYPE="TEXT" NAME="surl" VALUE="<?php echo $myrow["url"] ?>" SIZE=30>

Site Short Name:<INPUT TYPE="TEXT" NAME="shortname" VALUE="<?php echo $myrow["short"] ?>" SIZE=30>

Button URL:<INPUT TYPE="TEXT" NAME="buttonurl" VALUE="<?php echo $myrow["button"] ?>" SIZE=30>

IN:<INPUT TYPE="TEXT" NAME="inn" VALUE="<?php echo $myrow["in"] ?>" SIZE=30>

OUT:<INPUT TYPE="TEXT" NAME="outt" VALUE="<?php echo $myrow["out"] ?>" SIZE=30>

<input type="hidden" name="cmd" value="edit">
<input type="Submit" name="submit" value="Post Comment">
</form>
<? }




if($submit)
{
mysql_connect("localhost","*****","*****"); //enter name and password
mysql_select_db("*****"); //select the database
$sql2 = "UPDATE aff SET name='$sname',url='$url',short='$shortname', button='$buttonurl',in='$inn',out='$outt' WHERE ID=$id";

$result = mysql_query($sql2);

echo "Thank you! Information updated.";
}
}
?>


i've tried every combo of quotations, commas, everything, but it just skips over that part. any suggestions?
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 2004-06-24, 11:17 PM
Xnuiem's Avatar
Senior Member
 
Join Date: May 2004
Location: DFW, Texas
Posts: 1,104
Xnuiem will become famous soon enough
Send a message via Yahoo to Xnuiem
Default

Try this to get the error on the query:

$result = mysql_query($sql2) or die(mysql_error() . "
\r\n" . $sql2);
__________________
I rarely give code examples.
No, I have never used IIS or Windows of any kind as a web server. Get a real OS!
Please don't PM me, I won't respond.
Reply With Quote
  #3 (permalink)  
Old 2004-06-25, 04:33 PM
Moderator
 
Join Date: May 2004
Location: Portugal
Posts: 143
gesf is an unknown quantity at this point
Send a message via ICQ to gesf Send a message via MSN to gesf Send a message via Skype™ to gesf
Default

And btw, i suggest you to always use php's $_GET/$_POST superglobal arrays !
__________________
Best Regards,
Gonçalo "GesF" Fontoura

Website : gesf.org
Reply With Quote
Must read Review for Serious PHP Developers


NuSphere PhpED 5.5 : The Staff of php-editors.com recently spent a few days working with NuSphere PhpED 5.5 (a popular PHP IDE) and NuCoder 2.0 (a PHP Encoding Utility), read up on all the details.

Sponsored Links
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 11:33 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.1.0
© Copyright 2003-2008 www.php-editors.com. The ultimate PHP Editor and PHP IDE site.