need some mysql help, on two codes, that is

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

User avatar
Diod
Forum Commoner
Posts: 52
Joined: Tue Oct 19, 2004 9:07 am

need some mysql help, on two codes, that is

Post by Diod »

User avatar
CoderGoblin
DevNet Resident
Posts: 1425
Joined: Tue Mar 16, 2004 10:03 am
Location: Aachen, Germany

Post by CoderGoblin »

What is the error ?

Run the SQL on the Database rather than PHP for quick testing/modification.
User avatar
Diod
Forum Commoner
Posts: 52
Joined: Tue Oct 19, 2004 9:07 am

Post by Diod »

the DELETE query should work, it does in phpmyadmin... so its prolly a php isue

the EDIT query gives me SQL-query:

Code: Select all

UPDATE news SET text ='test', author ='test1', email ='test2'', title ='test1' WHERE ID = 1
in phpmyadmin.. but doesnt change anything
kettle_drum
DevNet Resident
Posts: 1150
Joined: Sun Jul 20, 2003 9:25 pm
Location: West Yorkshire, England

Post by kettle_drum »

Well that query has too many ' on the email variable - so thats likely the cause - and the ID variable doesnt have any single quotes around it. And the same is true for your delete query.

Always put the sql data in single quotes so you can see what your adding.
User avatar
Diod
Forum Commoner
Posts: 52
Joined: Tue Oct 19, 2004 9:07 am

Post by Diod »

Code: Select all

$news_id = $_GET['id'];
	$query = "D.ELETE FROM news WHERE ID = '" . $news_id ."'";
NOTE: the D.ELETE = DELETE cause i cant post it otherwise

is what i now have, but it still isnt working
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

Code: Select all

$news_id = mysql_escape_string($_GET['news_id']);
$query = "D.ELETE FROM news WHERE id='$news_id'";
kettle_drum
DevNet Resident
Posts: 1150
Joined: Sun Jul 20, 2003 9:25 pm
Location: West Yorkshire, England

Post by kettle_drum »

and i assume that there is a table called 'news' in lower case and that has a field called 'ID' in upper case and that the $news_id variable references a valid field in that table.

If that is still is all correct still, then do you have permission to use the DELETE statment? i.e. does the username you use to log into the mySQL server have that command in user table?

Code: Select all

use mysql;
SELECT Delete_priv FROM user WHERE User = 'My User Name';
User avatar
CoderGoblin
DevNet Resident
Posts: 1425
Joined: Tue Mar 16, 2004 10:03 am
Location: Aachen, Germany

Post by CoderGoblin »

Diod wrote: NOTE: the D.ELETE = DELETE cause i cant post it otherwise
Why can't you POST it ? Have you tried urlencode and decode or am I missing something ?.
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

for some odd reason.... it (as in phpdn forum) gives a application error then...
kettle_drum
DevNet Resident
Posts: 1150
Joined: Sun Jul 20, 2003 9:25 pm
Location: West Yorkshire, England

Post by kettle_drum »

The forum doesnt let let you i assume, as it probably beleives that you are trying to inject it into a query and delete something from the sites database.
User avatar
Diod
Forum Commoner
Posts: 52
Joined: Tue Oct 19, 2004 9:07 am

Post by Diod »

thx for trying timvw, but your code isnt working....

ID = row name in mysql
news = row name in mysql
$news_id = $_GET['id'] (and there is a ?id=.... in my url)
User avatar
Diod
Forum Commoner
Posts: 52
Joined: Tue Oct 19, 2004 9:07 am

Post by Diod »

bump
User avatar
Diod
Forum Commoner
Posts: 52
Joined: Tue Oct 19, 2004 9:07 am

Post by Diod »

bump again
User avatar
Diod
Forum Commoner
Posts: 52
Joined: Tue Oct 19, 2004 9:07 am

Post by Diod »

Got the edit thing to work..

still cant figure out the delete page
User avatar
andre_c
Forum Contributor
Posts: 412
Joined: Sun Feb 29, 2004 6:49 pm
Location: Salt Lake City, Utah

Post by andre_c »

like kettle_drum asked a few posts ago, do you have permission to use the DELETE statment?
Post Reply