more help yay!

Started by Valconeye, January 04, 2004, 08:41:50 PM

Previous topic - Next topic

Valconeye

  mysql_select_db("warcraft_guilds");
  $query = "insert into guilds WHERE name = '$name' SELECT FROM temp";
  $result = mysql_query($query);
  if(!$result)
  {
  echo "Duplicate login name or guild name detected. Please go back and try again.";
  }
  if ($result)
      echo  "The guild has been inserted into the database.";


whenever i run the code, it goes right to !$result so i guess the $query is wrong some how.

sorry for my noobness at mysql.

[Unknown]

Put the WHERE after the SELECT.

-[Unknown]

Valconeye


Valconeye

hehe, 1 more questions please, how would i do an insert and a delete at the same time?
i know the code below doesnt work, but both in 1 $query how would i?
$query = "insert into guilds SELECT * FROM temp WHERE name = '$name' delete from temp where name = '$name'";

[Unknown]

You can do two queries...  I would do this:

<?php
 mysql_select_db
('warcraft_guilds');

 
$result = mysql_query("
   INSERT INTO guilds
   SELECT FROM temp
   WHERE name = '
$name'");
 if (!
$result)
   die(
'Duplicate login name or guild name detected. Please go back and try again.');

 
mysql_query("
   DELETE FROM temp
   WHERE name = '
$name'");

 echo
'The guild has been inserted into the database.';
?>


-[Unknown]

Advertisement: