anarchoi Posted March 27, 2008 Share Posted March 27, 2008 ok basically i have this very simple script that displays all rows from a table where "VALIDE" is set to "0", meaning the entry is waiting for validation could anyone help me to modify this code so when I click on the result (title) it modify the current entry to set "VALIDE" to 1 ? thanks a lot! here's the code: mysql_connect($server, $user, $password) or die(mysql_error()); mysql_select_db($database) or die(mysql_error()); // Query the Database $query = "SELECT * from news2"; $res = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($res)) { $validation = $row["valide"]; if ( $validation == 0 ) { echo "<a href=validate_me>"; echo " " . $row["title"] . " "; echo "</a>"; echo "<br>"; } } Link to comment https://forums.phpfreaks.com/topic/98114-big-newbie-question/ Share on other sites More sharing options...
ansarka Posted March 27, 2008 Share Posted March 27, 2008 connection.php <?php $server='localhost'; $user='user'; $password='pwd'; $database='db'; mysql_connect($server, $user, $password) or die(mysql_error()); mysql_select_db($database) or die(mysql_error()); ?> list.php <?php include('connection.php'); // Query the Database $query = "SELECT * from news2 where VALIDE='0'"; $res = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($res)) { echo "<a href=validate.php?title='.$row[title].'>"; echo " " . $row["title"] . " "; echo "[/url]"; echo " "; } ?> validate.php <?php include('connection.php'); // Query the Database $query = "update news2 set VALIDE='1' where title=$title"; $res = mysql_query($query) or die(mysql_error()); header("Location: list.php"); ?> Link to comment https://forums.phpfreaks.com/topic/98114-big-newbie-question/#findComment-501933 Share on other sites More sharing options...
anarchoi Posted March 27, 2008 Author Share Posted March 27, 2008 hmmm i get this 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 '' at line 1 i also tryed using this: <? if(isset($_GET['groupe'])) { $band = $_GET['groupe']; } else { $band = ""; } // DATABASE $server = "localhost"; $user = "anarchoi1"; $password = "*******"; $database = "anarchoi1_phpb1"; mysql_connect($server, $user, $password) or die(mysql_error()); mysql_select_db($database) or die(mysql_error()); $query = "update news2 set VALIDE=1 where title = $band"; $res = mysql_query($query) or die(mysql_error()); ?> but i get a similar error Link to comment https://forums.phpfreaks.com/topic/98114-big-newbie-question/#findComment-501934 Share on other sites More sharing options...
ansarka Posted March 27, 2008 Share Posted March 27, 2008 try to print the query usin g echo $query; do you have any value on $band Link to comment https://forums.phpfreaks.com/topic/98114-big-newbie-question/#findComment-501936 Share on other sites More sharing options...
ansarka Posted March 27, 2008 Share Posted March 27, 2008 please change validate.php to <?php include('connection.php'); $title=$_GET['title']; // Query the Database $query = "update news2 set VALIDE='1' where title='$title'"; $res = mysql_query($query) or die(mysql_error()); header("Location: list.php"); ?> Link to comment https://forums.phpfreaks.com/topic/98114-big-newbie-question/#findComment-501937 Share on other sites More sharing options...
anarchoi Posted March 27, 2008 Author Share Posted March 27, 2008 nevermind, i messed around and got it to work! thanks Link to comment https://forums.phpfreaks.com/topic/98114-big-newbie-question/#findComment-501938 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.