Page 2 of 2

Re: PHP/MYSQL question please help!

Posted: Sun Mar 07, 2010 8:34 pm
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?

Re: PHP/MYSQL question please help!

Posted: Sun Mar 07, 2010 8:36 pm
by jraede
He means, you have <? twice, without closing the first one. This will cause an error.

Re: PHP/MYSQL question please help!

Posted: Sun Mar 07, 2010 9:51 pm
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");  
 
?> 
 
 

Re: PHP/MYSQL question please help!

Posted: Mon Mar 08, 2010 9:15 pm
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?....