Page 1 of 1

Re: getting the id from one table, putting it in another

Posted: Wed Jul 03, 2002 11:07 am
by WiZARD
Maybe simpy will create array?

Posted: Fri Jul 05, 2002 1:17 am
by WiZARD
Your welcome Michelle! :)

My turn then.

Posted: Sun Jul 07, 2002 5:35 pm
by Goober
Since your taken care of, I'll go ahead with my problem.

I'm farely new with php, but not stupid.

When I query information that was submitted into a database prior, my result is: Resource id #3

I used to remember what to do in this situation, but I completely forgot somehow. Someone please help me out.

Posted: Sun Jul 07, 2002 8:42 pm
by Oleg Butuzov
Resource id #3 -?????????

HM?!?! You try to put link indefiner into the data base!
like

Code: Select all

<?
$user="flashsoft";
$pass="me";
$host="localhost";
$database="flashsoft";

$link=mysql_connect($host, $user, $pass);
mysql_select_db($database);


mysql_query("INSERT INTO `table` (`link`) VALUES ('$link')"; // here is problem
// just change a var name

?>



regards...

Posted: Sun Jul 07, 2002 9:12 pm
by Goober
I'm sorry but your going to have to be more specific. :lol:

Posted: Mon Jul 08, 2002 3:18 am
by Oleg Butuzov
I did not undestud you. (BAD ENGLISH =( )

Resource id #3 - this is link of the mysql connection... so can not put it into data base =(.

Posted: Mon Jul 08, 2002 9:14 am
by Goober
Yes, I know that. I haven't been trying to put that into the database. I previously entered numbers, they entered just like they should, they are there. When I query them I get that: Resource Id #3, and I dont know what to do from there.

Posted: Wed Jul 10, 2002 1:46 am
by Oleg Butuzov
Goober wrote:When I query them I get that: Resource Id #3, and I dont know what to do from there.


Your vars have same names like link indentifier... may be...

Show me please a sours file, i after that I tell you where i mistake...

da code...

Posted: Thu Jul 11, 2002 7:03 am
by Goober

Code: Select all

$link = mysql_connect( "$dbhost","$dbuser","$dbpass" );
 if ( ! $link )
   die( "You did something wrong.  You are very stupid.  Fix it.<br>" );
      
$select = mysql_select_db( $dbname ) or die ( "You did something wrong.  You are very stupid.  Fix it.<br>" );

$result_wins = mysql_query( "SELECT sum(wins) FROM record" );
$var = mysql_fetch_array($result_wins);     
         if ($var == $four) 
        echo $var;


Thus, when I echo $var, I get "Array". :roll:

Posted: Thu Jul 11, 2002 7:09 am
by elitecodex
Try something like this:

Code: Select all

$result_wins = mysql_query("SELECT SUM(wins) AS wins_total FROM record") or die(mysql_error());
$var = mysql_fetch_array($result_wins)
if ( $var['wins_total'] == $four )
    echo $var['wins_total'];


When you are calling mysql_fetch_array, you are getting an array of all the fields in the current record, you have have to tell it which one. See if this works.

Will

Posted: Thu Jul 11, 2002 7:28 am
by Goober
OMFG....I love you so much. If I ever meet you in person, I'll molest you... :lol: