By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,374 Members | 1,768 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,374 IT Pros & Developers. It's quick & easy.

Deleting a Record.

P: n/a
Rob
Thanks for the Help on the other problems...all resolved.
One last (hopefullly) problem I can't seem to get around for this
program...why isn't this deleting the row i want? It does nothing. Now error
messages either. HELP!

$link = mysql_connect("localhost");
if(! $link)
die("Could not connect to MySQL");

$database = "PC_Store";
mysql_select_db($database)
or die ("could not open $database: ".mysql_error() );

$result = mysql_query("DELETE FROM inventorydata VALUES('$ProductID')");

The $ProductID variable is brought in from a menu choice on a diffrent page,
it is also the primary of the table...so it should delete the whole row
right?

Thanks again,
Rob
Jul 17 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
Hi Rob!

On Sun, 23 Nov 2003 19:06:41 -0700, "Rob" <ta******@yahoo.com> wrote:
Thanks for the Help on the other problems...all resolved.
One last (hopefullly) problem I can't seem to get around for this
program...why isn't this deleting the row i want? It does nothing. Now error
messages either. HELP!

$link = mysql_connect("localhost");
if(! $link)
die("Could not connect to MySQL");

$database = "PC_Store";
mysql_select_db($database)
or die ("could not open $database: ".mysql_error() );

$result = mysql_query("DELETE FROM inventorydata VALUES('$ProductID')");

The $ProductID variable is brought in from a menu choice on a diffrent page,
it is also the primary of the table...so it should delete the whole row
right?


Try

"delete from inventorydata where field = '".$ProductID."'"

Have a look at www.mysql.com for sql syntax

HTH, Jochen
--
Jochen Daum - CANS Ltd.
PHP DB Edit Toolkit -- PHP scripts for building
database editing interfaces.
http://sourceforge.net/projects/phpdbedittk/
Jul 17 '05 #2

P: n/a
Rob
Still nothing....
Not even an error message...

Thanks,
Rob
"Jochen Daum" <jo*********@cans.co.nz> wrote in message
news:86********************************@4ax.com...
Hi Rob!

On Sun, 23 Nov 2003 19:06:41 -0700, "Rob" <ta******@yahoo.com> wrote:
Thanks for the Help on the other problems...all resolved.
One last (hopefullly) problem I can't seem to get around for this
program...why isn't this deleting the row i want? It does nothing. Now errormessages either. HELP!

$link = mysql_connect("localhost");
if(! $link)
die("Could not connect to MySQL");

$database = "PC_Store";
mysql_select_db($database)
or die ("could not open $database: ".mysql_error() );

$result = mysql_query("DELETE FROM inventorydata VALUES('$ProductID')");

The $ProductID variable is brought in from a menu choice on a diffrent page,it is also the primary of the table...so it should delete the whole row
right?


Try

"delete from inventorydata where field = '".$ProductID."'"

Have a look at www.mysql.com for sql syntax

HTH, Jochen
--
Jochen Daum - CANS Ltd.
PHP DB Edit Toolkit -- PHP scripts for building
database editing interfaces.
http://sourceforge.net/projects/phpdbedittk/

Jul 17 '05 #3

P: n/a
Hi!

Still nothing....
Not even an error message...

Can you do:

- error_reporting(E_ALL);

$sql = "delete from ....."
print $sql;

