Newb advice

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
MiniMonty
Forum Contributor
Posts: 196
Joined: Thu Sep 03, 2009 9:09 am
Location: UK

Re: Newb advice

Post by MiniMonty »

Where ?
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: Newb advice

Post by jackpf »

Instead of

Code: Select all

if($_GET['something'] || $_POST['something']);
//use
if(isset($_GET['something']) || isset($_POST['something']));
MiniMonty
Forum Contributor
Posts: 196
Joined: Thu Sep 03, 2009 9:09 am
Location: UK

Re: Newb advice

Post by MiniMonty »

Doh ! Of course - works a treat.
Thanks
MiniMonty
Forum Contributor
Posts: 196
Joined: Thu Sep 03, 2009 9:09 am
Location: UK

Re: Newb advice

Post by MiniMonty »

That's ironed out a few bugs across the system...

Any ideas on this error that has popped up recently on my profile and edit profile scripts ?

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource
pankajnagarkoti70
Forum Newbie
Posts: 4
Joined: Fri Sep 25, 2009 5:31 pm

Re: Newb advice

Post by pankajnagarkoti70 »

Any advice on how to name and number the uploaded files rather than give them a date stamp ?
MiniMonty
Forum Contributor
Posts: 196
Joined: Thu Sep 03, 2009 9:09 am
Location: UK

Re: Newb advice

Post by MiniMonty »

pankajnagarkoti70 wrote:Any advice on how to name and number the uploaded files rather than give them a date stamp ?
read the first couple of pages of posts on this thread because I had the same issue and it was solved here.

Best wishes
Monty
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: Newb advice

Post by jackpf »

Yeah this seems to be a bit of a monster thread lol.
MiniMonty wrote:Any ideas on this error that has popped up recently on my profile and edit profile scripts ?

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource
Post your code.
MiniMonty
Forum Contributor
Posts: 196
Joined: Thu Sep 03, 2009 9:09 am
Location: UK

Re: Newb advice

Post by MiniMonty »

Herewith...
it's the second version of line 37 (if that makes any sense).
it's actually line 137 but the line numbers on this forum seem to start again at 100.

Code: Select all

 
<?php 
session_start(); 
 
// Connect to database
include_once "scripts/connect_to_mysql.php";
// $host = "localhost";
//   $user="blahblahblah";
//   $password="blahblahblah";
//   $database="blahblahblah";
//   $connection = mysql_connect($host, $user,$password)
//              or die ("Couldn't connect to server.");
//   $db = mysql_select_db($database, $connection)
//               or die ("Couldn't select the database.");
// Now let's initialize vars to be printed to page in the HTML section so our script does not return errors 
// they must be initialized in some server environments
$id = "";
$firstname = "";
$lastname = "";
$bio_body = "";
$website = "";
$youtube = "";
$user_pic = "";
$blabberDisplayList = "";
// If coming from category page
//if ($_GET['id']) {
    
     //$id = $_GET['id'];
     if(isset($_GET['id']) || isset($_POST['id']));
 
 else if (isset($_SESSION['id'])) {
 
    
     $id = $_SESSION['id'];
 
} else {
    
   include_once "index.php";
   exit();
}
$id = mysql_real_escape_string($id);
$id = eregi_replace("`", "", $id);
$sql = mysql_query("SELECT * FROM myMembers WHERE id='$id'");
 
