PHP/MYSQL question please help!
Moderator: General Moderators
-
powaytitan
- Forum Newbie
- Posts: 10
- Joined: Sat Mar 06, 2010 10:43 pm
Re: PHP/MYSQL question please help!
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!
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!
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!
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?....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"); ?>