Jump to content


Photo

Passing value / SQL


  • Please log in to reply
4 replies to this topic

#1 christo

christo
  • Members
  • PipPipPip
  • Advanced Member
  • 32 posts

Posted 07 May 2006 - 01:45 PM

This time from scrip1.php i need to press a button and it will send a value (number) to another script2.php that will erase a row from the DB

so at script1.php i have :
echo "    </table><br>
<td><form method=post action=upd_obj.php>
<input type=submit value='Modifier une annonce '> N°:
<input type=text name=objid size=1></form></td>";

//the value i need to sent is objid...a box next to N

and at script2.php :
$objid = $HTTP_POST_VARS['objid']; // in order to bring the value submited by post...at thisline a get the Notice too :(

//conncetion with DB

$query="DELETE * FROM  object WHERE objid=$objid";
$resultat=mysql_query($query);

The message i get...
[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Notice: Undefined index: objid in c:\foreign\easyphp1-8\www\agence\test\del_obj.php on line 21[/quote]

what have i done wrong, any ideas ???

Christos

#2 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,021 posts

Posted 07 May 2006 - 02:26 PM

See

[a href=\"http://www.phpfreaks.com/forums/index.php?act=ST&f=1&t=92933&hl=&view=findpost&p=371960\" target=\"_blank\"]http://www.phpfreaks.com/forums/index.php?...ndpost&p=371960[/a]
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#3 christo

christo
  • Members
  • PipPipPip
  • Advanced Member
  • 32 posts

Posted 07 May 2006 - 03:22 PM

hmm i don't understand your point !
Myself i send data via post and it should work normally, do you mean i should try $_REQUEST (i tried it) the isset thing is no use for me...or maybe i don't see what you're trying to explaing me :( Can you be more clear ?

christos

#4 christo

christo
  • Members
  • PipPipPip
  • Advanced Member
  • 32 posts

Posted 07 May 2006 - 04:07 PM

K problem sorted but there is another one :)

I manage to pass the value but it won't delete the row from the DB...
[code=auto:0]$objid = $HTTP_POST_VARS['objid'];

echo"objid=$objid";

//connection

$db_conx = mysql_connect($host,$user,$pass) or print("error de connection mysql");
mysql_select_db($base, $db_conx) or print("error connection base");


$query="DELETE * FROM object WHERE objid=$objid";
$resultat=mysql_query($query);

if ($resultat) {
echo"deleted !";
}
else {
echo" problem !";
}

My request seems ok,right?

#5 christo

christo
  • Members
  • PipPipPip
  • Advanced Member
  • 32 posts

Posted 07 May 2006 - 04:51 PM

sorted ,no need for * at the request ...




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users