Page 1 of 2

need some mysql help, on two codes, that is

Posted: Wed Oct 27, 2004 8:36 am
by Diod

Posted: Wed Oct 27, 2004 8:43 am
by CoderGoblin
What is the error ?

Run the SQL on the Database rather than PHP for quick testing/modification.

Posted: Wed Oct 27, 2004 8:49 am
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

Posted: Wed Oct 27, 2004 9:00 am
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.

Posted: Wed Oct 27, 2004 9:19 am
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

Posted: Wed Oct 27, 2004 10:16 am
by timvw

Code: Select all

$news_id = mysql_escape_string($_GET['news_id']);
$query = "D.ELETE FROM news WHERE id='$news_id'";

Posted: Wed Oct 27, 2004 10:17 am
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';

Posted: Wed Oct 27, 2004 10:20 am
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 ?.

Posted: Wed Oct 27, 2004 10:25 am
by timvw
for some odd reason.... it (as in phpdn forum) gives a application error then...

Posted: Wed Oct 27, 2004 10:26 am
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.

Posted: Wed Oct 27, 2004 10:50 am
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)

Posted: Thu Oct 28, 2004 9:21 am
by Diod
bump

Posted: Fri Oct 29, 2004 10:23 am
by Diod
bump again

Posted: Fri Oct 29, 2004 11:38 am
by Diod
Got the edit thing to work..

still cant figure out the delete page

Posted: Fri Oct 29, 2004 11:42 am
by andre_c
like kettle_drum asked a few posts ago, do you have permission to use the DELETE statment?