Gruzin Posted August 30, 2006 Share Posted August 30, 2006 hi guys, I want to display the result form db and add it some Edit and Delete function, here is my effort but think I'am not on a correct way. Your ideas will be very appreciated.P.S I won't post the Reslut script, it works ok, here is the delete function, which of course doesn't work...[code]<?php$con = mysql_connect("localhost","user","pass"); //connect to dbif(!$con){ die('Error:'.mysql_error()); }mysql_select_db("user", $con); //select db$query = "SELECT * FROM link_manager WHERE id ORDER BY id";$result = mysql_query($query) or die("Error: " . mysql_error());while($row = mysql_fetch_array($result))$id = $row['id'];$query2 = "DELETE * FROM link_manager WHERE id = $id";$result2 = mysql_query($query2) or die("Error: " . mysql_error());header( 'Location: http://www.mysite.net/links/') ;mysql_close($con);?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/19138-problem-with-phpmysql/ Share on other sites More sharing options...
ToonMariner Posted August 30, 2006 Share Posted August 30, 2006 where id = what?????that is your problem! Quote Link to comment https://forums.phpfreaks.com/topic/19138-problem-with-phpmysql/#findComment-82799 Share on other sites More sharing options...
ober Posted August 30, 2006 Share Posted August 30, 2006 To be more clear, ToonMariner meant this line:$query = "SELECT * FROM link_manager WHERE id <you are missing an ID value> ORDER BY id"; Quote Link to comment https://forums.phpfreaks.com/topic/19138-problem-with-phpmysql/#findComment-82800 Share on other sites More sharing options...
Gruzin Posted August 30, 2006 Author Share Posted August 30, 2006 yea, I know but I can't figure it out..I want this to be dinamic, I mean when I add a new record to db, it should add Edit And Delete link (function) automatically. Quote Link to comment https://forums.phpfreaks.com/topic/19138-problem-with-phpmysql/#findComment-82803 Share on other sites More sharing options...
Gruzin Posted August 30, 2006 Author Share Posted August 30, 2006 here is the error:Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '* FROM link_manager WHERE id = 47' at line 1 Quote Link to comment https://forums.phpfreaks.com/topic/19138-problem-with-phpmysql/#findComment-82807 Share on other sites More sharing options...
Gruzin Posted August 30, 2006 Author Share Posted August 30, 2006 Think I need a Guru help... Quote Link to comment https://forums.phpfreaks.com/topic/19138-problem-with-phpmysql/#findComment-82826 Share on other sites More sharing options...
ToonMariner Posted August 30, 2006 Share Posted August 30, 2006 echo your query to the screen and comment out the execution of the query - then check it in phpmyadmin - it may point out something more.This will probably be a case of some single or double quote issue... Quote Link to comment https://forums.phpfreaks.com/topic/19138-problem-with-phpmysql/#findComment-82830 Share on other sites More sharing options...
Gruzin Posted August 30, 2006 Author Share Posted August 30, 2006 I've tested this and works ok:$[code]query = "SELECT * FROM link_manager WHERE id ORDER BY id";$result = mysql_query($query) or die("Error: " . mysql_error());while($row = mysql_fetch_array($result))echo $row['id'];[/code] Quote Link to comment https://forums.phpfreaks.com/topic/19138-problem-with-phpmysql/#findComment-82833 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.