MasksMaster Posted November 15, 2006 Share Posted November 15, 2006 Hello, Everybody!I'm new to PHP/MySQL. For some strange reason I can get the UPDATE part to work. I even tried checking if $other, $ud_id, $ud_received were submitted and they were and show when I use echo.<?php $other=$_COOKIE['other'];$ud_received=$_POST['ud_received'];$ud_id=$_POST['ud_id'];echo $other;echo $ud_received." "."ud_received";echo $ud_id." "."ud_id"; //this part I replace with needed values$user="username";$password="password";$database="database";//This is where my problem ismysql_connect(localhost,$user,$password);$query="UPDATE $other SET received='$ud_received' WHERE id='$ud_id'";mysql_query($query);mysql_close();echo "Record Updated";?> Quote Link to comment Share on other sites More sharing options...
trq Posted November 15, 2006 Share Posted November 15, 2006 Your rconnection would be failing because you don't have a constant defined called localhost. Try...[code=php:0]mysql_connect("localhost",$user,$password);[/code]notice the word localhost is a string and thus needs to be within quotes.You really should also check that your query worked before stating a success message.[code=php:0]mysql_connect(localhost,$user,$password);$query="UPDATE $other SET received='$ud_received' WHERE id='$ud_id'";if (mysql_query($query)) { echo "Record Updated";} else { // query failed. echo mysql_error();}mysql_close();[/code] Quote Link to comment Share on other sites More sharing options...
MasksMaster Posted November 15, 2006 Author Share Posted November 15, 2006 Thank you SO much, [b]thorpe[/b]!As soon as I put those couple of lines that check the query I got a reply that... I forgot to connect to a database. ;D I did and it all worked! Thank you again Very much! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.