PHP/MYSQL question please help!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

powaytitan
Forum Newbie
Posts: 10
Joined: Sat Mar 06, 2010 10:43 pm

Re: PHP/MYSQL question please help!

Post by powaytitan »

I closed it on the bottom of the script. Am I suppose to close it after the database connection? MYSQL is not suppose to be within the php script?
jraede
Forum Contributor
Posts: 254
Joined: Tue Feb 16, 2010 5:39 pm

Re: PHP/MYSQL question please help!

Post by jraede »

He means, you have <? twice, without closing the first one. This will cause an error.
powaytitan
Forum Newbie
Posts: 10
Joined: Sat Mar 06, 2010 10:43 pm

Re: PHP/MYSQL question please help!

Post by powaytitan »

here is my current code it still does not work....

Code: Select all

 
<?  
$dbhost = 'localhost';
$dbuser = 'pm0663';
$dbpass = 'say76poj';
 
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');
 
$dbname = 'pm0663';
 
mysql_select_db($dbname);
$id = $_GET['id'];
$name = $_GET['name'];
$desccription = $_GET['description'];
$weight = $_GET['weight'];
$price = $_GET['price'];
$qoh = $_GET['qoh'];
    
    $sql = "UPDATE product SET name='$name',  
        description='$description', 
        price='$price', 
        weight ='$weight', 
        qoh= '$qoh'  
        WHERE productnumber='$id'" ;  
$result = mysql_query($sql) or die (mysql_error());  
header("location:edit.php");  
 
?> 
 
 
mikosiko
Forum Regular
Posts: 757
Joined: Wed Jan 13, 2010 7:22 pm

Re: PHP/MYSQL question please help!

Post by mikosiko »

powaytitan wrote:here is my current code it still does not work....

Code: Select all

 
<?  
$dbhost = 'localhost';
$dbuser = 'pm0663';
$dbpass = 'say76poj';
 
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');
 
$dbname = 'pm0663';
 
mysql_select_db($dbname);
$id = $_GET['id'];
$name = $_GET['name'];
[color=#FF0000]$desccription[/color] = $_GET['description'];  << IN RED... IS NOT EQUAL TO...
$weight = $_GET['weight'];
$price = $_GET['price'];
$qoh = $_GET['qoh'];
    
    $sql = "UPDATE product SET name='$name',  
        description=[color=#FF0000]'$description', [/color]  >>> IN RED.... TO THIS
        price='$price', 
        weight ='$weight', 
        qoh= '$qoh'  
        WHERE productnumber='$id'" ;  
$result = mysql_query($sql) or die (mysql_error());  
header("location:edit.php");  
 
?> 
 
 
Other than the error ... could you please refresh the exact code that you have and describe again what is happening or not happening now?.... are you getting any error?.... have you tried to echo the variables before your update sentence to see if they have the expected values?....
Post Reply