Jump to content

Two Queries: (a) Templating (b) Counting


Petrushka

Recommended Posts

Good afternoon.

 

I was hoping for some advice or assistance on the two following points:

 

a)  I wish to have my banner and navigation system in a php include file. 

 


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/strict.dtd"> 
<html><head><title>Virtual Stud Book</title> 
<link rel="stylesheet" type="text/css" href="http://www.virtualstudbook.co.uk/style/style.css"/> 
</head>

	<?php include("http://www.virtualstudbook.co.uk/style/template.php");?>

<body>

<div id="main">
<b>Welcome to the Virtual Stud Book!</b>
</div>

</body></html>

 

The result I get from the code above is: http://www.virtualstudbook.co.uk/index_test.php  How can I correct this?

 

Additionally, I have a table called horses, with current data as follows: http://www.virtualstudbook.co.uk/images/horses_table.jpg

 

I would like to have a list of the breeds for each gender, showing how many results there are (if there are no results I'd still want the breed to show up with '0').

 

The current code is:

 

<?php   
        mysql_connect("*****", "*****", "*****") or die(mysql_error());  
        mysql_select_db("*****") or die(mysql_error());  

        $data = mysql_query("SELECT gender, COUNT(*) SELECT * FROM `horses` WHERE gender = 'mare' AND allowed='OK' GROUP BY breed;")  
        or die(mysql_error());  
?>

 

The current result is: http://www.virtualstudbook.co.uk/search/horse.php

 

I'd appreciate any help.

Link to comment
Share on other sites

You are getting this errors

Warning: include() [function.include]: URL file-access is disabled in the server configuration in /home/fhlinux159/v/virtualstudbook.co.uk/user/htdocs/index_test.php on line 6

 

Warning: include(http://www.virtualstudbook.co.uk/style/template.php) [function.include]: failed to open stream: no suitable wrapper could be found in /home/fhlinux159/v/virtualstudbook.co.uk/user/htdocs/index_test.php on line 6

 

Warning: include() [function.include]: Failed opening 'http://www.virtualstudbook.co.uk/style/template.php' for inclusion (include_path='.:/usr/share/pear-php5') in /home/fhlinux159/v/virtualstudbook.co.uk/user/htdocs/index_test.php on line 6

 

Check allow_url_fopen is enabled in your php.ini file, I think URL file-access is disabled in the server.

 

you can keep this line in your page and try

ini_set('allow_url_fopen', 'on');

 

And for that query error

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 'SELECT * FROM `horses` WHERE gender = 'mare' AND allowed='OK' GROUP BY ' at line 1

 

There is error in your query, see some examples for writing subqueries

http://dev.mysql.com/doc/refman/5.0/en/subqueries.html

 

 

Link to comment
Share on other sites

The php include is a strange one... I have another site with the same piece of code, hosted with the same people, works no problem.  I have looked up the details, which are below:

 

allow_url_fopen On On

allow_url_include Off Off

 

So I looked up on my host's support page how to change the allow_url_include to On:

 

Can I edit the PHP.INI file?

This file is not editable on the server and we are unable to change this for you for security reasons.

 

Bizarre. 

 

Have been playing with the count issue, and have managed to get rid of all error messages, though sadly, none of the breeds/counts show up either. 

 

       
$data = mysql_query("SELECT breed, COUNT(*) FROM horses WHERE gender='Mare' AND allowed='OK' GROUP BY breed")  
        
or die(mysql_error());  
?>

 

 

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.