$result = mysql_query("DELETE FROM inventorydata
VALUES('$ProductID')");

var_dump($result);
var_dump(mysql_error());
var_dump(mysql_rows_affected());

HTH, Jochen
Thanks,
Rob
"Jochen Daum" <jo*********@cans.co.nz> wrote in message
news:86********************************@4ax.com.. .
Hi Rob!

On Sun, 23 Nov 2003 19:06:41 -0700, "Rob" <ta******@yahoo.com> wrote:
>Thanks for the Help on the other problems...all resolved.
>One last (hopefullly) problem I can't seem to get around for this
>program...why isn't this deleting the row i want? It does nothing. Nowerror >messages either. HELP!
>
>$link = mysql_connect("localhost");
>if(! $link)
> die("Could not connect to MySQL");
>
>$database = "PC_Store";
>mysql_select_db($database)
> or die ("could not open $database: ".mysql_error() );
>
>$result = mysql_query("DELETE FROM inventorydata VALUES('$ProductID')");
>
>The $ProductID variable is brought in from a menu choice on a diffrentpage, >it is also the primary of the table...so it should delete the whole row
>right?


Try

"delete from inventorydata where field = '".$ProductID."'"

Have a look at www.mysql.com for sql syntax

HTH, Jochen
--
Jochen Daum - CANS Ltd.
PHP DB Edit Toolkit -- PHP scripts for building
database editing interfaces.
http://sourceforge.net/projects/phpdbedittk/


--
Jochen Daum - CANS Ltd.
PHP DB Edit Toolkit -- PHP scripts for building
database editing interfaces.
http://sourceforge.net/projects/phpdbedittk/
Jul 17 '05 #4

P: n/a
Rob
Hi Jochen,

Here's the exact code I ran

</HEAD>
<BODY BGCOLOR=RED>
<?php

$link = mysql_connect("localhost");
if(! $link)
die("Could not connect to MySQL");

$database = "PC_Store";
mysql_select_db($database)
or die ("could not open $database: ".mysql_error() );

- error_reporting(E_ALL);

$sql = "DELETE FROM inventorydata VALUES('$ProductID')";

print $sql;

$result = mysql_query("DELETE FROM inventorydata

VALUES('$ProductID')");

var_dump($result);
var_dump(mysql_error());
var_dump(mysql_rows_affected());
?>
<BR>
Entry Deleted
</FORM>
<FORM METHOD=POST ACTION = "PC_Store1.php">
<INPUT TYPE = "submit" VALUE ="Return To Main Menu">
</FORM>

And here is the Exact output...

DELETE FROM inventorydata VALUES('40')bool(false) string(66) "You have an
error in your SQL syntax near 'VALUES('40')' at line 1"
Fatal error: Call to undefined function: mysql_rows_affected() in
c:\apache\htdocs\pcsdelpexein.php on line 23

I'm not sure what the syntax error is.... 40 is the product Id for the row I
want to delete.
The Fatal error is way beyond me....I appreciate your help!

Rob
Jul 17 '05 #5

P: n/a
$sql = 'DELETE FROM inventorydata WHERE productid = '. $ProductID;

This is basic SQL!
Rob wrote:
Hi Jochen,

Here's the exact code I ran

</HEAD>
<BODY BGCOLOR=RED>
<?php

$link = mysql_connect("localhost");
if(! $link)
die("Could not connect to MySQL");

$database = "PC_Store";
mysql_select_db($database)
or die ("could not open $database: ".mysql_error() );

- error_reporting(E_ALL);

$sql = "DELETE FROM inventorydata VALUES('$ProductID')";

print $sql;

$result = mysql_query("DELETE FROM inventorydata

VALUES('$ProductID')");

var_dump($result);
var_dump(mysql_error());
var_dump(mysql_rows_affected());
?>
<BR>
Entry Deleted
</FORM>
<FORM METHOD=POST ACTION = "PC_Store1.php">
<INPUT TYPE = "submit" VALUE ="Return To Main Menu">
</FORM>

And here is the Exact output...

DELETE FROM inventorydata VALUES('40')bool(false) string(66) "You have an
error in your SQL syntax near 'VALUES('40')' at line 1"
Fatal error: Call to undefined function: mysql_rows_affected() in
c:\apache\htdocs\pcsdelpexein.php on line 23

I'm not sure what the syntax error is.... 40 is the product Id for the row I
want to delete.
The Fatal error is way beyond me....I appreciate your help!

Rob


Jul 17 '05 #6

P: n/a
Rob

This is basic SQL!


LOL..that would explain that!

Thanks for the help gents...but I got it!!!!!

Thank god for http://sqlzoo.net/howto/mysqltip903137.htm

Here's the line I ended up using...simple eh?

$result = mysql_query("DELETE FROM inventorydata Where
ProductID=$ProductID");

It's always the little things.....

Rob
Jul 17 '05 #7

P: n/a
I noticed that Message-ID: <xc********************@comcast.com> from Rob
contained the following:
$result = mysql_query("DELETE FROM inventorydata Where
ProductID=$ProductID");

It's always the little things.....


It is. Remember, never, ever delete without a where clause (very easy
to delete the whole lot) Also do not delete from a simple link, other
wise spiders may delete your database for you.

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.