Hi again,

I have a cash gifting script that I converted to advertising instead of "gifts". So no host should have issue with it.

I went thru the session is registered thing but I don't know how to insert the newer coding. What exactly do I replace? I know about the () to [] but that's it. I know it is

$_session

or whatever but placement is my issue.

if( session_is_registered("alogin") ) {

Are they all the same in different php pages? How would you update the above code? Maybe I can use that as a guide to fix the rest. (the script is not up on site at this time)

Thanks, L-D - html guy

(this is adbanner.php)

<?php

session_start();

include "../adminheader.php";
include "../config.php";
include "../connect.php";

$name = $_POST['name'];
$url = $_POST['url'];

if( session_is_registered("alogin") ) {
        ?><table>
        <tr>
        <td width="15%" valign=top><br>
        <? include("adminnavigation.php"); ?>
        </td>
        <td valign="top" align="center"><br><br> <?
        echo "<font size=2 face='$fonttype' color='$fontcolour'><p><b><center>"; 
    $query = "insert into advertise (name,bannerurl) VALUES ('$name','$url')";
    $result = mysql_query ($query)
         or die ("Insert failed");
    echo "Your new banner has been saved.";
    ?> <p>Click <a href=banners.php>here</a> to go back<p>
    </table>
    </td>
    </tr>
    </table>
    <?
    }

else  {
    echo "Unauthorised Access!";
    }

include "../footer.php";
mysql_close($dblink);
?>

Are you trying to do this?

if( isset( $_SESSION['alogin'] ) )

Yes! But I wonder if they are all the same and if I went and did, say 20 fixes and it was wrong there would wacky error messages and hard to clean it up. I have a zipped "original" script in a safe place.

I guess it should be online so the changes can be checked one at a time. I'll do that.

Thanks,
L-D

Ok, put it in a folder to play with it, already had a db.

First I saw one error with session reg. I made this change...

if( isset( $_SESSION['ulogin'] ) )  // if( session_is_registered("ulogin") )

I changed the a to u and commented out the original. It worked! It's not showing as a error anymore.
Not too bad for a PHP dummie!

For the others I get

Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /home/content/13/11394913/html/fixscript/config.php on line 6

Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /home/content/13/11394913/html/fixscript/config.php on line 8

Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /home/content/13/11394913/html/fixscript/config.php on line 6

Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /home/content/13/11394913/html/fixscript/config.php on line 8

Also (this was below by the login links etc.)

Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /home/content/13/11394913/html/fixscript/index.php on line 29


 Here is config.php

 <?php



include "connect.php";



$settings = mysql_query ('select * from settings');
$settingrecord = mysql_fetch_array($settings);

while ($settingrecord = mysql_fetch_array($settings)) {
    switch ($settingrecord["name"]) {
    case "sitename";
        $sitename = $settingrecord["setting"];
        break;
    case "adminid";
        $adminid = $settingrecord["setting"];
        break;
    case "adminpw";
        $adminpw = $settingrecord["setting"];
        break;
    case "paypal";
        $paypal = $settingrecord["setting"];
        break;
    case "stormpay";
        $stormpay = $settingrecord["setting"];
        break;
    case "safepay";
        $safepay = $settingrecord["setting"];
        break;
    case "solidtrust";
        $solidtrust = $settingrecord["setting"];
        break;
    case "adminemail";
        $adminemail = $settingrecord["setting"];
        break;
           case "prointerval";
        $prointerval = $settingrecord["setting"];
        break;
    case "basecolour";
        $basecolour = $settingrecord["setting"];
        break;
    case "contrastcolour";
        $contrastcolour = $settingrecord["setting"];
        break;
    case "fonttype";
        $fonttype = $settingrecord["setting"];
        break;
    case "fontcolour";
        $fontcolour = $settingrecord["setting"];
        break;
    case "freepost";
        $freepost = $settingrecord["setting"];
        break;
    case "propost";
        $propost = $settingrecord["setting"];
        break;
    case "domain";
        $domain = $settingrecord["setting"];
        break;
    case "com1";
$com1 = $settingrecord["setting"];
        break;
    case "com2";
            $com2 = $settingrecord["setting"];
        break;
    case "com3";
    $com3 = $settingrecord["setting"];
        break;
    case "com4";
    $com4 = $settingrecord["setting"];
        break;
    case "com5";
    $com5 = $settingrecord["setting"];
        break;
    case "ups";
$ups = $settingrecord["setting"];
        break;
    case "adminfee";
    $adminfee = $settingrecord["setting"];
        break;
    case "rand";
     $rand = $settingrecord["setting"];
       break;
    }
}



    if( isset( $_SESSION['ulogin'] ) )  // if( session_is_registered("ulogin") )    
{
    $userinfo=mysql_query ("select * from members where userid='".$_SESSION[uname]."'");
    $userrecord=mysql_fetch_array($userinfo);

    $id=$userrecord["id"];
    $name=$userrecord["name"];
    $contact_email=$userrecord["contact_email"];
    $subscribed_email=$userrecord["subscribed_email"];
    $paypal_email=$userrecord["paypal_email"];
    $stormpay_email=$userrecord["stormpay_email"];
    $safepay_email=$userrecord["safepay_email"];
    $solidtrust_email=$userrecord["solidtrust_email"];
    $contact_email=$userrecord["contact_email"];
    $password=$userrecord["pword"];
    $userid=$userrecord["userid"];
    $status=$userrecord["status"];
    $referid=$userrecord["referid"];
    $verified=$userrecord["verified"];
    $solos=$userrecord["solos"];
    $points=$userrecord["points"];
    $commission=$userrecord["commission"];
    $ip=$userrecord["ip"];
    $joindate=$userrecord["joindate"];
    $lastpost=$userrecord["lastpost"];
    $subscribed=$userrecord["subscribed"];
    $memtype=$userrecord["memtype"];
    $up=$userrecord["up"];
    $random=$userrecord["random"];
    $hits_unique=$userrecord["hits_unique"];
$hits_visitor=$userrecord["hits_visitor"];  

}

?>

Here is where I need (more) help.

Thanks,
L-D

Opps, here is line 29 of index and the index file.

 $line1 = mysql_fetch_array($result1);
         $htmlcode = $line1["htmlcode"];







<?php


include "config.php";
if ($_GET['referid']) {

    if($_COOKIE['referid']!=$_GET['referid']) mysql_query("UPDATE members SET hits_unique=hits_unique+1,hits_visitor=hits_visitor+1 WHERE userid='".$_GET['referid']."'");
    else mysql_query("UPDATE members SET hits_visitor=hits_visitor+1 WHERE userid='".$_GET['referid']."'");

    setcookie('referid', $_GET['referid'], time()+365*24*60*60);
    setcookie('referrer', $_SERVER['HTTP_REFERER'], time()+365*24*60*60);

}

include "header.php";
include "style.php";

    ?>
    <?
    mysql_query("UPDATE members SET hits_unique=hits_unique+1,hits_visitor=hits_visitor+1 WHERE userid=<? echo $referid; ?> ");

    ?>

    <center> 
<?
    $query1 = "SELECT * FROM pages WHERE name='Index (Main) Page'";
    $result1 = mysql_query ($query1);

    $line1 = mysql_fetch_array($result1);
         $htmlcode = $line1["htmlcode"];



    echo $htmlcode;

    ?> <p>&nbsp;</p>

                    </td>
                </tr>
              </tbody></table>
              </td>
            </tr>
          </tbody></table>
        </div>
      </td>
    </tr>
  </tbody></table>

<?

include "footer.php";
mysql_close($dblink);
?> 

Thanks,
L-D

$_SESSION[uname] on line 98 should be $_SESSION['uname']

mysql_query("UPDATE members SET hits_unique=hits_unique+1,hits_visitor=hits_visitor+1 WHERE userid=<? echo $referid; ?> ");

should be

mysql_query("UPDATE members SET hits_unique=hits_unique+1,hits_visitor=hits_visitor+1 WHERE userid=$referid;");

Ok,

Did the repairs. Still get

Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /home/content/13/11394913/html/fixscript/config.php on line 6

Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /home/content/13/11394913/html/fixscript/config.php on line 8

Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /home/content/13/11394913/html/fixscript/config.php on line 6

Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /home/content/13/11394913/html/fixscript/config.php on line 8

There are more errors when clicking login, signup, faq, etc.

Plus

Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /home/content/13/11394913/html/fixscript/index.php on line 29

down under the links.

:-/
L-D

Show what's in connect.php. Appears the query in config.php is failing too. BTW, I recommend to use <?php instead of <?

If you'd added error handling to your query, you would have seen this much earlier.

Member Avatar for Zagga

Hi again.

Understanding the error messages you get is key to debugging as they usually tell you what the problem is, and where it was found.

I'll use your first error message as an example:

Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /home/content/13/11394913/html/fixscript/config.php on line 6

First of all, it says it is a WARNING, so PHP encountered a problem but it tried to carry on running the rest of the code anyway. If it had said ERROR the problem was so bad PHP couldn't carry on running any more of our code, and exited.

Next, the message shows the function it was trying to run when it found the problem, in our case mysql_fetch_array()

The message then shows us what the mysql_fetch_array() function expected as an input (it expects a resource containing the data we tried to get from the database), and what input it was actually given (it was given a boolean, which is TRUE or FALSE)

Lastly the message shows us which line PHP got to before it encountered a problem. This means the problem is around this line (usually before it). Looking at config.php we can see there is, indeed, a call to the mysql_fetch_array() function around line 6 (this actually shows on line 14 on the code you included above).

So, PHP expected $settingsrecord to be a resource, but it was actually FALSE. This would have happened if the query on the line before it failed, maybe because of a bad connection in connect.php.
To check this and get a more enlightening error message, you should add error handling as pritaeas advised (and linked to a great post that will probably help you quite a bit).

Change the query (on ine 13 of config.php) to:
$settings = mysql_query ('select * from settings') or die(mysql_error());

You will probably find that when you fix one bug it either solves a few error messages at once, or it creates a few more. Don't be disheartened by this. Carry on fixing them one by one and by the end you should have a working app, a greater understanding of debugging and a deeper knowledge of your own code.

Hi!!

Ok, I'm a bit confused... this is the top of config.php

 <?php

include "connect.php";

    $settings = mysql_query ('select * from settings');
    $settingrecord = mysql_fetch_array($settings);

    while ($settingrecord = mysql_fetch_array($settings)) {
        switch ($settingrecord["name"]) {
        case "sitename";
            $sitename = $settingrecord["setting"];
            break;
        case "adminid";

the last line is 13. It seems that ln 5 is the item to be replaced. I goofed on config where I knocked the numbering off by including stuff at the top of the code.

On your comments, fantastic! But, I'm a HTML guy, so I can't benefit BUT lots of members will read this and they will learn from it.

Please tell me if ln 5 should be replaced.

Thanks,
L-D

$settings = mysql_query ('select * from settings') or die('This seems to be your problem');

Member Avatar for Zagga

Yes, line 5 is the one to change.

I'm a HTML guy, so I can't benefit

A HTML guy that is also working with PHP, it seems :)

This is what shows up.

Table 'uadb.settings' doesn't exist

otherwise blank pg.

Thanks,
L-D

Member Avatar for Zagga

The message is showing that you don't have a table called settings in your database called uadb

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.