Jump to content


Photo

what is wrong with this script?:(((


  • Please log in to reply
5 replies to this topic

#1 alarik149

alarik149
  • Members
  • PipPipPip
  • Advanced Member
  • 60 posts

Posted 08 March 2006 - 11:11 AM

<?php

$db = mysql_connect(host', 'championships', 'passwd')
mysql_select_db('championships', $db);
$sql = "UPDATE register SET status = 'inactive' WHERE username = 'a'";
$result = mysql_query($sql) or die(mysql_error());

?>

why dosen`t this script work?I have 1 database named championships and 1 table named register.with 2 fields 'username' and 'status'.i don`t get it.it connects to the database good but it dosen`t change anything,no errors,no nothing.why?:( pls help me

Tired of math homework ? Just visit http://www.solvemymath.com for a free online math solver and calculator.
Videochat bucuresti studio -> http://www.GirlAddicts.com
About the adult video chat business -> www.girlplan.com

#2 Gaia

Gaia
  • Members
  • PipPipPip
  • Advanced Member
  • 95 posts
  • LocationCanada

Posted 08 March 2006 - 11:17 AM

Well, with the code you have right there, it's not outputting anything, you've just saved the mySQL result to a variable...

You need to remove the $result = part..

mysql_query($sql) or die(mysql_error());

Since you just want to update there's no need to save the result in a variable.

#3 alarik149

alarik149
  • Members
  • PipPipPip
  • Advanced Member
  • 60 posts

Posted 08 March 2006 - 11:20 AM

and how do i save it?please tell me the exact line(s) i need:(.in the book from luke welling it says just like that...no 'saving':(
Tired of math homework ? Just visit http://www.solvemymath.com for a free online math solver and calculator.
Videochat bucuresti studio -> http://www.GirlAddicts.com
About the adult video chat business -> www.girlplan.com

#4 Gaia

Gaia
  • Members
  • PipPipPip
  • Advanced Member
  • 95 posts
  • LocationCanada

Posted 08 March 2006 - 11:21 AM

I did......

change

$result = mysql_query($sql) or die(mysql_error());

To...

mysql_query($sql) or die(mysql_error());


#5 alarik149

alarik149
  • Members
  • PipPipPip
  • Advanced Member
  • 60 posts

Posted 08 March 2006 - 11:47 AM

yey,it works;) thanks a lot man...big thanks :)
Tired of math homework ? Just visit http://www.solvemymath.com for a free online math solver and calculator.
Videochat bucuresti studio -> http://www.GirlAddicts.com
About the adult video chat business -> www.girlplan.com

#6 AV1611

AV1611
  • Members
  • PipPipPip
  • Advanced Member
  • 997 posts

Posted 08 March 2006 - 11:58 AM

First, you are missing a ' be fore the word host in the first line
$db = mysql_connect(host', 'championships', 'passwd')
Second,

Do you actually have a username a? (username = 'a') or do you mean unsername like 'a%'?

Third, here is how I do PHP connect...
    $user="myname";
    $host="localhost";
    $password="mypassword";
    $database = "bible";
    mysql_connect($host,$user,$password);
    mysql_select_db($database);
You can even take these lines:
<?php
    $user="myname";
    $host="localhost";
    $password="mypassword";
 ?>

and put them in a file called mysqllogin.inc.php
then just use:
include 'mysqllogin.inc.php';
on all your web pages... it will save you a lot of typing




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users