View Single Post

   
  #4 (permalink)  
Old 05-07-2008, 10:15 AM
Salah Nait-Mouloud
 
Posts: n/a
Default Re: PHP Question

Hi.
try this
<?php
mysql_connect('localhost', 'login', 'password')
or die('Could not connect: ' . mysql_error());
mysql_select_db("election") or die ("Could not select election database");

$result = mysql_query("update election set Votes = Votes + 1 where
Name='TheGuy'");
if (!$result) {
$message = 'Invalid update: ' . mysql_error() . "\n";
$message .= 'Whole query: ' . $result;
}
mysql_close($link);
die($message);
?>

or this

<?php
$connect = mysql_connect('localhost', 'login', 'password');
if(!$connect){
die('Could not connect: ' . mysql_error());
}

$db = mysql_select_db("election");
if(!$db){
die ("Could not select election database");
}

$result = mysql_query("update election set Votes = Votes + 1 where
Name='TheGuy'");
if (!$result) {
$message = 'Invalid update: ' . mysql_error() . "\n";
$message .= 'Whole query: ' . $result;
}
mysql_close($link);
die($message);
?>

regards

On Tue, May 6, 2008 at 4:39 PM, Michael Condon <admin@compinfosec.com>
wrote:

> I have a PHP script that seems to be failing. I execute it using
> window.location.href("http://www.vote.com/vote2.php"):
>
> <?php
> $link = mysql_connect('localhost', 'login', 'password');
> if (!$link) {
> die('Could not connect: ' . mysql_error());
> }
> $result = use election
> if (!$result) {
> die('Could not connect: ' . mysql_error());
> }
> $result = mysql_query("update election set Votes = Votes + 1 where
> Name='TheGuy'");
> if (!$result) {
> $message = 'Invalid update: ' . mysql_error() . "\n";
> $message .= 'Whole query: ' . $result;
> die($message);
>
> mysql_close($link);
> ?>
>
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:
> http://lists.mysql.com/mysql?unsub=s...ud@echovox.com
>
>



--
Salah NAIT-M
Echovox <http://www.m-boost.com>

Reply With Quote