Jump to content

chico1st

Members
  • Posts

    60
  • Joined

  • Last visited

    Never

Everything posted by chico1st

  1. okay is still doesnt work even with the proper brackets and using && .. i have discovered that it only uses the first conditional statement bolded here is the code: do{ ... } while (([b]$row['caption'] != $fileCaption)[/b] && ($row['name'] != $fileName)); thanks!
  2. okay i need to sort articles by date first then within date by author name... is there a command for this or does it get complicated? any help will be great THANKS!
  3. I have a quick question, how do you make: coditional statement AND conditional statement so that both must be true? I have this do{ }while ($row['caption'] != $fileCaption) and $row['type'] != $fileType and $row['size'] != $fileSize and $row['caption'] != $fileCaption); with just teh first conditinal statement it works but if I add more it doesnt. I think my "and" thing is wrong THANKS!
  4. All of my inputs in my forms seem to be aligned to the top of the table row they are in... its odd because the text beside it such as:  Name: _______  (____ represents a box) looks like Name: [sup]______[/sup] any ideas on how to fix this? thanks!
  5. your my hero... ive been working on this for hours. ( i took some time off to watch a movie in there too)
  6. OKay im trying to do an image upload, i have echoed all of my variables and they seem right. [b]here is the form with the upload:[/b] <form action="addNews.php" method="post" enctype="multipart/form-data" name="uploadform"> <table> <tr> <td width="246"><input type="hidden" name="MAX_FILE_SIZE" value="2000000"><input name="userfile" type="file" class="box" id="userfile"></td> <td width="80"><input name="upload" type="submit" class="box" id="upload" value="  Upload  "></td> </tr> </table> </form> and here is the part of the program taht shoudl enter it into my database <?php if(isset($_POST['upload'])) {         $fileName = $_FILES['userfile']['name'];         $tmpName  = $_FILES['userfile']['tmp_name'];         $fileSize = $_FILES['userfile']['size'];         $fileType = $_FILES['userfile']['type'];         echo "$fileName --- $tmpName --- $fileSize --- $fileType";// debugging         $fp = fopen($tmpName, 'r');         $content = fread($fp, $fileSize);         $content = addslashes($content);         fclose($fp); echo "---$content-----------------------------------------------"; //debugging                 if(!get_magic_quotes_gpc())         {             $fileName = addslashes($fileName);         }         echo $fileName;//debugging         include '../../lib.php'; $dbConn = connect();         [b]$query = "INSERT INTO 'picture' (`image_ID`, `name`, `type`, `content`, `size`) VALUES (NULL, '$fileName',  '$fileType', '$content', '$fileSize')"; mysql_query($query, $dbConn) or die('Error, file not uploaded');[/b]                 echo "File $fileName uploaded"; }        ?> i always get the:" Error, file not uploaded", i figure it must have something to do with the insert because the variables are good, and the connection to my database i use in many different programs and it works there Thanks for any help you can give THANKS!
  7. Hey I have this little script it is part of a bigger program but when i run it, it pretty much just prints the php code, which is odd. Here is my code: <? include "spyLib.php"; $dbConn = connectToSpy(); $fieldNames = ""; $fieldValues = ""; foreach ($_REQUEST as $fieldName => $value){   if ($fieldName == $_POST['tableName']){     $theTable = $value;   } else {     $fields[] = $fieldName;     $values[] = $value;   } // end if } // end foreach print updateRec($theTable, $fields, $values); print mainButton(); ?> And the output is: (but all on one line) [b]Update Record[/b] $value){   if ($fieldName == $_POST['tableName']){     $theTable = $value;   } else {     $fields[] = $fieldName;     $values[] = $value;   } // end if } // end foreach print updateRec($theTable, $fields, $values); print mainButton(); ?> (i also tried replacing the => with a ->... because i didnt know the difference) Any help would be awesome. Sincerely THANKS!
  8. Okay it turns out that there is this new fangled $_POST() command that i didnt know about, all is now well in the world of php :D ERIK!
  9. okay whenever i: echo $tableName; there is just nothing there.. like no display... this happens in my library file and in my function calling file. i dont know what gives thanks though
  10. Okay I have one page with a form that selects a table to open for editing. Then i try to open that table and display the values. The display function is held in a library. (PHP 5.1.4,MySQL 5.0.22 ) (mysqlfreaks.com is broken im sorry) Whenever i try to open the table using the variables i get: [b]Warning: mysql_fetch_field(): supplied argument is not a valid MySQL result resource in C:\wamp\www\Lib.php on line 100[/b] but if i just type in a table name instead of using the variable it works fine. i think it might have to do with how i use the variable either .. the way i name it in the form (just below) or the way i use it in my query (bottom) I included most of the code but bolded what i think is important [b]here is the form that grabs the table:[/b] <body> <form action = "editTable.php" method = "post"> <table border = 1> <tr> <td colspan = 2><center> <h2>Edit table data</h2> </center></td> </tr> <tr> <td colspan = 2><center> [b] <select name = "tableName" size = 5> <option value = "news">News</option> <option value = "publications">Publications</option> <option value = "author">Author</option> <option value = "date">Date</option> <option value = "picture">Picture</option> <option value = "topic">Topic</option> </select> </center></td>[/b] </tr> <tr> <td colspan = 2><center> <input type = "submit" value = "edit table"> </center></td> </tr> </table> </form> </body> [b]Here is me calling my library function[/b] <?php include "Lib.php"; //check password if ($pwd == $adminPassword){ $dbConn = connect(); [b]print Edit("$tableName");[/b] } else { print "<h3>You must have administrative access to proceed</h3>\n"; } // end if ?> [b] Here is the function[/b] <?php function Edit($tableName){ //given a table name, generates HTML table including //add, delete and edit buttons global $dbConn; $output = ""; [b]$query = "SELECT * FROM {$tableName}";[/b] [b]$result = mysql_query($query, $dbConn);[/b] $output .= "<table border = 1>\n"; //get column headings //get field names $output .= "<tr>\n"; [b]while ($field = mysql_fetch_field($result)){[/b] $output .= " <th>$field->name</th>\n"; } // end while //get name of index field (presuming it's first field) $keyField = mysql_fetch_field($result, 0); $keyName = $keyField->name; //add empty columns for add, edit, and delete $output .= "<th></th><th></th>\n"; $output .= "</tr>\n\n"; //get row data as an associative array while ($row = mysql_fetch_assoc($result)){ $output .= "<tr>\n"; //look at each field foreach ($row as $col=>$val){ $output .= " <td>$val</td>\n"; } // end foreach //build little forms for add, delete and edit //delete = DELETE FROM <table> WHERE <key> = <keyval> $keyVal = $row["$keyName"]; $output .= <<< HERE <td> <form action = "deleteRecord.php"> <input type = "hidden" name = "tableName" value = "$tableName"> <input type= "hidden" name = "keyName" value = "$keyName"> <input type = "hidden" name = "keyVal" value = "$keyVal"> <input type = "submit" value = "delete"></form> </td> HERE; //update: won't update yet, but set up edit form $output .= <<< HERE <td> <form action = "editRecord.php" method = "post"> <input type = "hidden" name = "tableName" value = "$tableName"> <input type= "hidden" name = "keyName" value = "$keyName"> <input type = "hidden" name = "keyVal" value = "$keyVal"> <input type = "submit" value = "edit"></form> </td> HERE; $output .= "</tr>\n\n"; }// end while //add = INSERT INTO <table> {values} //set up insert form send table name $keyVal = $row["$keyName"]; $output .= <<< HERE <td colspan = "5"> <center> <form action = "addRecord.php"> <input type = "hidden" name = "tableName" value = "$tableName"> <input type = "submit" value = "add a record"></form> </center> </td> HERE; $output .= "</table>\n"; return $output; } // end Edit ?>
×
×
  • 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.