Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 12-10-2005, 11:17 PM PHP SQL Hangover
pappasaa's Avatar
Ultra Talker

Posts: 268
Trades: 0
I am stumped. I am changing my host today and 90% of my sites are all database. I can't seem to query the new database the right way.

This script works fine on the old server but not on the new one.

here are links to the old site and new site...same script

[edit=Republikin]Please no links to adult material or sites containing links to adult material[/edit]

PHP Code:
<?php

include ("include/header.inc.php");

include(
"include/dbconnect.php");

$result mysql_query("SELECT * FROM '$table' ORDER BY 'artist'",$db);


$sql 'SELECT * FROM `musictopten` LIMIT 0, 30 ';
echo 
"<table cellpadding=3 cellspacing=2 border=0 align=center width=100%><tr><td bgcolor=#000000><b>Artist Name</td><td bgcolor=#000000><b>Feature Video Title</td><td bgcolor=#000000><b>Video</td></tr>"

$alternate "2"
while (
$row = @mysql_fetch_array($result)) { 
$id $row["id"]; 
$artist $row["artist"];
$song1 $row["song1"];

if (
$alternate == "1") { 
$color "#555555"
$alternate "2"

else { 
$color "#222222"
$alternate "1"

echo 
"<tr bgcolor=$color><td>$artist</td><td>$song1</td><td><a href='view1.php?id=$id'>See All Videos</a></td></tr>"

echo 
"</table>"

include (
"include/footer.inc.php");
?>
PHP Code:
 <?

include("include/config.php");

$db mysql_connect("$dbserver""$dbuser""$dbpass");
mysql_select_db("$dbname",$db);
  
?>
Not sure what I am doing wrong but I need to get this to work. The new server offers a more updated version of php and mysql so it should work fine and the only part of the code i did change was the @ in front of the query.

Any help would be great and i will give you a credit and a link on my page
__________________
visit my link...um...nevermind

Last edited by Republikin; 12-11-2005 at 03:02 PM..
pappasaa is offline
Reply With Quote
View Public Profile Visit pappasaa's homepage!
 
 
Register now for full access!
Old 12-11-2005, 05:10 AM
aboyd's Avatar
Skilled Talker

Posts: 61
Location: USA
Trades: 0
I don't honestly see anything wrong with your code. Obviously, if it was working on the old server, then the code works.

Here are some questions to ask yourself. Is the database on the new server using a new name? Is the database even set up? Is the database in place, but each table is empty? Has your username or password changed? Is the "new" version of PHP actually version 5 (version 4 and 5 changed the way to access a database, you might have to rewrite some code)?
__________________

Please login or register to view this content. Registration is FREE
- geek blog & free phpBB mods

Please login or register to view this content. Registration is FREE
- tools & forums for writers

Please login or register to view this content. Registration is FREE
- dating advice for men, from women
aboyd is offline
Reply With Quote
View Public Profile Visit aboyd's homepage!
 
Old 12-11-2005, 05:46 AM
pappasaa's Avatar
Ultra Talker

Posts: 268
Trades: 0
i Have changed everything to the new setting but i can't find the problem. I dont know what is up. I am going to look into in more and get back to you..if anyone sees a problem let me know
__________________
visit my link...um...nevermind
pappasaa is offline
Reply With Quote
View Public Profile Visit pappasaa's homepage!
 
Old 12-11-2005, 05:54 AM
pappasaa's Avatar
Ultra Talker

Posts: 268
Trades: 0
i also see a poblem with the code posted...i have two querys that are asking the same thing but different ways...the second was a add-on and I took it out. I am still stumprd...I think it is a problem with the way i am calling the tables and not with the way i am calling the database.
__________________
visit my link...um...nevermind
pappasaa is offline
Reply With Quote
View Public Profile Visit pappasaa's homepage!
 
Old 12-11-2005, 01:21 PM
Extreme Talker

Posts: 169
Trades: 0
run the script with error_reporting(E_ALL); at the top and remove @ sign so that you will be able to know the actual error
__________________

Please login or register to view this content. Registration is FREE

TOP 10 WEB HOSTS COMPARED

BEST RESELLER HOSTING
john551 is offline
Reply With Quote
View Public Profile
 
Old 12-11-2005, 01:42 PM
pappasaa's Avatar
Ultra Talker

Posts: 268
Trades: 0
I get this error


PHP Code:
Warningmysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/pappasaa/public_html/nwabars/music_room/top_ten/allentries.php on line 13 
PHP Code:
<?php

include ("include/header.inc.php");

include(
"include/dbconnect.php");

$result mysql_query("SELECT * FROM '$table' ORDER BY 'artist'",$db);
error_reporting(E_ALL);

echo 
"<table cellpadding=3 cellspacing=2 border=0 align=center width=100%><tr><td bgcolor=#000000><b>Artist Name</td><td bgcolor=#000000><b>Feature Video Title</td><td bgcolor=#000000><b>Video</td></tr>"

$alternate "2"
while (
$row mysql_fetch_array($result)) { 
$id $row["id"]; 
$artist $row["artist"];
$song1 $row["song1"];

if (
$alternate == "1") { 
$color "#555555"
$alternate "2"

else { 
$color "#222222"
$alternate "1"

echo 
"<tr bgcolor=$color><td>$artist</td><td>$song1</td><td><a href='view1.php?id=$id'>See All Videos</a></td></tr>"

echo 
"</table>"

include (
"include/footer.inc.php");
?>
__________________
visit my link...um...nevermind
pappasaa is offline
Reply With Quote
View Public Profile Visit pappasaa's homepage!
 
Old 12-11-2005, 01:48 PM
aboyd's Avatar
Skilled Talker

Posts: 61
Location: USA
Trades: 0
You need to move the error reporting up, before the include statements, so you can see the errors with those, too. Sounds like your MySQL isn't set up right.

-T
__________________

Please login or register to view this content. Registration is FREE
- geek blog & free phpBB mods

Please login or register to view this content. Registration is FREE
- tools & forums for writers

Please login or register to view this content. Registration is FREE
- dating advice for men, from women
aboyd is offline
Reply With Quote
View Public Profile Visit aboyd's homepage!
 
Old 12-11-2005, 03:00 PM
Republikin's Avatar
Defies a Status

Posts: 3,189
Trades: 3
Try changing this...

PHP Code:
$result mysql_query("SELECT * FROM '$table' ORDER BY 'artist'",$db); 
To this..

PHP Code:
$result mysql_query("SELECT * FROM $table ORDER BY 'artist'",$db); 
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
Republikin is offline
Reply With Quote
View Public Profile
 
Old 12-11-2005, 03:15 PM
0beron's Avatar
Defies a Status

Posts: 1,832
Location: Somewhere else entirely
Trades: 0
That's most likely the problem, although if you have any more trouble, add an or die() to the end of the query:

PHP Code:
$result mysql_query("SELECT * FROM $table ORDER BY 'artist'",$db) or die(mysql_error()); 
That way you can see the mysql errors as well as the php ones. The 'invalid MySQL result resource' error usually means your query failed.
__________________
UPDATE 0beron SET talkupation = talkupation + lots WHERE post = 'helpful';

Please login or register to view this content. Registration is FREE
(aka MSN handwriting for forums)
0beron is offline
Reply With Quote
View Public Profile Visit 0beron's homepage!
 
Reply     « Reply to PHP SQL Hangover
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.60614 seconds with 12 queries