Kevin-J Posted February 10, 2007 Share Posted February 10, 2007 Why do I get this message error? Fatal error: Cannot redeclare list_categories() (previously declared in /home/darkness/public_html/forums/modules/functions.php:4) in /home/darkness/public_html/forums/modules/functions.php on line 3 here is functions.php <?php function list_categories() { $query = mysql_query("SELECT * FROM tutorials_categories"); while($row = mysql_fetch_array($query)) { $query2 = mysql_query("SELECT * FROM tutorials WHERE cat_id = '$row[id]'"); if(mysql_num_rows($query2) == 0) { echo" $row[catname] |"; } else { echo" <a href='$self?action=cat&id=$row[id]'>$row[catname]</a> |"; } } } function list_unval_tutorials() { echo"<strong>Un-Validated tutorials</strong>"; $query = mysql_query("SELECT * FROM tutorials WHERE valid = '0' ORDER BY id DESC"); while($row = mysql_fetch_array($query)) { echo" <table width='100%'> <tr> <td width='60%'> $row[tutname] </td> <td width='10%'> <a href='$self?action=mod&id=$row[id]'>Modify</a> </td> <td width='10%'> <a href='$self?action=delete&id=$row[id]'>Delete</a> </td> <td width='10%'> <a href='$self?action=view&id=$row[id]'>View</a> </td> <td width='10%'> <a href='$self?action=validate&id=$row[id]'>Validate?</a> </td> </tr> </table> "; } } function list_val_tutorials() { echo"<strong>Validated tutorials</strong>"; $query = mysql_query("SELECT * FROM tutorials WHERE valid = '1' ORDER BY id DESC"); while($row = mysql_fetch_array($query)) { echo" <table width='100%'> <tr> <td width='60%'> $row[tutname] </td> <td width='10%'> <a href='$self?action=mod&id=$row[id]'>Modify</a> </td> <td width='10%'> <a href='$self?action=delete&id=$row[id]'>Delete</a> </td> <td width='10%'> <a href='$self?action=view&id=$row[id]'>View</a> </td> </tr> </table> "; } echo""; } function del_tutorial() { if(!isset($_POST['delete'])) { if($_GET['id']) { $id = (int)$_GET['id']; $query = "DELETE FROM tutorials WHERE id = '$id' LIMIT 1"; mysql_query($query); echo"Tutorial Deleted"; } } } function val_tutorial() { if(!isset($_POST['validate'])) { if($_GET['id']) { $id = (int)$_GET['id']; $query = "UPDATE tutorials SET valid = '1' WHERE id = '$id' LIMIT 1"; mysql_query($query); echo"Tutorial Validated"; } } } function view_tutorial() { if(!isset($_POST['view'])) { if($_GET['id']) { $id = (int)$_GET['id']; $query = mysql_query("SELECT * FROM tutorials WHERE id = '$id' LIMIT 1"); while($row = mysql_fetch_array($query)) { echo"You are viewing: <b>$row[tutname]</b> $row[tuttext] Some other info: Author: $row[authname] | Date posted: $row[date] | "; } } } } function add_tut() { if(!isset($_POST['add_tut'])) { echo" <form action='$self?action=add_tut' name='addtutorials' method='post'> <table> <tr> <td> Tutorial name: </td> </tr> <tr> <td> <input type='text' name='tutname'> </td> </tr> <td> Author name: </td> </tr> <tr> <td> <input type='text' name='authname'> </td> </tr> <tr> <td> Categories: </td> </tr> <tr> <td> <select name='category'>"; $query = mysql_query("SELECT * FROM tutorials_categories ORDER BY id ASC"); while($row = mysql_fetch_array($query)) { echo"<option value='$row[id]'>$row[catname]"; } echo" </select> </td> </tr> <tr> <td> Image: </td> </tr> <tr> <td> <input type='text' name='image'> (40x40px) </td> </tr> <tr> <td> Email: </td> </tr> <tr> <td> <input type='text' name='email'> </td> </tr> <tr> <td> Tutorial Link: </td> </tr> <tr> <td> <textarea cols='50' rows='1' name='tuttext'></textarea><br /> </td> </tr> <tr> <td> Short description: </td> </tr> <tr> <td> <textarea cols='50' rows='5' name='shortdes'></textarea><br /> </td> </tr> <tr> <td> <input type='submit' name='add_tutorials' value='submit tutorial'> </td> </tr> </table> </form>"; } elseif(isset($_POST['add_tutorials'])) { $tutname = mysql_real_escape_string(strip_tags($_POST['tutname'])); $authname = mysql_real_escape_string(strip_tags($_POST['authname'])); $image = mysql_real_escape_string(strip_tags($_POST['image'])); $email = mysql_real_escape_string(strip_tags($_POST['email'])); $category = mysql_real_escape_string(strip_tags($_POST['category'])); $tuttext = $_POST['tuttext']; $shortdes = $_POST['shortdes']; $date = date("d.m.y"); $error = array(); if(empty($tutname)) { $error[] = "Please enter your tutorial name."; } if(empty($authname)) { $error[] = "Please enter your (the author's) name."; } if(empty($image)) { $error[] = "Please enter an image."; } if(empty($tuttext)) { $error[] = "Hello. You seem to have entered nothing into the tutorial link area."; } if(empty($shortdes)) { $error[] = "Enter a short description."; } if(count($error)>0) { echo"<font size='3' color='#CC0000'>ERROR:</font>"; foreach($error as $error2) echo"$error2"; } else { $mysql = "INSERT INTO tutorials(tutname, email, authname, image, tuttext, shortdes, valid, cat_id, date, views) VALUES('$tutname', '$email', '$authname', '$image', '$tuttext', '$shortdes', '0', '$category', '$date', '0')"; mysql_query($mysql); echo"Your tutorial has successfully been submitted for valadation."; } } } function mod_tut() { if(!isset($_POST['modify'])) { if($_GET['id']) { $id = (int)$_GET['id']; $query = mysql_query("SELECT * FROM tutorials WHERE id = '$id' LIMIT 1"); while($row = mysql_fetch_array($query)) { echo" <form name='modify' action='$self?action=mod&id=$row[id]' method='post'> <table> <tr> <td> Tutorial name: </td> </tr> <tr> <td> <input type='text' name='modtutname' value='$row[tutname]'> </td> </tr> <td> Author name: </td> </tr> <tr> <td> <input type='text' name='modauthname' value='$row[authname]'> </td> </tr> <tr> <td> Image: </td> </tr> <tr> <td> <input type='text' name='modimage' value='$row[image]'>(40x40px) </td> </tr> <tr> <td> Email: </td> </tr> <tr> <td> <input type='text' name='modemail' value='$row[email]'> </td> </tr> <tr> <td> Tutorial Text: </td> </tr> <tr> <td> <textarea cols='50' rows='20' name='modtuttext'>$row[tuttext]</textarea> </td> </tr> <tr> <td> Short description: </td> </tr> <tr> <td> <textarea cols='50' rows='5' name='modshortdes'>$row[shortdes]</textarea> </td> </tr> <tr> <td> <input type='submit' name='modify' value='modify'> </td> </tr> </table> </form>"; } } } elseif(isset($_POST['modify'])) { $modtutname = mysql_real_escape_string(strip_tags($_POST['modtutname'])); $modauthname = mysql_real_escape_string(strip_tags($_POST['modauthname'])); $modimage = mysql_real_escape_string(strip_tags($_POST['modimage'])); $modemail = mysql_real_escape_string(strip_tags($_POST['modemail'])); $modcategory = mysql_real_escape_string(strip_tags($_POST['modcategory'])); $modtuttext = $_POST['modtuttext']; $modshortdes = $_POST['modshortdes']; $err3 = array(); if(empty($modtutname)) { $error[] = "Please enter your tutorial name."; } if(empty($modauthname)) { $error[] = "Please enter your (the author's) name."; } if(empty($modimage)) { $error[] = "Please enter an image."; } if(empty($modtuttext)) { $error[] = "Hello. You seem to have entered nothing into the tutorial text area."; } if(empty($modshortdes)) { $error[] = "Enter a short description."; } if(count($err3)>0) { echo"ERROR:"; foreach($err3 as $err5) echo"$err5"; } else { if($_GET['id']) { $id = (int)$_GET['id']; $sql1 = "UPDATE tutorials SET tutname = '$modtutname' WHERE id = '$id'"; $sql2 = "UPDATE tutorials SET authname = '$modauthname' WHERE id = '$id'"; $sql3 = "UPDATE tutorials SET image = '$modimage ' WHERE id = '$id'"; $sql4 = "UPDATE tutorials SET email = '$modemail ' WHERE id = '$id'"; $sql5 = "UPDATE tutorials SET category = '$modcategory' WHERE id = '$id'"; $sql6 = "UPDATE tutorials SET tuttext = '$modtuttext' WHERE id = '$id'"; $sql7 = "UPDATE tutorials SET shortdes = '$modshortdes ' WHERE id = '$id'"; mysql_query($sql1); mysql_query($sql2); mysql_query($sql3); mysql_query($sql4); mysql_query($sql5); mysql_query($sql6); mysql_query($sql7); echo"Tutorial successfully updated."; } } } } function add_cat() { if(!isset($_POST['add_cat'])) { echo" <form action='$self?action=add_cat' name='addcategories' method='post'> <table> <tr> <td> Tutorial name: </td> </tr> <tr> <td> <input type='text' name='catname'> </td> </tr> <tr> <td> <input type='submit' name='add_categories' value='submit category'> </td> </tr> </table> </form>"; } elseif(isset($_POST['add_categories'])) { $catname = mysql_real_escape_string(strip_tags($_POST['catname'])); $error = array(); if(empty($catname)) { $error[] = "Please enter your tutorial name."; } if(count($error)>0) { echo"<font size='3' color='#CC0000'>ERROR:</font>"; foreach($error as $error2) echo"$error2"; } else { $mysql = "INSERT INTO tutorials_categories(catname) VALUES('$catname')"; mysql_query($mysql); echo"Your category has successfully been submitted."; } } } ?> Link to comment https://forums.phpfreaks.com/topic/37873-fatal-error/ Share on other sites More sharing options...
trq Posted February 10, 2007 Share Posted February 10, 2007 How are you including this file? Use include_once() as it seems you may be including it twice. Link to comment https://forums.phpfreaks.com/topic/37873-fatal-error/#findComment-181323 Share on other sites More sharing options...
Kevin-J Posted February 10, 2007 Author Share Posted February 10, 2007 Alright umm..here is a code that includes it.. <?php include"connect.php"; include"functions.php"; list_categories(); switch($_GET['cat']) { case"$row[id]"; if(!isset($_POST['$row[id]'])) { if($_GET['id']) { $id = (int)$_GET['id']; $query3 = mysql_query("SELECT * FROM tutorials WHERE valid = '1' AND cat_id = '$id' ORDER BY id DESC"); while($row = mysql_fetch_array($query3)) { echo" <table width='100%'> <tr> <td width='52'> <img src='$row[image]' alt=''> </td> <td> <b><a href='viewtut.php?action=view&id=$row[id]'>$row[tutname]</a></b> $row[shortdes]. Author: <b>$row[author]</b> | Views: <b>$row[views]</b> | Date: <b>$row[date]</b> | </td> </tr> </table>"; } } } } ?> Link to comment https://forums.phpfreaks.com/topic/37873-fatal-error/#findComment-181324 Share on other sites More sharing options...
Kevin-J Posted February 10, 2007 Author Share Posted February 10, 2007 anyone? Link to comment https://forums.phpfreaks.com/topic/37873-fatal-error/#findComment-181567 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.