Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8255423
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T01:31:06+00:00 2026-06-08T01:31:06+00:00

This code works and enters all of the correct information into the database but

  • 0

This code works and enters all of the correct information into the database but the error check returns an error. I could remove the error check but I’m afraid of creating some nightmare that comes back to haunt me later or that I’m missing a fundamental issue:

    $sql5a = mysql_query("SELECT id FROM categories WHERE category='$category'");
        $categoryresult = mysql_fetch_array($sql5a);
        $oldcategoryid = $categoryresult['id'];
        $sql6a = "INSERT INTO lookupcategory SET
        fbid='$fbid2',
        categoryid='$oldcategoryid'";
            if ( @mysql_query($sql5b) ) { 
                                echo('sql5b updated successfully<br>'); 
                            } else { 
                                echo('Error: sql5b not updated<br>'.mysql_error() );
                        }
                            if ( @mysql_query($sql6b) ) { 
                                echo('sql6b updated successfully<br>'); 
                            } else { 
                                echo('Error: sql6b not updated<br>'.mysql_error() );
                        }

The output is: “Error: sql5b not updated
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘Resource id #7’ at line 1”
“sql6b updated successfully”

When I check the database all entries are correct. If sql5a didn’t work, sql6b couldn’t work, hence my confusion over the error.

A sample Category would be: Travel/Leisure
The category was originally created from a form response:
$category = htmlentities($fbdetail[‘category’], ENT_QUOTES);
and entered into the database successfully. An id number was assigned using AUTO_INCREMENT.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T01:31:09+00:00Added an answer on June 8, 2026 at 1:31 am

    You assign query to variable $sql5a, but call @mysql_query($sql5b).
    $sql5b doesn’t exist (at least in this sample). Same with $sql6a…

    You can use INSERT syntax without VALUES, but you need to ommit INTO keyword.

    $sql5a = mysql_query("SELECT id FROM categories WHERE category='$category'");
    if ( $res5a = @mysql_query($sql5a) ) { // first execute query and store resource in variable
        echo('sql5a selected successfully<br>'); 
    } else { 
        echo('Error: sql5a failed<br>'.mysql_error() );
    }
    $categoryresult = mysql_fetch_array($res5a); // fetch array passing the RESOURCE var, NOT query string
    $oldcategoryid = $categoryresult['id'];
    $sql6a = "INSERT lookupcategory SET
    fbid='$fbid2',
    categoryid='$oldcategoryid'";
    
    if ( @mysql_query($sql6a) ) { 
        echo('sql6a inserted successfully<br>'); 
    } else { 
        echo('Error: sql6a failed<br>'.mysql_error() );
    }
    

    I don’t know where you get $fbid2 or $category from, since it’s not in this piece of code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This code works well for displaying separate xml items in my main.xml. But is
This code works fine, but I'll want to handle exception if any thing goes
This code works well: UIDatePicker *pickerView = [[UIDatePicker alloc] initWithFrame:pickerFrame]; [pickerView addTarget:self action:@selector(pickerChanged:) forControlEvents:UIControlEventValueChanged];
This code works fine in Chrome. However, in Firefox, when it hits the GMxhr
This code works for me except it only checks for a duplicate once, and
This code works: monkey.h @interface monkey : NSObject { NSNumber *monkeyRanch; } @property (nonatomic,
This code works (when ControlType=dropDown then the background yellow ): <Window x:Class=TestCollapsed.Views.MainView xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml
this code works fine until I start scrolling: - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
This code works: class Test { public: Test(string name) : _name(name) {}; bool operator()()
This code works perfectly in Ubuntu, Windows, and Mac OS X. It also works

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.