Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

php script error 1

Status
Not open for further replies.

WB786

MIS
Mar 14, 2002
610
I didn't design this website and moved the website from one domain to another but the page is not displaying correctly. I am getting a script error saying expected: ) at character 30 - in the following line:

<td><a href="page.html?id=<? echo $id; ?>&bid=<?php echo $r['ID']; ?>" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('<?php echo $r['button']?>','','graphics/<?php echo $r['button']; ?>-over.jpg',1)"><img src="graphics/<?php echo $r['button']; if($bid==$r['ID']) echo "-over"; ?>.jpg" name="<?php echo $r['button']?>" width="145" height="30" border="0"></a></td>

the main page to the website loads fine but when you click on say About Us the page.html doesn't pull the correct values from a MySQL database that doesn't reside on the same web host - (the guy who setup this website is hosting the server at his domain) I have talked to this guy but he is not sure why I am having such a problem so if anyone else can help that would be really GREAT!!

Working site:
New Domain:
Thanks,

:)WB
 
It seems like your new host is not configured to parse .html files while your old one was. Tell the server admin to add .html to the list of parsed extensions for php engine or rename all your files to .php.
 
Forgot to mention that both sites are hosted by the same company and had wrote them an email to fix the problem over 5 days ago.

Trying to get these admin at this place is just too time consuming.

Since I only had to modify two pages - I went with the option of just renaming the file extensions to .php and updating the a href tags as well. IT WORKS NOW!!!!

THANKS FOR ALL THE HELP!!!

:)WB
 
Vragabond,

Would it be possible to host the same website on our Windows 2003 server running IIS 6.0. I installed PHP 5.0 on the server but got the same problem described in my original post and then as per your solution I renamed the files to PHP but now I am getting the following error: Fatal error: Call to undefined function mysql_connect()

Any ideas?


Thanks,

:)WB
 
I know the post was directed to vragabond, but I'll chime in anyway.


You don't have PHP's MySQL extensions installed. There should be a line in your php.ini file that reads:

extension=php_mysql.dll

make sure the line isn't commented out (i.e. there's no semicolon as the beginning). If it is, remove the leading semicolon and restart your web server.




Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Thanks for chiming in,

But now I am getting this error:

Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource

Note: MySql Server is not on the this same Windows 2003 server. It is actually being hosted on a different host outside of our company's firewall. Here is the connection string:

function cap_connect(){
$dbh=mysql_connect ("67.18.26.40:3306", "emhceec_capitalr", "equipment") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("emhceec_capitalrentals");
}

The error is pointing to this line: $r=mysql_fetch_assoc($result);

Thanks,

:)WB
 
Depending on the type of query and whether that query has errors, mysql_query() can return TRUE, FALSE or a handle to a query result resource. In specific, a SELECT query will return a resource handle on success and a FALSE on failure. See
If you try to pass a FALSE to any of PHP's mysql_fetch_*() functions, you will get that error. As the error says, FALSE is not a result resource.

At minimum, change your mysql_query() invocation to include the seam "or die(...);" clause that your mysql_connect() invocation does. That way, your script will tell you what MySQL didn't like about your query.

Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Sorry, but I am not a PHP expert and this site was designed by someone else - but at least now I am getting exposed to PHP. I mostly dabble with ASP. Here is the whole connection string, please let me know what I need to modify to make this work:

<?php
function cap_connect(){
$dbh=mysql_connect ("67.18.26.40:3306", "emhceec_capitalr", "equipment") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("emhceec_capitalrentals");
}

function get_content($id, $bid){
if($bid!=''){
$sql="select content from cap_buttons where ID=$bid";
$result=mysql_query($sql);
$r=mysql_fetch_assoc($result);
$content=$r['content'];
}else{
$sql="select content from cap_headings where ID=$id";
$result=mysql_query($sql);
$r=mysql_fetch_assoc($result);
$content=$r['content'];
}
return $content;
}
?>

Thanks!!

:)WB
 
Insufficient data for a meaningful answer.

I need to see the error returned by MySQL. In order to see it, you need to apply the advice I gave you earlier and add the "or die(...)" commands to the lines where mysql_query() is invoked.

Want the best answers? Ask the best questions!

TANSTAAFL!!
 
This is the error: Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource

At line number 16 from the above mentioned post: $r=mysql_fetch_assoc($result);

I am not sure what other information I can give you.

Thanks.

:)WB
 
sleipnir214 said:
At minimum, change your mysql_query() invocation to include the seam "or die(...);" clause that your mysql_connect() invocation does. That way, your script will tell you what MySQL didn't like about your query.

To be more explicit....

The "invalid resource" error is a secondary error, caused by another problem, specifically in your SQL query. In your code, your mysql_connect() invocation reads:

$dbh=mysql_connect (...) or die ('I cannot connect to the database because: ' . mysql_error());

The part beginning with "or die" will run only if mysql_connect() returns a FALSE, and then the script will output some debugging information.

Changing every instance of:

$r=mysql_fetch_assoc($result);

with:

$r=mysql_fetch_assoc($result)[red] or die (mysql_error())[/red];

will do the same thing for your mysql_fetch_assoc() invocations, namely if mysql_fetch_assoc() returns FALSE (which is the most likely primary error in your code), then the "or die" part will run, outputting debugging information.



Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Ok Got it. Here is what the error now says:

Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in E:\crweb\webapps\Party\pages\cap_functions.php on line 16
You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1

Thanks,

:)WB
 
I don't know which mysql_query() invocation the error is talking about. But what values are passed to the function get_content()? What are the values in $bid and $id?



Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Good question - I am not sure. Looks like I might have to get hold of the person who originally did the website for our company before I started - hopefully we can still track this guy down.

Getting the new website was my main concern. Now that is working - I wanted to move it to our local server and just get rid of the company that is hosting our current website - we are not too happy with their services and also this gives me better control of our websites.

Hopefully I can get the local server to work as well.

Thanks for all the help so far though!!!

:)WB
 
chekc ur database for the about us record,

since it is not entered properly in the table

and then try again,

since it is working fin for all other pages then it should also work for the about us page.

u can get more information at
forum.pctechindia.com

thanks
 
Ok, I finally got the .sql file from this guy as now our website is down and can not connect to his mysql server. I installed mysql server on Win2k3 and is using IIS with PHP4 installed but still getting error in: $r=mysql_fetch_assoc($result);

I can query the db using SELECT statement without any problem so the db is working correctly.

Do I need to USE Tomcat server instead of IIS to properly execute the PHP coding - or need to modify the currect SELECT statement to somehow make this thing work.

The ID is simply a string coming from the main page where the various buttons are so the page.php page can render the proper information based on what button you pressed on main page.

Please advise.

Thanks,

:)WB
 
Can you believe the problem was in the coding. The id and bid querystring was not being passed at all to mysql. After much searching and learning more about PHP this is what the final solution was:

In the connection include file (listed above) all it was missing:

$id = $_REQUEST['id'];
$bid = $_REQUEST['bid'];

Problem solved. Now the question is for my own knowledge: Why was this not required before and why now? Is this possible due to new version of either PHP or MySql that I installed on Win2k3 or IIS need more explict instruction to properly handle PHP.

Your thoughts?

Thanks,

:)WB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top