RE: [PHP-DB] Error query : mysql_result
| From: | John W. Holmes | Date: | Thu, 10 Oct 2002 12:30:30 +0000 |
| Subject: | RE: [PHP-DB] Error query : mysql_result | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-22315@lists.php.net to get a copy of this message | ||
This usually means your query failed. Check for errors using
mysql_error().
---John Holmes...
> -----Original Message-----
> From: Burgess [mailto:c.burgess@city.ac.uk]
> Sent: Thursday, October 10, 2002 5:14 AM
> To: php-db@lists.php.net
> 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",
'',
> 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 "<p>add workplace details</p>";
> print "<p>" . $worksql. "</p>";
> print mysql_errno() . ": ".mysql_error() ;
> exit;
> }
>
>
> Please contact me if you require further information.
> Many thanks
>
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php