Jump to content

big newbie question!


anarchoi

Recommended Posts

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

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

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.