RE: [PHP-DB] Error query : mysql_result

2002-10-10 Thread John W. Holmes

This usually means your query failed. Check for errors using
mysql_error().

---John Holmes...

> -Original Message-
> From: Burgess [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, October 10, 2002 5:14 AM
> To: [EMAIL PROTECTED]
> Subject: [PHP-DB] Error query : mysql_result
> 
> Hi
> 
> I have used the mysql_result function to return some specific
information
> from database.  The information is returned as it should but I keep
> getting
> this error message:
> 
> Warning: Unable to jump to row 0 on MySQL result index 4 in
> /u1.bath/s31/eh842/public_html/SCR/register/process.php on line 140
> 
> 
> 
> I'm relatively new to PHP and am unable to solve the problem so I
wondered
> if someone would mind spending a couple of minutes to help me.
> 
> My script, in part, reads as below:
> 
>  // check to see if company exists in db
> 
> $CompanyQuery = mysql_query("SELECT coid FROM co_details WHERE
co_name
> =
> '$company' AND co_city = '$city' AND co_country = '$co_country'");
> 
> $CompanyExist = mysql_num_rows($CompanyQuery);
> $company_id= mysql_result($CompanyQuery,0,0);
> 
> if ($CompanyExist > 0) {
> 
>   //if company exists add workplace details
>$confirmkey =  md5(uniqid(rand()));
>   $signup_id = signup_details($username, $title, $fname, $lname,
> $email,
> $country, $job_title, $user_notes, $agree_terms,
$confirmkey,$password);
>   addworkplace($signup_id, $company_id, $department, $start_month,
> $start_year, $end_month, $end_year );
>
add_cons_info($signup_id,$functional,$technical,$mysap,$industry);
> 
> }  //END if statement
> 
> else { //add company and workplace details
> 
>// Add new member to table signup
> $confirmkey =  md5(uniqid(rand()));
>$signup_id = signup_details($username, $title, $fname, $lname,
> $email, $country, $job_title, $user_notes, $agree_terms, $confirmkey,
> $password);
>   $company_id = company_details($company, $city, $co_country);
>   addworkplace($signup_id, $company_id, $department, $start_month,
> $start_year, $end_month, $end_year );
>
add_cons_info($signup_id,$functional,$technical,$mysap,$industry);
> 
>  } // END else statement
> 
>   }
> 
>   //  if successful in adding to vAuthenticate, send confirmation
email
>   if (mysql_errno() == 0){
> 
>$emailerMessage .= "\n\n"; // 2 Line Breaks
>$emailerMessage .= $confirm; // URL to confirm.php -> see email.inc
>$emailerMessage .= "?confirmkey=" . $confirmkey; // add confirm key
to
> message
>$emailerMessage .= "\n\n"; // 2 Line Breaks
>$sent = @mail($email, $emailerSubject, $emailerMessage,
> "From:$emailerName<$emailerEmail>\nReply-to:$emailerEmail");
>  } // END if statement
> 
> }
> 
> 
> 
> 
> function signup_details($username, $title, $fname, $lname, $email,
> $country,
> $job_title, $user_notes, $agree_terms, $confirmkey, $password)  {
> 
> if ($user_notes == '') {
> 
>  $user_notes = "Member chose not to include a profile";
>  $sql = "INSERT INTO signup VALUES
>
('','$username','$title','$fname','$lname','$email','$country','$job_tit
le
> ',
> '$user_notes','$agree_terms',NOW(),'$confirmkey')";
>   $addmember = mysql_query($sql);
>   $memberid=mysql_insert_id();
> 
>   // If SUCCESSFUL, add to vAuthenticate tables too
>   if (mysql_errno() == 0){
>   $AddToAuth = new auth();
>   $add =
> $AddToAuth->add_user($username,$password,"Ungrouped","999","inactive",
'',
> 0);
>   }
>   else{
> print "this is the signup details sql statement\n ";
> print $sql."\n";
> print mysql_errno() . ": " . mysql_error() . "\n";
> exit;
>   }
>   return $memberid;
> 
>  }// END if
> 
> else {
> 
>   $user_notes = addslashes($user_notes);
> 
>   $sql = "INSERT INTO signup VALUES
>
('','$username','$title','$fname','$lname','$email','$country','$job_tit
le
> ',
> '$user_notes','$agree_terms',NOW(),'$confirmkey')";
>   $addmember = mysql_query($sql);
>   $memberid=mysql_insert_id();
> 
>   // If SUCCESSFUL, add to vAuthenticate tables too
>   if (mysql_errno() == 0){
>   $AddToAuth = new auth();
>   $add =
> $AddToAuth->add_user($username,$password,"Ungrouped","999","inactive&quo

Re: [PHP-DB] Error query : mysql_result

2002-10-10 Thread Thomas Lamy



Burgess [mailto:[EMAIL PROTECTED]] wrote:
> Hi
> 
> I have used the mysql_result function to return some specific 
> information
> from database.  The information is returned as it should but 
> I keep getting
> this error message:
> 
> Warning: Unable to jump to row 0 on MySQL result index 4 in
> /u1.bath/s31/eh842/public_html/SCR/register/process.php on line 140
> 
> My script, in part, reads as below:
> 
>133   // check to see if company exists in db
>134  
>135 $CompanyQuery = mysql_query("SELECT coid FROM co_details 
>136  WHERE co_name =
>137  '$company' AND co_city = '$city' AND co_country = '$co_country'");
>138  
>139  $CompanyExist = mysql_num_rows($CompanyQuery);
>140  $company_id= mysql_result($CompanyQuery,0,0);
>141  
>142  if ($CompanyExist > 0) {
>143  
>144//if company exists add workplace details
>145 $confirmkey =  md5(uniqid(rand()));
>146$signup_id = signup_details($username, $title, $fname, 
> []
> 
I have inserted the line numers where I think they are right, please correct
me...

This seems to be a common trivial error: in 139, you get the number of rows
found, but if there are none, you try to retrieve data in line 140, where
you get the error message. Exchange line 140 with 142, and the error message
will go away.

And please, the next time you ask here, post only code snippets (e.g.
beginning of function to 2-5 lines from where you get the error), and
include line numbers. Thanks.

Thomas

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP-DB] Error query : mysql_result

2002-10-10 Thread Snijders, Mark

would be nice if you would tell which line is 140



-Original Message-
From: Burgess [mailto:[EMAIL PROTECTED]]
Sent: donderdag 10 oktober 2002 11:14
To: [EMAIL PROTECTED]
Subject: [PHP-DB] Error query : mysql_result


Hi

I have used the mysql_result function to return some specific information
from database.  The information is returned as it should but I keep getting
this error message:

Warning: Unable to jump to row 0 on MySQL result index 4 in
/u1.bath/s31/eh842/public_html/SCR/register/process.php on line 140



I'm relatively new to PHP and am unable to solve the problem so I wondered
if someone would mind spending a couple of minutes to help me.

My script, in part, reads as below:

 // check to see if company exists in db

$CompanyQuery = mysql_query("SELECT coid FROM co_details WHERE co_name =
'$company' AND co_city = '$city' AND co_country = '$co_country'");

$CompanyExist = mysql_num_rows($CompanyQuery);
$company_id= mysql_result($CompanyQuery,0,0);

if ($CompanyExist > 0) {

  //if company exists add workplace details
   $confirmkey =  md5(uniqid(rand()));
  $signup_id = signup_details($username, $title, $fname, $lname, $email,
$country, $job_title, $user_notes, $agree_terms, $confirmkey,$password);
  addworkplace($signup_id, $company_id, $department, $start_month,
$start_year, $end_month, $end_year );
  add_cons_info($signup_id,$functional,$technical,$mysap,$industry);

}  //END if statement

else { //add company and workplace details

   // Add new member to table signup
$confirmkey =  md5(uniqid(rand()));
   $signup_id = signup_details($username, $title, $fname, $lname,
$email, $country, $job_title, $user_notes, $agree_terms, $confirmkey,
$password);
  $company_id = company_details($company, $city, $co_country);
  addworkplace($signup_id, $company_id, $department, $start_month,
$start_year, $end_month, $end_year );
  add_cons_info($signup_id,$functional,$technical,$mysap,$industry);

 } // END else statement

  }

  //  if successful in adding to vAuthenticate, send confirmation email
  if (mysql_errno() == 0){

   $emailerMessage .= "\n\n"; // 2 Line Breaks
   $emailerMessage .= $confirm; // URL to confirm.php -> see email.inc
   $emailerMessage .= "?confirmkey=" . $confirmkey; // add confirm key to
message
   $emailerMessage .= "\n\n"; // 2 Line Breaks
   $sent = @mail($email, $emailerSubject, $emailerMessage,
"From:$emailerName<$emailerEmail>\nReply-to:$emailerEmail");
 } // END if statement

}




function signup_details($username, $title, $fname, $lname, $email, $country,
$job_title, $user_notes, $agree_terms, $confirmkey, $password)  {

if ($user_notes == '') {

 $user_notes = "Member chose not to include a profile";
 $sql = "INSERT INTO signup VALUES
('','$username','$title','$fname','$lname','$email','$country','$job_title',
'$user_notes','$agree_terms',NOW(),'$confirmkey')";
  $addmember = mysql_query($sql);
  $memberid=mysql_insert_id();

  // If SUCCESSFUL, add to vAuthenticate tables too
  if (mysql_errno() == 0){
  $AddToAuth = new auth();
  $add =
$AddToAuth->add_user($username,$password,"Ungrouped","999","inactive", '',
0);
  }
  else{
print "this is the signup details sql statement\n ";
print $sql."\n";
print mysql_errno() . ": " . mysql_error() . "\n";
exit;
  }
  return $memberid;

 }// END if

else {

  $user_notes = addslashes($user_notes);

  $sql = "INSERT INTO signup VALUES
('','$username','$title','$fname','$lname','$email','$country','$job_title',
'$user_notes','$agree_terms',NOW(),'$confirmkey')";
  $addmember = mysql_query($sql);
  $memberid=mysql_insert_id();

  // If SUCCESSFUL, add to vAuthenticate tables too
  if (mysql_errno() == 0){
  $AddToAuth = new auth();
  $add =
$AddToAuth->add_user($username,$password,"Ungrouped","999","inactive", '',
0);
  }
  else{
print "this is the signup details sql statement\n ";
print $sql."\n";
print mysql_errno() . ": " . mysql_error() . "\n";
exit;
  }
  return $memberid;
  }// END else

} // END function

function company_details($company, $city, $co_country)
{
  $newcompanysql = "INSERT INTO co_details VALUES
('','$company','$city','$co_country')";
  $add_company= mysql_query($newcompanysql);
  if (mysql_errno() > 0){
print "add compnay details \n";
print $newcompanysql. "\n";
print mysql_errno() 

[PHP-DB] Error query : mysql_result

2002-10-10 Thread Burgess

Hi

I have used the mysql_result function to return some specific information
from database.  The information is returned as it should but I keep getting
this error message:

Warning: Unable to jump to row 0 on MySQL result index 4 in
/u1.bath/s31/eh842/public_html/SCR/register/process.php on line 140



I'm relatively new to PHP and am unable to solve the problem so I wondered
if someone would mind spending a couple of minutes to help me.

My script, in part, reads as below:

 // check to see if company exists in db

$CompanyQuery = mysql_query("SELECT coid FROM co_details WHERE co_name =
'$company' AND co_city = '$city' AND co_country = '$co_country'");

$CompanyExist = mysql_num_rows($CompanyQuery);
$company_id= mysql_result($CompanyQuery,0,0);

if ($CompanyExist > 0) {

  //if company exists add workplace details
   $confirmkey =  md5(uniqid(rand()));
  $signup_id = signup_details($username, $title, $fname, $lname, $email,
$country, $job_title, $user_notes, $agree_terms, $confirmkey,$password);
  addworkplace($signup_id, $company_id, $department, $start_month,
$start_year, $end_month, $end_year );
  add_cons_info($signup_id,$functional,$technical,$mysap,$industry);

}  //END if statement

else { //add company and workplace details

   // Add new member to table signup
$confirmkey =  md5(uniqid(rand()));
   $signup_id = signup_details($username, $title, $fname, $lname,
$email, $country, $job_title, $user_notes, $agree_terms, $confirmkey,
$password);
  $company_id = company_details($company, $city, $co_country);
  addworkplace($signup_id, $company_id, $department, $start_month,
$start_year, $end_month, $end_year );
  add_cons_info($signup_id,$functional,$technical,$mysap,$industry);

 } // END else statement

  }

  //  if successful in adding to vAuthenticate, send confirmation email
  if (mysql_errno() == 0){

   $emailerMessage .= "\n\n"; // 2 Line Breaks
   $emailerMessage .= $confirm; // URL to confirm.php -> see email.inc
   $emailerMessage .= "?confirmkey=" . $confirmkey; // add confirm key to
message
   $emailerMessage .= "\n\n"; // 2 Line Breaks
   $sent = @mail($email, $emailerSubject, $emailerMessage,
"From:$emailerName<$emailerEmail>\nReply-to:$emailerEmail");
 } // END if statement

}




function signup_details($username, $title, $fname, $lname, $email, $country,
$job_title, $user_notes, $agree_terms, $confirmkey, $password)  {

if ($user_notes == '') {

 $user_notes = "Member chose not to include a profile";
 $sql = "INSERT INTO signup VALUES
('','$username','$title','$fname','$lname','$email','$country','$job_title',
'$user_notes','$agree_terms',NOW(),'$confirmkey')";
  $addmember = mysql_query($sql);
  $memberid=mysql_insert_id();

  // If SUCCESSFUL, add to vAuthenticate tables too
  if (mysql_errno() == 0){
  $AddToAuth = new auth();
  $add =
$AddToAuth->add_user($username,$password,"Ungrouped","999","inactive", '',
0);
  }
  else{
print "this is the signup details sql statement\n ";
print $sql."\n";
print mysql_errno() . ": " . mysql_error() . "\n";
exit;
  }
  return $memberid;

 }// END if

else {

  $user_notes = addslashes($user_notes);

  $sql = "INSERT INTO signup VALUES
('','$username','$title','$fname','$lname','$email','$country','$job_title',
'$user_notes','$agree_terms',NOW(),'$confirmkey')";
  $addmember = mysql_query($sql);
  $memberid=mysql_insert_id();

  // If SUCCESSFUL, add to vAuthenticate tables too
  if (mysql_errno() == 0){
  $AddToAuth = new auth();
  $add =
$AddToAuth->add_user($username,$password,"Ungrouped","999","inactive", '',
0);
  }
  else{
print "this is the signup details sql statement\n ";
print $sql."\n";
print mysql_errno() . ": " . mysql_error() . "\n";
exit;
  }
  return $memberid;
  }// END else

} // END function

function company_details($company, $city, $co_country)
{
  $newcompanysql = "INSERT INTO co_details VALUES
('','$company','$city','$co_country')";
  $add_company= mysql_query($newcompanysql);
  if (mysql_errno() > 0){
print "add compnay details \n";
print $newcompanysql. "\n";
print mysql_errno() . ": ".mysql_error() . "\n";
exit;
  }
  else
return mysql_insert_id();
}



function addworkplace ($signup_id, $company_id, $department, $start_month,
$start_year, $end_month, $end_year)
{
 //start date in correct format
 $start_date= $start_year."-".$start_month."-01";

  //end date in correct format
   $end_date = $end_year."-".$end_month."-01";

/* if ($end_month || $end_year == "Present")
$end_date="NULL";
  else
$end_date=$end_year."-".$end_month."-01";
*/

  $worksql = "INSERT INTO workplace VALUES
('','$signup_id','$company_id','$end_date','$start_date','$department')";
  mysql_query($worksql);
  // need to meddle with date to get correct format
  if (mysql_errno() > 0){
print "add workplace details";
print "" . $worksql. "";
print mysql_errno() . ": ".mysql_error() ;
exit;
  }


Please