getting the id from one table, putting it in another

Codes here !

Moderators: macek, egami, gesf

User avatar
WiZARD
Moderator
Moderator
Posts: 1257
Joined: Thu Jun 20, 2002 10:14 pm
Location: Ukraine, Crimea, Simferopol
Contact:

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

Postby WiZARD » Wed Jul 03, 2002 11:07 am

Maybe simpy will create array?

User avatar
WiZARD
Moderator
Moderator
Posts: 1257
Joined: Thu Jun 20, 2002 10:14 pm
Location: Ukraine, Crimea, Simferopol
Contact:

Postby WiZARD » Fri Jul 05, 2002 1:17 am

Your welcome Michelle! :)

Goober
New php-forum User
New php-forum User
Posts: 5
Joined: Sun Jul 07, 2002 5:31 pm
Location: Dallas, TX
Contact:

My turn then.

Postby Goober » Sun Jul 07, 2002 5:35 pm

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.

User avatar
Oleg Butuzov
Last Samuray
Last Samuray
Posts: 831
Joined: Sun Jun 02, 2002 3:09 am

Postby Oleg Butuzov » Sun Jul 07, 2002 8:42 pm

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...

Goober
New php-forum User
New php-forum User
Posts: 5
Joined: Sun Jul 07, 2002 5:31 pm
Location: Dallas, TX
Contact:

Postby Goober » Sun Jul 07, 2002 9:12 pm

I'm sorry but your going to have to be more specific. :lol:

User avatar
Oleg Butuzov
Last Samuray
Last Samuray
Posts: 831
Joined: Sun Jun 02, 2002 3:09 am

Postby Oleg Butuzov » Mon Jul 08, 2002 3:18 am

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 =(.

Goober
New php-forum User
New php-forum User
Posts: 5
Joined: Sun Jul 07, 2002 5:31 pm
Location: Dallas, TX
Contact:

Postby Goober » Mon Jul 08, 2002 9:14 am

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.

User avatar
Oleg Butuzov
Last Samuray
Last Samuray
Posts: 831
Joined: Sun Jun 02, 2002 3:09 am

Postby Oleg Butuzov » Wed Jul 10, 2002 1:46 am

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...

Goober
New php-forum User
New php-forum User
Posts: 5
Joined: Sun Jul 07, 2002 5:31 pm
Location: Dallas, TX
Contact:

da code...

Postby Goober » Thu Jul 11, 2002 7:03 am

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:

elitecodex
New php-forum User
New php-forum User
Posts: 68
Joined: Tue Jul 09, 2002 8:45 am
Location: East Coast, USA
Contact:

Postby elitecodex » Thu Jul 11, 2002 7:09 am

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

Goober
New php-forum User
New php-forum User
Posts: 5
Joined: Sun Jul 07, 2002 5:31 pm
Location: Dallas, TX
Contact:

Postby Goober » Thu Jul 11, 2002 7:28 am

OMFG....I love you so much. If I ever meet you in person, I'll molest you... :lol:


Return to “mySQL & php coding”

Who is online

Users browsing this forum: No registered users and 0 guests