while($row = mysql_fetch_array($sql)){ 
 
    $firstname = $row["firstname"];
    $lastname = $row["lastname"];   
    $email = $row["email"];
    //$email = "<a href=\"mailto:$email\"><u><font color=\"#006600\">Mail</font></u></a>";  
    $sign_up_date = $row["sign_up_date"];
    $sign_up_date = strftime("%b %d, %Y", strtotime($sign_up_date));
    $last_log_date = $row["last_log_date"];
    $last_log_date = strftime("%b %d, %Y", strtotime($last_log_date));  
    $bio_body = $row["bio_body"];   
    $website = $row["website"];
    $youtube = $row["youtube"];
    ///////  Mechanism to Display Pic. See if they have uploaded a pic or not  //////////////////////////
    $check_pic = "members/$id/image01.jpg";
    $default_pic = "members/0/image01.jpg";
    if (file_exists($check_pic)) {
    $user_pic = "<img src=\"$check_pic\" width=\"200px\" />"; // forces picture to be 100px wide and no more
    } else {
    $user_pic = "<img src=\"$default_pic\" width=\"200px\" />"; // forces default picture to be 100px wide and no more
    }
    ///////  Mechanism to Display Youtube Channel or not  //////////////////////////
    if ($youtube == "") {
    $youtubeChannel = "<br />This user has no YouTube channel yet.";
    } else {
    $youtubeChannel = ' <script src="http://www.gmodules.com/ig/ifr?url=http://www.google.com/ig/modules/youtube.xml&up_channel=' . $youtube . '&synd=open&w=290&h=370&title=&border=%23ffffff%7C3px%2C1px+solid+%23999999&output=js"></script>  '; // forces default picture to be 100px wide and no more
    }   
 
} // close while loop
 
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
$style_sheet = "default";
?>
<?php
// Place Blab post into database
$blab_outout_msg = "";
if ($_POST['blab_field'] != ""){
    
     // Delete any blabs over 20 for this member
     $sqlDeleteBlabs = mysql_query("SELECT * FROM blabbing WHERE mem_id='$id' ORDER BY blab_date DESC LIMIT 50");
     
     $bi = 1;
     
     while ($row = mysql_fetch_array($sqlDeleteBlabs)) {
         
         $blad_id = $row["id"];
         if ($bi > 20) {
             
              $deleteBlabs = mysql_query("DELETE FROM blabbing WHERE id='$blad_id'");
         }
         $bi++;
     }
     // End Delete any blabs over 20 for this member
    
     $blab_field = $_POST['blab_field'];
     $blab_field = stripslashes($blab_field);
     $blab_field = strip_tags($blab_field);
     $blab_field = mysql_real_escape_string($blab_field);
     $blab_field = eregi_replace("'", "'", $blab_field);
     
     $sql = mysql_query("INSERT INTO blabbing (mem_id, the_blab, blab_date) 
     VALUES('$id','$blab_field', now())")  
     or die (mysql_error());
     
     $blab_outout_msg = "Your Blab has been posted!";
}
 
?>
 
 
 
 
<?php
$the_blab_form = "";
if (isset($_SESSION['id'])) {
    
    if ($_SESSION['id'] == $id){
     $the_blab_form = '
     ' . $blab_outout_msg . '
 
<form action="profile.php" method="post" enctype="multipart/form-data" name="blab_from">
<textarea name="blab_field" rows="3" style="width:97%;"></textarea>
Blab away  (220 char max) <input name="submit" type="submit" value="submit" />
</form>';
    }
}
 
?>
 
<?php
$sql_blabs = mysql_query("SELECT id, mem_id, the_blab, blab_date FROM blabbing WHERE mem_id='$id' ORDER BY blab_date DESC LIMIT 20");
 
while($row = mysql_fetch_array($sql_blabs)){
    
    $blabid = $row["id"];
    $uid = $row["mem_id"];
    $the_blab = $row["the_blab"];
    $blab_date = $row["blab_date"];
    $blab_date = strftime("%b %d, %Y, %Y %I:%M:%S %p", strtotime($blab_date));
    
                $blabberDisplayList .= '
                    <table width="100%" align="center" cellpadding="4" bgcolor="#A6D2FF">
        <tr>
          <td width="93%" bgcolor="#D9ECFF"><span style="font-size:10px; font-weight:bold; color:#A6A6A6;">' . $blab_date . '</span><br />
            ' . $the_blab . '</td>
        </tr>
      </table>';
    
}
 
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta name="Description" content="Profile for <?php print "$firstname $lastname"; ?>" />
<meta name="Keywords" content="<?php print "$firstname, $lastname"; ?>" />
<meta name="rating" content="General" />
<meta name="ROBOTS" content="All" />
<title>Site Profile for <?php print "$firstname $lastname"; ?></title>
<link href="style_profiles/<?php print "$style_sheet"; ?>.css" rel="stylesheet" type="text/css" />
<link rel="icon" href="http://www.yourdomain.com/favicon.ico" type="image/x-icon" />
<link rel="shortcut icon" href="http://www.yourdomain.com/favicon.ico" type="image/x-icon" />
</head>
 
<body>
<?php include_once "header_template.php"; ?>
<table width="950" align="center">
  <tr>
    <td width="758"><br />
      <table width="90%" border="0" align="center" cellpadding="6">
      <tr>
        <td width="48%" valign="top">
        <?php print "$firstname $lastname"; ?>
        <br />
        <?php print "$user_pic"; ?>
        <br />
        Member Since: <?php print "$sign_up_date"; ?>
        <br />
       <?php print "$youtubeChannel"; ?>
       </td>
        <td width="52%" valign="top">
        <br />
        <strong><u><?php print "$firstname $lastname"; ?>'s Blabs:</u></strong>
        <br />
        <?php print "$the_blab_form"; ?>
        <div style="width:100%; height:180px; overflow:auto; overflow-x:hidden;">
        <?php print "$blabberDisplayList"; ?>
        </div>
        <br />
        <br />
        <strong><u><?php print "$firstname $lastname"; ?>'s Location Details:</u></strong>
        <br />
        <br />
        <strong><u>About <?php print "$firstname $lastname"; ?></u></strong>
        <br />
        <?php print "$bio_body"; ?>
        <br />
 
        
        </td>
      </tr>
      <tr>
        <td colspan="2" valign="top">&nbsp;</td>
        </tr>
      </table>
      <p><br />
        <br />
    </p>
      <p>&nbsp;</p>
      <p><br />
        <br />
        <br />
        <br />
        <br />
      </p></td>
    <td width="180" valign="top"><?php include_once "right_AD_template.php"; ?></td>
  </tr>
</table>
<?php include_once "footer_template.php"; ?>
</body>
</html>
 
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: Newb advice

Post by califdon »

Monty, I just wanted to say that I really admire your site design. Is that from a template or is that totally from scratch? I did notice one tiny typo in your "Learn It" box on the first page ("shedule"). Also with regard to those boxes, I noticed that the 1st and 3rd boxes' text changes to darker color when the mouse hovers, but not the 2nd and 4th box, which I found a bit disoncerting. At first I thought it might be a matter of a "visited" link, but it doesn't appear to be that. Just thought I'd mention those small things.
User avatar
Mirge
Forum Contributor
Posts: 298
Joined: Thu Sep 03, 2009 11:39 pm

Re: Newb advice

Post by Mirge »

califdon wrote:Monty, I just wanted to say that I really admire your site design. Is that from a template or is that totally from scratch? I did notice one tiny typo in your "Learn It" box on the first page ("shedule"). Also with regard to those boxes, I noticed that the 1st and 3rd boxes' text changes to darker color when the mouse hovers, but not the 2nd and 4th box, which I found a bit disoncerting. At first I thought it might be a matter of a "visited" link, but it doesn't appear to be that. Just thought I'd mention those small things.
Ha I forgot I even contributed to this thread.

What's the URL? I went through the first few pages, but didn't find it. I'm curious, calif :)
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: Newb advice

Post by jackpf »

Try putting

Code: Select all

var_dump($sql_blabs);
on line 136.

Also, put "or die(mysql_error());" after the query.
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: Newb advice

Post by califdon »

Mirge wrote:What's the URL? I went through the first few pages, but didn't find it. I'm curious, calif :)
You gave up too soon :wink: (page5, I believe):
Re: Newb advice

Postby MiniMonty on Fri Sep 25, 2009 2:09 pm
Hi all,
...
As you know by now I'm trying to build a membership system - if you feel like joining up it's free and it's here:
http://%20www.shutterbugclub.com
it's going OK but now I'm stumbling over the member profile page.
...but remove the space before "www". Dunno how that got in there.
User avatar
Mirge
Forum Contributor
Posts: 298
Joined: Thu Sep 03, 2009 11:39 pm

Re: Newb advice

Post by Mirge »

califdon wrote:
Mirge wrote:What's the URL? I went through the first few pages, but didn't find it. I'm curious, calif :)
You gave up too soon :wink: (page5, I believe):
Re: Newb advice

Postby MiniMonty on Fri Sep 25, 2009 2:09 pm
Hi all,
...
As you know by now I'm trying to build a membership system - if you feel like joining up it's free and it's here:
http://%20www.shutterbugclub.com
it's going OK but now I'm stumbling over the member profile page.
...but remove the space before "www". Dunno how that got in there.
Ah ok thanks.

Yeah, that's not half bad. The text is a little big for me... and I'd probably have used a different font. The colors work nicely together though!
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: Newb advice

Post by jackpf »

Kinda weird though - the layout seems to jump up and down a bit for different pages.
MiniMonty
Forum Contributor
Posts: 196
Joined: Thu Sep 03, 2009 9:09 am
Location: UK

Re: Newb advice

Post by MiniMonty »

jackpf wrote:Kinda weird though - the layout seems to jump up and down a bit for different pages.
True - It's very much a work in progress.
Most of the pages are built in Flash, some in html and the design is about 75% done.
I'm concentrating on the back end at the moment trying to get the membership system working
with view and edit profile, members avatar pics etc., but I appreciate all the comments.
Give it a month or so (in between 'real' work) and it should be ready to rock.

The design is all my own but the functionality is based on a tutorial for a complete site
I found here:
http://www.webintersect.com/parts.php

Best wishes
Monty
Post Reply