8 Replies - 495 Views - Last Post: 27 March 2013 - 06:13 AM Rate Topic: -----

#1 codabra  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 13-August 12

Error when connecting to a table

Posted 27 March 2013 - 02:57 AM

To start of, i want to say thanks for any help.

I had a working database and table then decided that with my basic knowledge it would be okay to try to update it ( big mistake ). The table i was adding had some additional columns and i chose to go the import route and replace my original table. After countless tries and errors on not being able to update it i decided to rename my original table and then upload my new csv file and name it that. ( I also made some additional changes to another table on the same data base )
Now i am unable to connect to the table.

I can however connect to the server.

Things I've tried.

obvious i tried to re-name the files to get the old one working -Fail
I've tried to change my database connect in my php - Fail
I've created a new table and tried to connect to that - Fail
I've tried creating a whole new database with a new table - Fail

I've gone through my code and commented out a section that i really have no idea what it's doing but i'm assuming it
connects with the table and database i'm trying to fix. ( That would be the function section.. remember above i said i edited another table I think that's there was only 2 )- fail

<?php
   include("includes/db_connect.php");
   function getProducts($CategoryID)
   {
     $query ="select ID,ProductID,ProductName,ProductDetail,ProductImage from product where CategoryID = '".$CategoryID."'";
     $result = mysql_query($query);
     return $result;
   }

?>


the working version had "select from and where" all in lowercase.. I made them capital - Fail

I've been trying to fix this issue over the last 10hrs... clearly there is something i'm not getting.

the database connect is

<?php
// FOR SERVER
$link = mysql_connect('localhost','username','password');
if(!$link)
	{
		exit('Unable to connect to the server');
		}
$conn = mysql_select_db('database_name', $link);
if(!$conn)
	{
		exit('Unable to link to database courses');
	   
	}
?>


At this point i just need to be put out my misery. Thank you for reading. :withstupid:/>

Is This A Good Question/Topic? 0
  • +

Replies To: Error when connecting to a table

#2 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3393
  • View blog
  • Posts: 9,591
  • Joined: 08-June 10

Re: Error when connecting to a table

Posted 27 March 2013 - 03:48 AM

ok, the first step is figuring out what is really in your DB. tools like phpMyAdmin, the MySQL Workbench (or other GUIs atop the mysql executable) should be sufficient for that.
Was This Post Helpful? 1
  • +
  • -

#3 andrewsw  Icon User is online

  • Fire giant boob nipple gun!
  • member icon

Reputation: 2885
  • View blog
  • Posts: 9,571
  • Joined: 12-December 12

Re: Error when connecting to a table

Posted 27 March 2013 - 03:48 AM

Do you receive any error messages and, if so, what are they?

Add the following to the top of your PHP so that you can see any error messages:

error_reporting(E_ALL);
ini_set('display_errors', '1');

and display any mysql_error that you receive.

The mysql library is deprecated, see the links in my signature.
Was This Post Helpful? 1
  • +
  • -

#4 JackOfAllTrades  Icon User is online

  • Saucy!
  • member icon

Reputation: 5954
  • View blog
  • Posts: 23,222
  • Joined: 23-August 08

Re: Error when connecting to a table

Posted 27 March 2013 - 03:51 AM

You haven't told us the exact error you're getting.
Was This Post Helpful? 0
  • +
  • -

#5 codabra  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 13-August 12

Re: Error when connecting to a table

Posted 27 March 2013 - 04:21 AM

I've been using phpMyadmin

There reason i didn't list a specific error because i have none other then was was inputted which is "Unable to link to database courses". So that lets me know i'm not connecting to the table.

As far as the code Andrew put. I added it and nothing happened. I changed where i placed it and nothing, i also went and placed it in the db-connect include file and its just blank.

I placed it at the top so.. i'm not how how many ways i can screw that up...but apparently I've found one

( I did try to read up on the depreciation, but i dont have enough current know how to change things at the moment - but will down the road ).
Was This Post Helpful? 0
  • +
  • -

#6 codabra  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 13-August 12

Re: Error when connecting to a table

Posted 27 March 2013 - 04:30 AM

man... as you can see from my previous post... I've been up all night trying to figure this out. My typing skills have diminished greatly.

:helpsmilie:
Was This Post Helpful? 0
  • +
  • -

#7 andrewsw  Icon User is online

  • Fire giant boob nipple gun!
  • member icon

Reputation: 2885
  • View blog
  • Posts: 9,571
  • Joined: 12-December 12

Re: Error when connecting to a table

Posted 27 March 2013 - 04:33 AM

Quote

There reason i didn't list a specific error because i have none other then was was inputted which is "Unable to link to database courses". So that lets me know i'm not connecting to the table.

Your quote says that you are unable to connect to the database, not a table. As Dormilich suggests, use PHPMyAdmin or similar to check your database and connection details.

and you've probably placed those two lines of code in the correct place, but there is no error to display, other than the (significant!) one that you already receive.

View Postcodabra, on 27 March 2013 - 11:30 AM, said:

man... as you can see from my previous post... I've been up all night trying to figure this out. My typing skills have diminished greatly.

:helpsmilie:

Yes, it is deprecated, not depreciated :whatsthat:
Was This Post Helpful? 0
  • +
  • -

#8 codabra  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 13-August 12

Re: Error when connecting to a table

Posted 27 March 2013 - 05:39 AM

So about an hour after you told me it was my database and the table, i figured it out!!!

Some how when i was renaming the tables the username was getting removed so it never occurred to me to check that.

I"m slightly peeved after 11 long hours of working and seeing the sunrise, the solution was picking a username from a drop box. Honestly i would have preferred to have solved a major database corruption. :taz:

Thank you andrew
-Good day & Good night!
Was This Post Helpful? 0
  • +
  • -

#9 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3393
  • View blog
  • Posts: 9,591
  • Joined: 08-June 10

Re: Error when connecting to a table

Posted 27 March 2013 - 06:13 AM

its always the small and inconspicious errors that prove problematic...
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1