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 6882973
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:19:22+00:00 2026-05-27T05:19:22+00:00

I am trying to insert data in table in mysql database through php code

  • 0

I am trying to insert data in table in mysql database through php code but I am always getting following error:
Invalid query: Table ‘whatsup_wp1.pushDevices’ doesn’t exist

I am using following code:

    <?php 
    $deviceid = $_GET["deviceid"];
    $link = mysql_connect('localhost', 'whatsup_wp1', 'XSvUCl0FugzV4');
    if (!$link) {
        die('Not connected : ' . mysql_error());
    }

    // make foo the current db
    $db_selected = mysql_select_db('whatsup_wp1', $link);
    if (!$db_selected) {
        echo 'Can\'t use whatsup_wp1 : ' . mysql_error();
    }
    else
        {
    //echo 'connect';
    }
    //$query = "select count(*) from city";
    //$query = "insert into devices (pushID) values('".$deviceid."')";
    $query = "INSERT INTO pushDevices(device) VALUES ('".$deviceid."')";
    echo $query;
    $result = mysql_query($query);
    if (!$result){
        die('Invalid query: ' . mysql_error());
    }
    echo $result;
    ?>

This database have more tables and I am able to use them. I am having problem with the tables that I am creating today. They appears in phpmyadmin but somehow I am not able to get use them through my php code.

Any help may be vital for me. I have spent complete day on it.

Thanks
Pankaj

  • 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-05-27T05:19:23+00:00Added an answer on May 27, 2026 at 5:19 am

    Its hard to tell by What your saying but i have a suggestion…. It looks like theres no table selected try this

    it formatted like this

    $query = "INSERT INTO mydb.mytable
    (mytablefield)
    VALUES
    ('myfieldvalue')"
    $result = mysql_query($query);
    if (!$result){
        die('Invalid query: ' . mysql_error());
    }
    

    My guess is you meant for it to be like this?

    $query = "INSERT INTO whatsup_wp1.devices 
    (device)
    VALUES
    ('".$deviceid."')"
    $result = mysql_query($query);
    if (!$result){
        die('Invalid query: ' . mysql_error());
    }
    

    And for security reasons i recommend this…

    else
        {
    //echo 'connect';
    $deviceid = mysql_real_escape_string(stripslashes($deviceid));
    }
    

    Change to

    else
        {
    //echo 'connect';
    $deviceid = mysql_real_escape_string(stripslashes($deviceid));
    }
    

    Personally i just use it like this

    $result = mysql_query("INSERT INTO mytable
    (mytablefield)
    VALUES
    ('myfieldvalue')");
    if($result){echo "Works!";}
    else{die('Invalid query: ' . mysql_error());exit();}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm getting error Not unique table/alias while trying to display data from MySQL database
I am trying to insert into mysql database dynamically. But I always see only
Language: OO PHP 5+ DB: MySQL I am trying to insert data from a
I am trying to retieve data from a MySQL table and insert into a
I'm trying to insert some data into a local MySQL database by using MySQL
I am trying to insert some text data into a table in SQL Server
I have created a datatable and trying to insert that datatable through SqlBulkCopy but
I was trying to insert new data into an existing XML file, but it's
I’m trying to bulk insert data to SQL server express database. When doing bcp
I received a MySQL data dump and am trying to insert the data into

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.