Jump to content

digitalgod

Members
  • Posts

    374
  • Joined

  • Last visited

    Never

Everything posted by digitalgod

  1. hey Ken, I tried everything in my form htmlentities which displayed A-TRAK \\\"SUNGLASSES ARE A MUST TOUR\\\" so it said it doesn't exist in my database also tried addslashes but only gave me \\\\\\ I tried switching ' with " in my form but gave me the same result as htmlentities.... why is it so complicated to make this thing work :(
  2. I really appreciate your help Ken but it's still doing the same thing...... it's really getting frustrating. admin.php [code] case "newevent";       $process=$_POST['process'];         if ($process == "yes") {         $club=$_POST['club_name'];         $name=$_POST['event_name'];         $month=$_POST['month'];         $day=$_POST['day'];         $date=$month.'-'.$day.'-'.'06';         $time=$_POST['time'];         $performers=$_POST['performers'];         $djs =$_POST['djs'];         $promoter=$_POST['promoter'];         $style=$_POST['style'];         $price=$_POST['cover'];         $dress=$_POST['dress'];         $notes=$_POST['notes'];         $buy=$_POST['buy'];         $guest=$_POST['guestlist'];         $flyer1=$_POST['flyer1'];         $flyer2=$_POST['flyer2'];         $flyer3=$_POST['flyer3'];         $flyer4=$_POST['flyer4'];         $type=$_POST['type'];         $query = "SELECT * FROM ".$prefix."events WHERE name='" . mysql_real_escape_string($name) . "'";          $result= mysql_query($query) or die("Problem with the query: $query<br>" . mysql_error());          $row=mysql_fetch_assoc($result);          if ($row['id'] != "") {           $tmpl->add_template("event_no");           }           else {                        $qtmp = array(); foreach($_POST as $k => $v)     switch($k) {         case 'club_name':             if (trim(stripslashes($v)) != '')                 $qtmp[] = "club ='" . mysql_real_escape_string(trim(stripslashes($v))) . "'";             break;         case 'event_name':             if (trim(stripslashes($v)) != '')                 $qtmp[] = "name ='" . mysql_real_escape_string(trim(stripslashes($v))) . "'";             break;         case 'djs':         case 'performers':         case 'promoter':         case 'dress':         case 'notes':         case 'buy':         case 'guestlist':         case 'flyer1':         case 'flyer2':         case 'flyer3':         case 'flyer4':               } $query = "INSERT INTO ".$prefix."events set " . implode(', ',$qtmp); $result = mysql_query($query) or die("Problem with the query: $query<br>" . mysql_error());                                $tmpl->add_template("club_success");           }         }         else {         $tmpl->add_template("event_form");         }       break;       case "editevent":       $process=$_POST['process'];         if ($process == "yes") {         $process_b=$_POST['process_b'];         $name=$_POST['ename'];           if ($process_b == "yes") {           $new_club=$_POST['club_name'];           $new_name=$_POST['event_name'];           $new_month=$_POST['month'];           $new_day=$_POST['day'];           $new_date=$month.'-'.$day.'-'.'06';           $new_time=$_POST['time'];           $new_performers=$_POST['performers'];           $new_djs =$_POST['djs'];           $new_promoter=$_POST['promoter'];           $new_style=$_POST['style'];           $new_price=$_POST['cover'];           $new_dress=$_POST['dress'];           $new_notes=$_POST['notes'];           $new_buy=$_POST['buy'];           $new_guest=$_POST['guestlist'];           $new_flyer1=$_POST['flyer1'];           $new_flyer2=$_POST['flyer2'];           $new_flyer3=$_POST['flyer3'];           $new_flyer4=$_POST['flyer4'];           $new_type=$_POST['type'];           if (strlen($new_name) < 4 ){             $tmpl->add_template("edituser_tooshort");             }             else {             mysql_query("UPDATE ".$prefix."events SET club='$new_club',name='$new_name',date='$new_date',time='$new_time',performers='$new_performers',dj='$new_djs',promoter='$new_promoter',music='$new_style',cover='$new_price',dress='$new_dress',notes='$new_notes',cover='$new_price',tickets='$new_buy',guestlist='$new_guest',flyer1='$new_flyer1',flyer2='$new_flyer2',flyer3='$new_flyer3',flyer4='$new_flyer4',type='$new_type' WHERE name='$name'") or die(query_error());             $tmpl->add_template("editclub_success");             }           }           else {           $query = "SELECT * FROM ".$prefix."events WHERE name='" . mysql_real_escape_string($name) . "'";           echo $query;           $result= mysql_query($query) or die("Problem with the query: $query<br>" . mysql_error());           $row=mysql_fetch_assoc($result);           if ($row['id'] != "") {                 $tmpl->add_template("editevent_form2");           }           else              $tmpl->add_template("username_no");           }         }         else {         $tmpl->add_template("editevent_form1");         }             break; [/code] And this is the form to create an event (event_form.php) [code] <script type="text/javascript"> function writeMonthOptions() {   var theMonth;   var monthCounter;   var numMonth;   var theDate = new Date();   var month=new Array(12)   month[0]="January"   month[1]="February"   month[2]="March"   month[3]="April"   month[4]="May"   month[5]="June"   month[6]="July"   month[7]="August"   month[8]="September"   month[9]="October"   month[10]="November"   month[11]="December"     for (monthCounter = 0; monthCounter < 12; monthCounter++)   {     numMonth = monthCounter + 1;     theMonth = month[monthCounter];     if (numMonth < 10 )     {       numMonth = '0' + numMonth;     }     document.write('<OPTION value=' + numMonth + '>' + theMonth);   } } function writeDay() {   var dayCounter;   var numDay;   //numDay = dayCounter;   for (dayCounter = 1; dayCounter <= 31; dayCounter++)   {     if (dayCounter < 10)     {       numDay = '0' + dayCounter;     }     else     {         numDay = dayCounter;     }     document.write('<OPTION value=' + numDay + '>' + dayCounter);   } } </script> <div id="article"> <form action="admin.php?a=newevent" method="post" enctype="multipart/form-data" name="form" id="form"> <input type="hidden" name="process" value="yes" />     <table width="603" border="0">       <tr>         <td colspan="2">&nbsp;</td>       </tr>       <tr>         <td width="151">Club Name:</td>         <td width="442"><input name="club_name" type="text" id="club_name"/></td>       </tr>       <tr>         <td>Event Name:</td>         <td><input name="event_name" type="text" id="event_name"></td>       </tr>       <tr>         <td>Date:</td>         <td><select name="month" id="month">             <option>Month</option>             <script type="text/javascript">writeMonthOptions();</script>           </select> <select name="day" id="day">             <option>Day</option>             <script type="text/javascript">writeDay();</script>           </select></td>       </tr>       <tr>         <td>Time :</td>         <td><input name="time" type="text" id="time"></td>       </tr>       <tr>         <td>Performers :</td>         <td><input name="performers" type="text" id="performers"></td>       </tr>       <tr>         <td>Dj:</td>         <td><select name="dj" id="dj">             <option>Choose one</option>           </select></td>       </tr>       <tr>         <td>Promoter: </td>         <td><input name="promoter" type="text" id="promoter" /></td>       </tr>       <tr>         <td>Music style:</td>         <td><input name="style" type="text" id="style" /></td>       </tr>       <tr>         <td>Cover price: </td>         <td> <input name="cover" type="text" id="cover"> </td>       </tr>       <tr>         <td>Dress Code:</td>         <td><input name="dress" type="text" id="dress" /></td>       </tr>       <tr>         <td>Notes:</td>         <td><textarea name="notes" id="notes"></textarea></td>       </tr>       <tr>         <td>Buy Tickets:</td>         <td><select name="buy" id="buy">             <option>Choose one</option>             <option value="yes">Yes</option>             <option value="no">No</option>           </select></td>       </tr>       <tr>         <td>Guestlist:</td>         <td><select name="guestlist" id="guestlist">             <option>Choose one</option>             <option value="yes">Yes</option>             <option value="no">No</option>           </select></td>       </tr>       <tr>         <td>Flyers:</td>         <td><table width="100%" border="0">             <tr>               <td><input type="file" name="file"></td>               <td>&nbsp;</td>             </tr>             <tr>               <td><input type="file" name="file2"></td>               <td>&nbsp;</td>             </tr>             <tr>               <td><input type="file" name="file3"></td>               <td>&nbsp;</td>             </tr>             <tr>               <td><input type="file" name="file4"></td>               <td>&nbsp;</td>             </tr>           </table></td>       </tr>       <tr>         <td>Type:</td>         <td><select name="type" id="type">             <option>Choose one</option>             <option value="hip hop">Hip Hop</option>             <option value="house">House</option>             <option value="both">Both</option>           </select></td>       </tr>       <tr>         <td colspan="2">&nbsp;</td>       </tr>     </table> <input type="submit" value="Create"/> <label> <input type="reset" name="Reset" value="Reset" /> </label> </form> </div> [/code] and this is the form to select what event to edit (editevent_form1.php) [code] <div id="article"> <form action="admin.php?a=editevent" method="post"> <input type="hidden" name="process" value="yes" /> <table border="0"> <tr>         <td>Event:</td>         <td><select name="ename" id="ename">             <option>Choose one</option>             <?php $sql='SELECT * FROM '.$prefix.'events'; $req=mysql_query($sql) or die(query_error()); while($data = mysql_fetch_assoc($req)) {     echo '<option value="'.$data['name'].'">'.$data['name'].'</option>'; } ?>           </select></td> </tr> </table> <br /> <input type="submit" value="Edit Event" /> </form> </div> [/code]
  3. [!--quoteo(post=377459:date=May 26 2006, 08:48 PM:name=kenrbnsn)--][div class=\'quotetop\']QUOTE(kenrbnsn @ May 26 2006, 08:48 PM) [snapback]377459[/snapback][/div][div class=\'quotemain\'][!--quotec--] Try this: [code]<?php $query = "SELECT * FROM ".$prefix."events WHERE name='" . mysql_real_escape_string($name) . "'"; $result= mysql_query($query) or die("Problem with the query: $query<br>" . mysql_error()); $row=mysql_fetch_assoc($result); if ($row['id'] != "")    $tmpl->add_template("editevent_form2"); else    $tmpl->add_template("username_no"); ?>[/code] You were using the sprintf() function incorrectly and you had the "or die" clause on the wrong line. Ken [/quote] Hi Ken, thank you for your reply but I'm still getting an error :S. here's the error I get : Problem with the query: INSERT INTO mtlguest_events (club,name,date,time,performers,dj,promoter,music,cover,dress,notes,tickets,guestlist,flyer1,flyer2,flyer3,flyer4,type) VALUES('1234','A-TRAK \"SUNGLASS IS A MUST TOUR\"','06-04-06','','','','','','','','','yes','no','','','','','both')A-TRAK \\\"SUNGLASS IS A MUST TOUR\\\"' You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'A-TRAK \\\"SUNGLASS IS A MUST TOUR\\\"'' at line 1 and here's the code I have [code] $query = "INSERT INTO ".$prefix."events (club,name,date,time,performers,dj,promoter,music,cover,dress,notes,tickets,guestlist,flyer1,flyer2,flyer3,flyer4,type) VALUES('$club','$name','$date','$time','$performers','$djs','$promoter','$style','$price','$dress','$notes','$buy','$guest','$flyer1','$flyer2','$flyer3','$flyer4','$type')" . mysql_real_escape_string($name) . "'";          $result= mysql_query($query) or die("Problem with the query: $query<br>" . mysql_error());[/code]
  4. [!--quoteo(post=377178:date=May 25 2006, 08:37 PM:name=eves)--][div class=\'quotetop\']QUOTE(eves @ May 25 2006, 08:37 PM) [snapback]377178[/snapback][/div][div class=\'quotemain\'][!--quotec--] [code] $result=mysql_query($query); [/code] you missed that part [/quote] still not working... any ideas on what I'm doing wrong [code]$query = sprintf("SELECT * FROM ".$prefix."events WHERE name='$name'" , mysql_real_escape_string($name)) or die(query_error());           $result= mysql_query($query);           //$result=mysql_query("SELECT * FROM ".$prefix."events WHERE name='$name'") or die(query_error());           $row=mysql_fetch_array($result);             if ($row['id'] != "") {             $tmpl->add_template("editevent_form2");             }             else {             $tmpl->add_template("username_no");             }[/code] still only displays A-TRACK and not the rest with the double quotes
  5. [!--quoteo(post=377045:date=May 25 2006, 11:15 AM:name=kenrbnsn)--][div class=\'quotetop\']QUOTE(kenrbnsn @ May 25 2006, 11:15 AM) [snapback]377045[/snapback][/div][div class=\'quotemain\'][!--quotec--] When you store your data use the [a href=\"http://www.php.net/mysql_real_escape_string\" target=\"_blank\"]mysql_real_escape_string()[/a] to properly escape quotes and other characters that can affect the store operation. When this data is extracted, the escaped characters will not be escaped. One more point, when you send data to the browser that includes quotes or double quotes, use the [a href=\"http://www.php.net/htmlentities\" target=\"_blank\"]htmlentities()[/a] function to convert these to encoded characters. If you had looked at your generated code, you would have seen that the double quote in your data ended the value in the form. Ken [/quote] thanks Ken, I think it's going to work but can you help me use that in my code? I tried doing this [code] $query = sprintf("SELECT * FROM ".$prefix."events WHERE name='$name'" , mysql_real_escape_string($name));           //$result=mysql_query("SELECT * FROM ".$prefix."events WHERE name='$name'") or die(query_error());           $row=mysql_fetch_array($query);             if ($row['id'] != "") {             $tmpl->add_template("editevent_form2");             }             else {             $tmpl->add_template("username_no");             }[/code] but I get this Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource **edit** oh I gotta use that only to store data right? or not.... really lost here lol
  6. [!--quoteo(post=376897:date=May 25 2006, 12:51 AM:name=Crayon Violent)--][div class=\'quotetop\']QUOTE(Crayon Violent @ May 25 2006, 12:51 AM) [snapback]376897[/snapback][/div][div class=\'quotemain\'][!--quotec--] don't even know what you are trying to do here: $sql='SELECT * FROM '.$prefix.'events'; is $prefix your table name, and is events supposed to be the condition you are wanting to base the selection on? like, [code] $prefix = 'tablename'; $events = 'blah'; $sql = "select * from '$prefix' where events = '$events'"; [/code] ? post what you are trying to do [/quote] $prefix is the prefix of my table names and events is one of the tables so ie $prefix = phpfreaks_ so this would look like $sql='SELECT * FROM 'phpfreaks_events'; the problem isn't with the tables it's with extracting information that has "" in it. this $data['name'] returns A-TRAK "SUNGLASSES IS A MUST TOUR" but when I do this $result=mysql_query("SELECT * FROM ".$prefix."events WHERE name='$name'") or die(query_error()); $row=mysql_fetch_array($result); it just returns A-TRAK because of the " hope I'm a bit more clear
  7. hey guys, I made a news script where I can write stuff and it will get stored in a database, my only problem is when I try to retrieve it or query the table it won't work properly if I have " " or ' ' in the entry. Here's an example: I have this form: [code]<div id="article"> <form action="admin.php?a=editevent" method="post"> <input type="hidden" name="process" value="yes" /> <table border="0"> <tr>         <td>Event:</td>         <td><select name="ename" id="ename">             <option>Choose one</option>             <?php $sql='SELECT * FROM '.$prefix.'events'; $req=mysql_query($sql) or die(query_error()); while($data = mysql_fetch_assoc($req)) {     echo '<option value="'.$data['name'].'">'.$data['name'].'</option>'; } ?>           </select></td> </tr> </table> <br /> <input type="submit" value="Edit Event" /> </form> </div>[/code] and one of the events is named A-TRAK "SUNGLASSES IS A MUST TOUR" so when I do this query $name=$_POST['ename']; $result=mysql_query("SELECT * FROM ".$prefix."events WHERE name='$name'") or die(query_error()); $row=mysql_fetch_array($result); it tells me that the event doesn't exist because all it returns is A-TRAK any way I can fix this?
  8. [!--quoteo(post=376081:date=May 22 2006, 12:47 PM:name=Yeshua Watson)--][div class=\'quotetop\']QUOTE(Yeshua Watson @ May 22 2006, 12:47 PM) [snapback]376081[/snapback][/div][div class=\'quotemain\'][!--quotec--] Have you tried adding the prefix in manually to see if it will update then? Replace the prefix with the actual prefix and test it out. [/quote] yup I did but it still doesn't work. Like I said the delete function works but not the update
  9. thing is I also have a delete function but it works perfectly so why doesn't the update work...? [code] case "delpromo":       $process=$_POST['process'];         if ($process == "yes") {         $username=$_POST['username'];         $result=mysql_query("SELECT * FROM ".$prefix."promo WHERE username='$username'") or die(query_error());         $row=mysql_fetch_array($result);           if ($row['id'] == "") {           $tmpl->add_template("username_no");           }           else {           mysql_query("DELETE FROM ".$prefix."promo WHERE username='$username'") or die(query_error());           $tmpl->add_template("userdel_success");           }         }         else {         $tmpl->add_template("promodel_form");         }             break;[/code] I think that the variable gets lost when it goes to the 2nd form and that's why $username returns nothing. How can I fix this?
  10. [!--quoteo(post=376050:date=May 22 2006, 11:08 AM:name=Orio)--][div class=\'quotetop\']QUOTE(Orio @ May 22 2006, 11:08 AM) [snapback]376050[/snapback][/div][div class=\'quotemain\'][!--quotec--] I cant see where you set $prefix ... I think that's the problem. Orio. [/quote] $prefix is set in config.php which is included at the top of the file
  11. hey guys, I have a form that updates entries in a table but for some reason it doesn't update nor does it give me a MySQL error. [code]case "editpromo":       $process=$_POST['process'];         if ($process == "yes") {         $process_b=$_POST['process_b'];         $username=$_POST['username'];           if ($process_b == "yes") {           $new_uname=$_POST['new_uname'];           $new_email=$_POST['new_email'];           $new_type=$_POST['new_type'];           if (strlen($new_uname) < 4 || strlen($new_email) < 6) {             $tmpl->add_template("edituser_tooshort");             }             else {             echo $new_type;             mysql_query("UPDATE ".$prefix."promo SET username='$new_uname',email='$new_email',type='$new_type' WHERE username='$username'") or die(query_error());             $tmpl->add_template("edituser_success");             }           }           else {           $result=mysql_query("SELECT * FROM ".$prefix."promo WHERE username='$username'") or die(query_error());           $row=mysql_fetch_array($result);             if ($row['id'] != "") {             $tmpl->add_template("editpromo_form2");             }             else {             $tmpl->add_template("username_no");             }           }         }         else {         $tmpl->add_template("editpromo_form1");         }             break;[/code] I even echoed $new_type to make sure the variable wasn't empty but it does return the right value. here's my form [code] <div id="article"> <form action="admin.php?a=editpromo" method="post"> <input type="hidden" name="process" value="yes" /> <input type="hidden" name="process_b" value="yes" /> <input type="hidden" name="username" value="<?php echo $username; ?>" /> <table border="0"> <tr> <td>Username:</td> <td><input type="text" name="new_uname" value="<?php echo $username; ?>" maxlength="<?php echo $max_username; ?>" /></td> </tr> <tr> <td>Email:</td> <td><input type="text" name="new_email" value="<?php echo $row['email']; ?>" maxlength="150" /></td> </tr> <tr> <td>Type:</td> <td><select name="new_type" id="new_type">   <option value="<?php echo $row['type']; ?>"><?php echo $row['type']; ?></option>   <option value="promoter">Promoter</option>   <option value="hotel">Hotel</option> </select> </td> </tr> </table> <br /> <input type="submit" value="Edit '<?php echo $username; ?>'" /> </form> </div> [/code] I'm still having problems with the echos in the form, it doesn't return anything, I've been told it's a scope issue but I'm really not sure how I can fix this. any ideas? **edit** ok I think I found the problem when I echo $username after the form is submitted it doesn't return anything so I'm guessing it's also a scope issue, is there any way I can fix this? It's getting frustrating
  12. [!--quoteo(post=375440:date=May 19 2006, 11:30 PM:name=Dave K.)--][div class=\'quotetop\']QUOTE(Dave K. @ May 19 2006, 11:30 PM) [snapback]375440[/snapback][/div][div class=\'quotemain\'][!--quotec--] What is this doing: $tmpl->add_template("editprofile_form"); If you're using a template system of some kind, it would depend on how that template system handles PHP code within the templates. Does the add_template() method read in the template file using fread or something similar or does it include() the template file? If it is using something like fread to get the contents of the file, the PHP inside would not be processed. [/quote] hey Dave, it simply include() the template file [code] session_start(); // //    Build the template class // class Template { var $errors; var $cur_page_name;   //   //    Create the add_template() function   //   function add_template($template_name) {   $template_name=$template_name.".php";     //     //    If the template name is blank...     //     if ($template_name == ".php") {     print("Error loading template.<br />\n");     $this->errors++;     }     else {       //       //    The file exists, so output the data       //       if (file_exists("template/".$this->cur_page_name."/".$template_name)) {       include("template/".$this->cur_page_name."/".$template_name);       }       //       //    If it doesn't, don't output the data       //       else {       print("That template doesn't exist.<br />\n");       $this->errors++;       }     }   } }[/code]
  13. [!--quoteo(post=375354:date=May 19 2006, 05:13 PM:name=ryanlwh)--][div class=\'quotetop\']QUOTE(ryanlwh @ May 19 2006, 05:13 PM) [snapback]375354[/snapback][/div][div class=\'quotemain\'][!--quotec--] You have $uname here, which i suspect should be $username. [code]$result=mysql_query("SELECT * FROM ".$prefix."users WHERE username='".$uname."'")[/code] [/quote] $uname is just a variable where the username is stored $uname = $_GET['user']; so I don't think that's the problem
  14. hey guys not sure how to explain this so I'll show you what I have so far. I have members.php that contain [code] //...... $tmpl->add_template("main"); $a=(isset($_GET['a']) ? $_GET['a'] : 'default'); $uname = $_GET['user'];     switch($a) {       case "editprofile":       $process=$_POST['process'];         if ($process == "yes") {         $process_b=$_POST['process_b'];         $username=$_POST['username'];           if ($process_b == "yes") {           $new_email=$_POST['new_email'];           $new_name=$_POST['new_name'];             if (strlen($new_uname) < 5 || strlen($new_email) < 6 || strlen($new_name) < 3) {             $tmpl->add_template("editprofile_tooshort");             }             else {             mysql_query("UPDATE ".$prefix."users SET username='$new_uname',email='$new_email',realname='$new_name' WHERE username='$username'") or die(query_error());             $tmpl->add_template("editprofile_success");             }           }           else {                      }         }         else {         $result=mysql_query("SELECT * FROM ".$prefix."users WHERE username='".$uname."'") or die(query_error());           $row=mysql_fetch_array($result);             if ($row['id'] != "") {             $tmpl->add_template("editprofile_form");             }         }             break;       case "viewprofile":       $tmpl->add_template("viewprofile");       break;         } //....... [/code] so when a person clicks on Edit Profile it takes them to this form (editprofile_form.php) [code] <div id="article"> <form action="members.php?a=editprofile" method="post"> <input type="hidden" name="process" value="yes" /> <input type="hidden" name="process_b" value="yes" /> <input type="hidden" name="username" value="<?php echo $username; ?>" /> <table border="0"> <tr> <td> </td> <td> </td> </tr> <tr> <td>Email:</td> <td><input type="text" name="new_email" value="<?php echo $row['email']; ?>" maxlength="150" /></td> </tr> <tr> <td>First name:</td> <td><input type="text" name="new_name" value="<?php echo $row['fname']; ?>" maxlength="75" /></td> </tr> <tr>   <td>Last name:</td>   <td><input type="text" name="new_name2" value="<?php echo $row['lname']; ?>" maxlength="75" /></td> </tr> <tr> //..... [/code] my problem is that the input boxes don't show any value..... I know I'm querying the right table and that the rows exist and have info in them so why are the boxes empty...? any help would be greatly aprecaited *edit* if I place echo $row['email']; in members.php it works perfectly so why doesn't it work in the form...?
  15. nevermind found my own mistake, it was actually pointing at the root directory instead of where my script was
  16. hey guys, I made this script where an admin can approve/decline user submitted pics but I ran into a snag. here's part of the script [code] function delete($user_dat, $globalvars)     {         $split_imgname = explode('.', $_GET['delete']);                  if($split_imgname[1] == null)         {             echo "We shall have no directory deleting here.";                          $exitp = new template();             $exitp->exitp($user_dat, $globalvars);         }                  if(unlink($_GET['user'] . "/" . $_GET['delete']))         {             @unlink($_GET['user'] . "/thumbnails/" . $split_imgname[0] . ".gif");             mysql_query("DELETE FROM vibe_img WHERE username = '" . $_GET['user'] . "' && image_name = '" . $_GET['delete'] . "'");                      } else {             echo "Could not remove the image because of unknown errors. ";             echo 'Click <a href="' . $_SERVER['PHP_SELF'] . '?admin=viewuploads">here</a> to go back.';         }     }          function viewuploads($user_dat, $globalvars)     {         $sql = 'SELECT * FROM vibe_img WHERE status = "Pending Approval" ORDER BY img_date';         $query = mysql_query($sql) or die('SQL Error <br>'.$sql.'<br>'.mysql_error());              while($data = mysql_fetch_assoc($query))         {             $rem_array = array("-", ".", "!", " ");             $js_functions = str_replace($rem_array, "", $data['image_name']);                         $split_name = explode('.', $data['image_name']);                          echo '<script>                                                  function del' . $js_functions. '()                 {                     var delimgfinal = confirm("Are you sure you want to delete, ' . $data['image_name'] . '?")                     if(delimgfinal == true)                     {                         window.location = "' . $_SERVER['PHP_SELF'] . '?admin=delete&delete=' . $data['image_name'] . '&user=' . $data['username'] . '"                     } else {                                          }                 }                 </script>';                          echo '<a href="users/' . $data['username'] . '/' . $data['image_name'] . '" target="_blank"><img src="users/' . $data['username'] . '/thumbnails/' . $split_name[0] . '.gif" border="0" /></a><br /><p></p>';             echo '<input type="button" onclick="app' . $js_functions . '()" value="Approve" />                 <input type="button" onclick="del' . $js_functions . '()" value="Decline" /><br /><p></p>';         }              } [/code] my problem is that it always gives me an error saying that the image file doesn't exist even though it does and it's looking in the right directory here's the error I got Warning: unlink(admin/Fish.jpg): No such file or directory and it does that to whatever user I try to delete the pic except it says the member's username instead of admin any ideas?
  17. [!--quoteo(post=368901:date=Apr 26 2006, 01:01 PM:name=swatisonee)--][div class=\'quotetop\']QUOTE(swatisonee @ Apr 26 2006, 01:01 PM) [snapback]368901[/snapback][/div][div class=\'quotemain\'][!--quotec--] Is your table name or just users ? And if not, then you need to match a field for $prefix. [/quote] yeah I found the mistake and it was pretty dumb on my part, $prefix is assigned in my config.php and I accidently replaced the one on my server with an old config.php so it had the wrong variable but the table still existed so I didn't realise that it was trying to write on a different table.... can't believe I lost a few hours on this.... thanks!
  18. Hey guys, I have a form with a few drop down lists that collect info from a user and inserts it into a database. My problem is that it keeps telling me that a column doesn't exist when it does.... here's the table [code] id INT NOT NULL AUTO_INCREMENT,   PRIMARY KEY(id),   username VARCHAR(250),   password VARCHAR(32),   email VARCHAR(250),   realname VARCHAR(250),   code VARCHAR(32),   active VARCHAR(3),   country VARCHAR(50),   state VARCHAR(50),   city VARCHAR(50),   date_birth DATE not null,   gender VARCHAR(6),   mobile VARCHAR(10),   carrier VARCHAR(15),   race VARCHAR(50),   language VARCHAR(50),   timeoffset text NOT NULL,   count int(10) NOT NULL default '0',   emailnot text NOT NULL,   nots text NOT NULL,   inmemlist text NOT NULL,   showmail text NOT NULL,   timestamp int(10) NOT NULL default '0',   last_login datetime NOT NULL default '0000-00-00 00:00:00'[/code] here's part of the form [code] <td>*Country:</td>   <td> <select id='countrySelect' name='country' onchange='populateState()'>         </select></td> </tr> <tr>   <td>*State/Province:</td>   <td><select id='stateSelect' name='state' disabled=true onchange='populateCity()'>         </select>        </td> </tr> <tr>   <td>*City:</td>   <td><select id='citySelect' name='city' disabled=true>         </select>         <script type="text/javascript">initCountry('CA'); </script></td> </tr>[/code] and here's my register.php [code] $uname=$_POST['uname'];     $pword=$_POST['pword'];     $encrypt_pass=md5($pword);     $c_pword=$_POST['c_pword'];     $email=$_POST['email'];     $c_email=$_POST['c_email'];     $realname=$_POST['name'];     $country=$_POST['country'];     $state=$_POST['state'];     $city=$_POST['city'];     $month=$_POST['month'];     $day=$_POST['day'];     $year=$_POST['year'];     $birth = $year + $month + $day;     $gender=$_POST['gender'];     $mobile=$_POST['mobile'];     $carrier=$_POST['carrier'];     $rand_a=rand(500,500000);     $rand_b=rand(1,1000000);     $code=substr(md5(rand(-$rand_a,$rand_b)),0,8); mysql_query("INSERT INTO ".$prefix."users(username,password,email,realname,code,active,country,state,city,date_birth,gender,mobile,carrier)               VALUES('$uname','$encrypt_pass','$email','$realname','$code','no','$country','$state','$city','$birth','$gender','$mobile','$carrier')") or die(query_error()); [/code] and it keeps giving me this error whenever I submit the form Unknown column 'country' in 'field list' any ideas why it's doing that?
  19. thanks GBS what's weird was that I did have a onchange = 'populateCity()' before but that didn't work at all, all 3 drop downs were empty when I did that. thanks for your help :)
  20. [quote]Please don't post JavaScript questions in the PHP forums. Moved.[/quote] sorry about that was very late and I was tired :S [quote]I made few changes in the js part,... hoping it helps,,[/quote] thanks man :D! it works perfectly. Can you please explain to me what made it work so I can understand :P
  21. Hey guys, What I'm trying to do is have a user select his country and when that happens he state/province drop down automaticly populates according to the chosen country. I have that part working but I also want a 3rd drop down named City which populates with cities from the chosen state... here's what I got, it works perfectly for Country and States but the Cities drop down always stays empty.... [code] var postState = '<?= $_POST["state"] ?>'; var postCountry = '<?= $_POST["country"] ?>'; var postCity = '<?= $_POST["city"] ?>'; var city = '\ CA:AB:AI:Airdrie|\ CA:AB:BR:Brooks|\ //etc '; var state = '\ US:AK:Alaska|\ US:AL:Alabama|\ US:AR:Arkansas|\ //etc '; var country = '\ AF:Afghanistan|\ AL:Albania|\ DZ:Algeria|\ //etc '; function TrimString(sInString) {   if ( sInString ) {     sInString = sInString.replace( /^\s+/g, "" );// strip leading     return sInString.replace( /\s+$/g, "" );// strip trailing   } } // Populates the country selected with the counties from the country list function populateCountry(defaultCountry) {   if ( postCountry != '' ) {     defaultCountry = postCountry;   }   var countryLineArray = country.split('|');  // Split into lines   var selObj = document.getElementById('countrySelect');   selObj.options[0] = new Option('Select Country','');   selObj.selectedIndex = 0;   for (var loop = 0; loop < countryLineArray.length; loop++) {     lineArray = countryLineArray[loop].split(':');     countryCode  = TrimString(lineArray[0]);     countryName  = TrimString(lineArray[1]);     if ( countryCode != '' ) {       selObj.options[loop + 1] = new Option(countryName, countryCode);     }     if ( defaultCountry == countryCode ) {       selObj.selectedIndex = loop + 1;     }   } } function populateState() {   var selObj = document.getElementById('stateSelect');   var foundState = false;   // Empty options just in case new drop down is shorter   if ( selObj.type == 'select-one' ) {     for (var i = 0; i < selObj.options.length; i++) {       selObj.options[i] = null;     }     selObj.options.length=null;     selObj.options[0] = new Option('Select State','');     selObj.selectedIndex = 0;   }   // Populate the drop down with states from the selected country   var stateLineArray = state.split("|");  // Split into lines   var optionCntr = 1;   for (var loop = 0; loop < stateLineArray.length; loop++) {     lineArray = stateLineArray[loop].split(":");     countryCode  = TrimString(lineArray[0]);     stateCode    = TrimString(lineArray[1]);     stateName    = TrimString(lineArray[2]);   if (document.getElementById('countrySelect').value == countryCode && countryCode != '' ) {     // If it's a input element, change it to a select       if ( selObj.type == 'text' ) {         parentObj = document.getElementById('stateSelect').parentNode;         parentObj.removeChild(selObj);         var inputSel = document.createElement("SELECT");         inputSel.setAttribute("name","state");         inputSel.setAttribute("id","stateSelect");         parentObj.appendChild(inputSel);         selObj = document.getElementById('stateSelect');         selObj.options[0] = new Option('Select State','');         selObj.selectedIndex = 0;       }       if ( stateCode != '' ) {         selObj.options[optionCntr] = new Option(stateName, stateCode);       }       // See if it's selected from a previous post       if ( stateCode == postState && countryCode == postCountry ) {         selObj.selectedIndex = optionCntr;       }       foundState = true;       optionCntr++     }   }   // If the country has no states, change the select to a text box   if ( ! foundState ) {     parentObj = document.getElementById('stateSelect').parentNode;     parentObj.removeChild(selObj);   // Create the Input Field     var inputEl = document.createElement("INPUT");     inputEl.setAttribute("id", "stateSelect");     inputEl.setAttribute("type", "text");     inputEl.setAttribute("name", "state");     inputEl.setAttribute("size", 20);     inputEl.setAttribute("value", "");     parentObj.appendChild(inputEl);   } } function populateCity() { var selObj = document.getElementById('citySelect');   var foundCity = false;   // Empty options just in case new drop down is shorter   if ( selObj.type == 'select-one' ) {     for (var i = 0; i < selObj.options.length; i++) {       selObj.options[i] = null;     }     selObj.options.length=null;     selObj.options[0] = new Option('Select City','');     selObj.selectedIndex = 0;   }      var cityLineArray = city.split("|");  // Split into lines   var optionCntr = 1;   for (var loop = 0; loop < cityLineArray.length; loop++) {     lineArray = cityLineArray[loop].split(":");     countryCode  = TrimString(lineArray[0]);     stateCode    = TrimString(lineArray[1]);     cityCode    = TrimString(lineArray[2]);     cityName    = TrimString(lineArray[3]);   if (document.getElementById('stateSelect').value == stateCode && stateCode != '' ) {     // If it's a input element, change it to a select       if ( selObj.type == 'text' ) {         parentObj = document.getElementById('citySelect').parentNode;         parentObj.removeChild(selObj);         var inputSel = document.createElement("SELECT");         inputSel.setAttribute("name","city");         inputSel.setAttribute("id","citySelect");         parentObj.appendChild(inputSel);         selObj = document.getElementById('citySelect');         selObj.options[0] = new Option('Select City','');         selObj.selectedIndex = 0;       }       if ( cityCode != '' ) {         selObj.options[optionCntr] = new Option(cityName, cityCode);       }       // See if it's selected from a previous post       if ( cityCode == postCity && stateCode == postState ) {         selObj.selectedIndex = optionCntr;       }       foundCity = true;       optionCntr++     }   }      if ( ! foundCity ) {     parentObj = document.getElementById('citySelect').parentNode;     parentObj.removeChild(selObj);   // Create the Input Field     var inputEl = document.createElement("INPUT");     inputEl.setAttribute("id", "citySelect");     inputEl.setAttribute("type", "text");     inputEl.setAttribute("name", "city");     inputEl.setAttribute("size", 20);     inputEl.setAttribute("value", "");     parentObj.appendChild(inputEl);   } } function initCountry(country) {   populateCountry(country);   populateState();   populateCity(); } [/code] all that is in list.js and in my php form I have <script type="text/javascript" src="list.js"></script> and for the drop down lists <select id='countrySelect' name='country' onchange='populateState()'></select> <select id='stateSelect' name='state'></select> <script type="text/javascript">initCountry('CA'); </script> <select id='citySelect' name='city'></select> any ideas what I'm doing wrong? any help would be greatly appreciated!
  22. [!--quoteo(post=361649:date=Apr 4 2006, 02:32 PM:name=AV1611)--][div class=\'quotetop\']QUOTE(AV1611 @ Apr 4 2006, 02:32 PM) [snapback]361649[/snapback][/div][div class=\'quotemain\'][!--quotec--] I have a program with a simular issue, only it's with adding new part numbers to the system: Here is how I did it: I great big script! first run a query starting with the lowest field number and do a series of clauses until I find an "empty". if there is not "empty", then they get an error message... You just have to think very linear to figure it out, but it's not that hard. [/quote] thanks for your reply AV1611 but I think I have it all wrong. I think it would be much easier if I created a table for the images something like id || username || image_name || status that way there won't be as much clutter as before plus there won't be a problem when people start deleting and adding new pics. Now my question is would a table like that be any good or will it slow things down since the script might have to do a lot of searching to find the images that belongs to a user. And what will happen if a user deletes an image and the whole row is deleted, will the id change by itself or will it remain the same? example: id || username || image_name || status 342 || AV1611 || 123.jpg || Approved 343 || digitalgod || 456.jpg || Approved and you decide to delete your 123.jpg what will happen if I remove the whole row?
  23. Hey guys, I've made myself a image upload script that limits each users to a maximum of 10 images. What I'm trying to do is have the names of those images written in a table. Now I'm not sure what's the best way to make a table for this. What I've done is I added 21 fields in my users table, 1 for main_thumb and the rest for img1, img2, etc status1,status2 etc the status fields are for whether the admin approved or not the images. My problem is that when a user uploads an image I want the script to be able to find out where to insert the name so if the user already uploaded 1 image and is uploading a second one the script will see that that the img1 field has something in it but the img2 field is empty so it will insert the name in img2 and insert "Pending Approval" in status2. I hope I made myself clear! Any help would be greatly appreciated
×
×
  • 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.