XILO Community Forum

Support 0845 034 6444 • Sales 0800 084 2421

Go Back   XILO Community Forum > Customer Support > Support Queries > PHP/MySQL problems
Support Queries This forum should be used to contact XILO's support team should you have any problems with your account.

Reply
 
LinkBack Thread Tools Display Modes
  (#1 (permalink)) Old
User
moteintheeye is on a distinguished road
 
Posts: 7
Join Date: May 2006
Location: orleans
Question PHP/MySQL problems - 26/06/2006, 3:53 PM

I've had a painful day of trying to get information from my live database using PHP but so far to no avail. I've created a test file, through which I've found out that the connection is being made (and hence all the connection details are correct) but for some reason, pulling information from the database fails. The code I've got works fine off-line and goes like this:

Code:
  $db = mysql_connect($dbserver, $dbusername,   $dbpassword) or die("Database Error: ".mysql_error());  
  mysql_select_db($dbname, $db) or die("Database Error: ".mysql_error());  
  $select = 'SELECT name FROM mote_proj WHERE id=1';
  $result = mysql_query($select, $db);
  while ($row = mysql_fetch_array($result)) {
    $nm = $row['name'];
    echo $nm;
  }
I've figured I'm still on PHP 4 but can anyone see where I'm going wrong?

Cheers,

Simon
Reply With Quote
  (#2 (permalink)) Old
Tom Tom is offline
XILO Staff
Tom is on a distinguished road
 
Tom's Avatar
 
Posts: 172
Join Date: Nov 2005
Default Re: PHP/MySQL problems - 26/06/2006, 4:14 PM

Simon,

What are you entering for the dbserver?

Tom


XILO Communications Ltd.
Internet Hosting and Online Services
w: http://www.xilo.net/
h: http://my.xilo.net/
t: +44 (0) 845 034 6444
f: +44 (0) 845 034 6555
Reply With Quote
  (#3 (permalink)) Old
User
moteintheeye is on a distinguished road
 
Posts: 7
Join Date: May 2006
Location: orleans
Default Re: PHP/MySQL problems - 26/06/2006, 4:36 PM

I've entered both "localhost" and "mysql.golf.xilo.net" (I know its not recommended but I was desperate).

I put in an echo to check if it is was connecting fine, and that came back saying OK, but getting it to pull out data is where I can't find a solution.

I wondered whether having an underscore in the table name was a problem, otherwise when specifying $dbname, do I keep or omit the log-in name that appears at the beginning of the name?

Otherwise I'm stumped!

Cheers
Reply With Quote
  (#4 (permalink)) Old
Tom Tom is offline
XILO Staff
Tom is on a distinguished road
 
Tom's Avatar
 
Posts: 172
Join Date: Nov 2005
Default Re: PHP/MySQL problems - 26/06/2006, 4:40 PM

Simon,

Underscores in both the database name and username will not cause a problem but you do keep your username in the username and database name.

Normally something like;

username_databasename
username_databaseuser

Tom


XILO Communications Ltd.
Internet Hosting and Online Services
w: http://www.xilo.net/
h: http://my.xilo.net/
t: +44 (0) 845 034 6444
f: +44 (0) 845 034 6555
Reply With Quote
  (#5 (permalink)) Old
User
moteintheeye is on a distinguished road
 
Posts: 7
Join Date: May 2006
Location: orleans
Default Re: PHP/MySQL problems - 26/06/2006, 4:51 PM

So that's how I have my databasename and databaseuser but I still can't get the data!

I tried changing the permissions for the user as it keeps coming back as read only (fine when I'm only getting data anyway) and even added a new user to test this, but no change.

So if there's no problem in the scripting, is there any other reason this can occur?

Is my site going to be hosted on golf if the database is?
Any other ideas?
Any simple way of checking the set up?
I developed on php 5 and MySQL 5 (I think) so am I going to have problems with lots of my scripts?

I've raised a ticket on this, so am i better keeping going there on here?
Service is much quicker here


Quote:
Originally Posted by XILO-Tom
Simon,

Underscores in both the database name and username will not cause a problem but you do keep your username in the username and database name.

Normally something like;

username_databasename
username_databaseuser

Tom
Reply With Quote
  (#6 (permalink)) Old
Tom Tom is offline
XILO Staff
Tom is on a distinguished road
 
Tom's Avatar
 
Posts: 172
Join Date: Nov 2005
Default Re: PHP/MySQL problems - 26/06/2006, 5:02 PM

Simon,

It could be a coding problem - if youve made it for PHP5 and MySQL5 - it is probable that you are using code for those versions that do not work with the versions we are running.

Golf will be the server you are on if the databases are there.

We've replied to your ticket but not heard back from you yet

Tom


XILO Communications Ltd.
Internet Hosting and Online Services
w: http://www.xilo.net/
h: http://my.xilo.net/
t: +44 (0) 845 034 6444
f: +44 (0) 845 034 6555
Reply With Quote
  (#7 (permalink)) Old
Techie & Moderator
Kieran is on a distinguished road
 
Kieran's Avatar
 
Posts: 769
Join Date: Apr 2006
Location: Swindon, UK
Default Re: PHP/MySQL problems - 26/06/2006, 5:06 PM

This may sound blindingly obvious, but seeing as I can see no fault with your code and you have had your script report that the connection to the database was successful, have you made sure that the username in question you are using to connect to the database has the required permissions to execute the query you have entered?
Reply With Quote
  (#8 (permalink)) Old
Tom Tom is offline
XILO Staff
Tom is on a distinguished road
 
Tom's Avatar
 
Posts: 172
Join Date: Nov 2005
Default Re: PHP/MySQL problems - 26/06/2006, 5:08 PM

Also - possibly try and assign the permissions 'dba' and see if that helps

Tom


XILO Communications Ltd.
Internet Hosting and Online Services
w: http://www.xilo.net/
h: http://my.xilo.net/
t: +44 (0) 845 034 6444
f: +44 (0) 845 034 6555
Reply With Quote
  (#9 (permalink)) Old
User
moteintheeye is on a distinguished road
 
Posts: 7
Join Date: May 2006
Location: orleans
Default Re: PHP/MySQL problems - 26/06/2006, 8:43 PM

I've checked my permissions if H-Sphere and it says that they are all ok, but is there a file I can edit to dictate this as it keeps on changing whenever I re-enter H-Sphere?
My assumption is that its all good, but worth checking.

Simon
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes



Powered by vBulletin | XHTML | © Copyright 2003-2008 XILO Communications Ltd. All rights reserved. E&OE