was working on localhost now not on hosted site

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
malcolmboston
DevNet Resident
Posts: 1826
Joined: Tue Nov 18, 2003 1:09 pm
Location: Middlesbrough, UK

was working on localhost now not on hosted site

Post by malcolmboston »

ok well as the title tells you, now php throws up an error message regarding mysql
Warning: Supplied argument is not a valid MySQL result resource in /home/terrie/public_html/logged_in/My_Account/view_profiles.php on line 43
not sure why the hell this is happening all of a sudden, as it was working perfectly this morning at home

heres the code:

Code: Select all

<?php require_once('../../Connections/TDN_all.php'); ?> 
<?php
$colname_showing_profile = "1";
if (isset($HTTP_SESSION_VARS['username'])) {
  $colname_showing_profile = (get_magic_quotes_gpc()) ? $HTTP_SESSION_VARS['username'] : addslashes($HTTP_SESSION_VARS['username']);
}
mysql_select_db($database_TDN_all, $TDN_all);
$query_showing_profile = sprintf("SELECT show_profile FROM login WHERE username = '%s'", $colname_showing_profile);
$showing_profile = mysql_query($query_showing_profile, $TDN_all) or die(mysql_error());
$row_showing_profile = mysql_fetch_assoc($showing_profile);
$totalRows_showing_profile = mysql_num_rows($showing_profile);

mysql_select_db($database_TDN_all, $TDN_all);
$query_all_admins = "SELECT username, firstname, surname, gender, organisation, email, dob, comments, picture, show_profile, access_level FROM login WHERE show_profile = 'Yes' AND access_level = 'Admin'";
$all_admins = mysql_query($query_all_admins, $TDN_all) or die(mysql_error());
$row_all_admins = mysql_fetch_assoc($all_admins);
$totalRows_all_admins = mysql_num_rows($all_admins);

mysql_select_db($database_TDN_all, $TDN_all);
$query_all_members = "SELECT username, firstname, surname, gender, organisation, email, dob, comments, picture, show_profile, access_level FROM login WHERE show_profile = 'Yes' AND access_level = 'member' ORDER BY surname ASC";
$all_members = mysql_query($query_all_members, $TDN_all) or die(mysql_error());
$row_all_members = mysql_fetch_assoc($all_members);
$totalRows_all_members = mysql_num_rows($all_members);

// database variables for connections 
$host = "localhost"; 
$user = "malcolmboston"; 
$password = "xxxxxxxx"; 
$DBname = "tees-drug-network"; 
$tablename = "login"; 
//connection variables completed 
// establishing connections 
$link = mysql_connect ($host, $user, $password); 
//connection established 
//the query defined 
$query = "SELECT username, firstname, surname, gender, organisation, email, dob,
 comments, picture, show_profile, password  FROM  login WHERE username = '".$_SESSION['username']."'"; 

// select the database 
mysql_select_db($DBname); 
// query the database 
$result = mysql_query($query); 
$data = mysql_fetch_array($result, MYSQL_ASSOC);
?>
<?php
//defining the date for later use
$theDate = time();
$date = date('j F Y',$theDate);
// use echo $date to show result
?>
<?php 
//used to show the time
$thetime = time();
$time = date('g:ia',$thetime);
// use echo $time to show result
?>
ive taken out all of the html because i dont think you will need it also it is worth pointing out that i use a newer version of PHP and Apache than my 'hosters'
malcolmboston
DevNet Resident
Posts: 1826
Joined: Tue Nov 18, 2003 1:09 pm
Location: Middlesbrough, UK

Post by malcolmboston »

its wortg noting i could probably sort this out myself but ive only got notepad with me and am pretty lost without my baby zend
malcolmboston
DevNet Resident
Posts: 1826
Joined: Tue Nov 18, 2003 1:09 pm
Location: Middlesbrough, UK

Post by malcolmboston »

ok, i just fixed it

was because the localhost mysql DB and my hosts DB name are different sorry for bothering you

"hopes no-one is writing out a big explanation" :lol:
Nay
Forum Regular
Posts: 951
Joined: Fri Jun 20, 2003 11:03 am
Location: Brisbane, Australia

Post by Nay »

Man, I was writing a big essay for you to use heredoc <_<.

-Nay
malcolmboston
DevNet Resident
Posts: 1826
Joined: Tue Nov 18, 2003 1:09 pm
Location: Middlesbrough, UK

Post by malcolmboston »

lol, i thought someone might be sorry bud

its all good though

anyway while im here ill ask a question just before i browse the manual

basically i have a URL in my database, for a pic
how do i make it show the image and not the path?

simple im sure
malcolmboston
DevNet Resident
Posts: 1826
Joined: Tue Nov 18, 2003 1:09 pm
Location: Middlesbrough, UK

Post by malcolmboston »

it worked fine on localhost retrieving the picture on from a seperate directory (avatars/linux.jpg) but wont work when i tell it where to retrieve it from on the net from an absolute address

any help or pointers to an explanation would be great
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

What does the img src="..." bit look like in the html output?
malcolmboston
DevNet Resident
Posts: 1826
Joined: Tue Nov 18, 2003 1:09 pm
Location: Middlesbrough, UK

Post by malcolmboston »

one min, brb! :lol:
malcolmboston
DevNet Resident
Posts: 1826
Joined: Tue Nov 18, 2003 1:09 pm
Location: Middlesbrough, UK

Post by malcolmboston »

its working.

I 'assumed' it would be PHP related :cry: and not standard HTML
Post Reply