Jump to content

Recommended Posts

hi everyone, i recently had to move an old website to a new host, it was built with php 4.4.8. New host is php 5.

 

there is much wrong i'm sure.... but can anyone give me some pointers regarding this code?

 

 



print "<blockquote><p class=\"PAGEHEADING\">Admin: Add an item";
print "<P><A HREF=\"index.php\">Main Menu</A> | <A HREF=\"articles.php?action=search\">Search for items</A></P>";

if ($submit) {
  if ($aid == "") {
    echo("<P>You must choose a type " .
         "for this item. Click 'Back' " .
         "and try again.</P>");
    exit();
  }

  mysql_select_db("articles");




  $sql = "INSERT INTO articles SET title='$title',description='$description',content='$content',rank='$rank',url='$url',review='$review',image='$image',online='$online',datecreated='$datecreated',B468='$B468',sky='$sky',specials='$specials',aid='$aid'";




if (mysql_query($sql)) {
    echo("<P>New article added</P>");
  } else {
    echo("<P>Error adding new article: " .
         mysql_error() . "</P>");
  }

  $jid = mysql_insert_id();

  $cats = mysql_query("SELECT id, name FROM article_cats ORDER BY name");

  while ($cat = mysql_fetch_array($cats)) {
    $cid = $cat["id"];
    $cname = $cat["name"];
    $var = "cat$cid"; // The name of the variable
    if ($$var) { // The checkbox is checked
      $sql = "INSERT IGNORE INTO article_lookup " .
             "SET JID=$jid, CID=$cid";
      $ok = mysql_query($sql);
      if ($ok) {
        echo("<P>Article added to category: $cname</P>");
      } else {
        echo("<P>Error inserting article into category $cname:" .
             mysql_error() . "</P>");
      }
    } // end of if ($$var)
  } // end of while loop



?>

<P><A HREF="<?php echo($PHP_SELF."?action=add"); ?>">Add another item</A></P><br>

<?php } else {

  mysql_select_db("articles");

  $authors = mysql_query("SELECT id, name FROM article_authors");
  $cats    = mysql_query("SELECT id, name FROM article_cats ORDER BY name");
?>

<FORM ACTION="<?php echo("add.php"); ?>" METHOD=POST>
<P><b>Enter the new item:</b><BR><br>
<TABLE>
<TR VALIGN="TOP">
<TD>Rank:</TD>
<TD><INPUT NAME="rank" TYPE="TEXT" SIZE=15 MAXLENGTH=200>
</TD>
</TR>


<TR VALIGN="TOP">
<TD>Date (y-m-d):</TD>
<TD><INPUT NAME="datecreated" TYPE="TEXT" SIZE=15 MAXLENGTH=20 value="<? echo ( date("y-m-d")); ?>"></TD>
</TR>


<TR VALIGN="TOP">
<TD>Online:</TD>
<TD><INPUT NAME="online" TYPE="checkbox" checked></TD>
</TR>



<TR VALIGN="TOP">
<TD>Title:</TD>
<TD><INPUT NAME="title" TYPE="TEXT" SIZE=65 MAXLENGTH=200></TD>
</TR>

<TR VALIGN="TOP">
<TD>Url:</TD>
<TD><INPUT NAME="url" TYPE="TEXT" SIZE=65 MAXLENGTH=200>
</TD>
</TR>

<TR VALIGN="TOP">
<TD>Image 120:</TD>
<TD><INPUT NAME="image" TYPE="TEXT" SIZE=65 MAXLENGTH=200>
</TD>
</TR>

<TR VALIGN="TOP">
<TD>Image 468:</TD>
<TD><INPUT NAME="B468" TYPE="TEXT" SIZE=65 MAXLENGTH=200>
</TD>
</TR>

<TR VALIGN="TOP">
<TD>Image SkySc:</TD>
<TD><INPUT NAME="sky" TYPE="TEXT" SIZE=65 MAXLENGTH=200>
</TD>
</TR>

<TR VALIGN="TOP">
<TD>Specials:</TD>
<TD><INPUT NAME="specials" TYPE="TEXT" SIZE=65 MAXLENGTH=200>
</TD>
</TR>

<TR VALIGN="TOP">
<TD>Description:</TD>
<TD><TEXTAREA NAME="description" ROWS=5 COLS=65 WRAP></TEXTAREA></TD>
</TR>


<TR VALIGN="TOP">
<TD>Review Page:</TD>
<TD><TEXTAREA NAME="review" ROWS=5 COLS=65 WRAP></TEXTAREA></TD>
</TR>

<TR VALIGN="TOP">
<TD>Page Head:</TD>
<TD><TEXTAREA NAME="pagehead" ROWS=5 COLS=65 WRAP></TEXTAREA></TD>
</TR>

<TR VALIGN="TOP">
<TD>Content:</TD>
<TD><TEXTAREA NAME="content" ROWS=50 COLS=65 WRAP></TEXTAREA></TD>
</TR>

<INPUT TYPE=hidden NAME="aid" VALUE="1">

<TR VALIGN="TOP">
    <td>Partners:</td>
<td>
<?php
  while ($cat = mysql_fetch_array($cats)) {
    $cid = $cat["id"];
    $cname = $cat["name"];
    echo("<INPUT TYPE=CHECKBOX NAME=cat$cid>$cid $cname<BR>\n"); 
  }
?></td>
</tr>


<TR VALIGN="TOP">
    <td> </td>
<td><INPUT TYPE=SUBMIT NAME="submit" VALUE="SUBMIT">
</td>
</tr>


</TABLE>

<br></FORM>

<?php }



 

 

many thanks for any help that you can offer

 

regards

Caz

Link to comment
https://forums.phpfreaks.com/topic/200725-moved-from-php44-to-5/
Share on other sites

After a quick look I couldn't really spot anything of concern with PHP4/5 migration, looks like you may be depending on "register globals" in some areas though - assuming that's all of the code - but that shouldn't be enabled with PHP4.4.8 anyway.

 

I'm not saying the code's fine though, certainly could do with being re-written.

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.