Jump to content

[SOLVED] Undefined Varibale


monkeypaw201

Recommended Posts

so, i am trying to run the following code:

 

$pilot_id = mysql_connect("localhost","cerulean","bluesky1701");

if (!$pilot_id)

  {

  die('Could not connect: ' . mysql_error());

  }

  mysql_select_db("cerulean_site", $pilot_id);

  $result = mysql_query("SELECT * FROM pilots ORDER BY pilot_id DESC");

 

$pilot_id=$row['pilot_id'];

 

and its throwing a weird error about an undefined variable

 

Notice: Undefined variable: row
Link to comment
https://forums.phpfreaks.com/topic/90094-solved-undefined-varibale/
Share on other sites

but this is giving me the same error:

 

$pilot_id = mysql_connect("localhost","cerulean","bluesky1701");

if (!$pilot_id)

  {

  die('Could not connect: ' . mysql_error());

  }

  mysql_select_db("cerulean_site", $pilot_id);

  $result = mysql_query("SELECT * FROM pilots ORDER BY pilot_id DESC");

 

$pilot_id=$row_pilot_id['pilot_id'];

What the above poster said.  Maybe you forgot to grab the results from your query...

 

<?php

  while($row = mysql_fetch_array($result)) {
    //Do what you've got to do.
  }

?>

 

If you only want one record/row...

<?php

  $row = mysql_fetch_array($result);

?>

 

 

You are saying that "$pilot_id" equals something yuou have not defined.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.