Help with PHP Code

6 posts by 3 authors in: Forums > CMS Builder
Last Post: September 23, 2014   (RSS)

By Joseph - September 15, 2014 - edited: September 15, 2014

Hi, looking for some help i am getting on one of the pages on my website http://www.socanews.com/music/albums/album.php?Vibezy-Riddim-326 not sure what i did wrong. thanks for any help in advance.

This is the code up to line 45:

<?php
require_once "/var/www/vhosts/socanews.com/httpdocs/cmsAdmin/lib/viewer_functions.php";
function getArtist($artistname) {

$artistname1 = mysql_real_escape_string(trim($artistname));
// $artistname=addslashes($artistname1);
list($artist, $blogMetaData) = getRecords(array(
'tableName' => 'artists',
'limit' => '1',
'where' => "title = '$artistname1'",
'allowSearch' => '0',
));
return $artist;
//print_r($artist);
}
list($albumsRecords, $albumsMetaData) = getRecords(array(
'tableName' => 'albums',
'where' => whereRecordNumberInUrl(1),
'limit' => '1',
));
$albumsRecord = @$albumsRecords[0]; // get first record
//print_r($albumsRecord);
// show error message if no matching record is found
if (!$albumsRecord) {
header("HTTP/1.0 404 Not Found");
print "Record not found!";
exit;
}

list($musicnewsRecords, $featuredartistMetaData) = getRecords(array(
'tableName' => 'news',
'limit' => '3',
'where' => "catNews LIKE '%news%' AND catNews LIKE '%entertainment%'",
'orderBy' => 'publishDate DESC',
'allowSearch' => '0',
));
function getCountrytitle($id)
{
// $query = 'title = '.$id;
list($countryRecords, $countryMetaData) = getRecords(array(
'tableName' => 'country',
'where' => "title='$id'",
'limit' => '0',
));
return $countryRecords[1];

By claire - September 18, 2014 - edited: September 18, 2014

Hi Joseph, what errors are you getting with this?

added by edit - sorry, just want to confirm if you're seeing anything other than the Record Not Found problem.

Can you attach the code for this place please?

--------------------

Claire Ryan
interactivetools.com

Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

By Joseph - September 18, 2014

Hi Claire

i have attached the actual php page as i am not sure which part of the code is giving the error. 

error occurs on this p[age - http://www.socanews.com/music/albums/album.php?8-Mile-Riddim-190

thanks
Joseph

Attachments:

album.php 46K

By rconring - September 19, 2014

Error is in line 45 where you are returning the second record from an array that is limited to 0.  if you are trying to do the same thing as for the tracks, you need to change the funcion to something like this ... I do not know how the country table constructed.

 function getCountrytitle($num)
  {
    list($countryRecords, $countryMetaData) = getRecords(array(
    'tableName'   => 'country',
    'where'       => "num ='$num'",
    // 'limit'       => '0',
    ));
    if($countryRecords){return $countryRecords['title'];}
  }

Ron Conring
Conring Automation Services
----------------------------------------
Software for Business and Industry Since 1987

By claire - September 19, 2014

That isn't going to work, Ron. The error is due to the limit parameter in the getRecords function, but getRecords returns an array even if only one record is found.

So change the function like this:

function getCountrytitle($num)
{
    list($countryRecords, $countryMetaData) = getRecords(array(
        'tableName' => 'country',
        'where' => "title='$num'",
        'limit' => 1,
    ));
    return @$countryRecords[0];
}

This still might not work if the where parameter finds nothing, but that'll be a start anyway.

--------------------

Claire Ryan
interactivetools.com

Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/