Jump to content

ksb24930

Members
  • Posts

    24
  • Joined

  • Last visited

    Never

Everything posted by ksb24930

  1. I want to make a form in drupal using webforms that inserts info into a mysql table using php. I couldn't find a module that would make my life easier. Does anyone know how I can do that? Thanks for any direction!
  2. I have id, the primary key, set to auto-increment. But, I want new rows to fill in the empty rows. How can i do that? For example, I want my id to be 1-20 without spaces, without numerical gaps.
  3. I am interested in making a section on my site, much like freerice.org, where a question is displayed, a user selects the best answer, and then a new question is displayed - without the need to track the user or her answers, where would I start? Vague questions, I know, but if you can give me any direction on where to go, thatd be great!
  4. I am running this following script to update a mysql database. When I press "submit," an error is returned that says something about the CGI not being able to return a complete set of headers. Then, the information that I put in is displayed over 200 times (i only want it once). (it works on another server!) <? if (!isset($_COOKIE['***'])) die("Do you belong here? I do not recognize you! I want cookies! Make sure your browser accepts cookies!<br><a href='../home.php'>Away From Here!</a>"); $conn = mysql_connect("localhost", "***", "***") OR DIE (mysql_error()); @mysql_select_db ("databox", $conn) OR DIE (mysql_error()); if ($_POST) { $location = $_POST["location"]; $date = $_POST["date"]; $venue = $_POST["venue"]; $sql = "INSERT INTO schedule (location, date, venue) "; $sql.= "VALUES ("; $sql.= "'{$location}', '{$date}', '{$venue}')"; @mysql_query ($sql, $conn); Header("Location:".$_SERVER["PHP_SELF"]); } // Do this process of user has click a file name to view or remove if ($_GET) { $iid = $_GET["iid"]; $act = $_GET["act"]; switch ($act) { case rem: $sql = "DELETE FROM schedule WHERE id=$iid"; @mysql_query ($sql, $conn); Header("Location:./sched_index.php"); exit(); break; default: break; } }?> <html> <body> <a href='../maintaindir.php'>Return to Maintain Headquarters</a><br> <a href='../home.php'>Return Home</a> <FORM name="formcheck" method="post" enctype="multipart/form-data" onsubmit="return formCheck(this);"> <center><font size=6>Schedule Update</font><hr><br> <table> <P> <tr><td> <LABEL for="name">Location (ex. Omaha, NE): </LABEL></td> <td><INPUT type="text" name="location" size="20"></td> </tr> <tr> <td> <LABEL for="name">Date (ex. April 26): </LABEL></td><td> <INPUT type="text" name="date" size="20"></td> </tr> <tr><td><LABEL for="name">Venue (ex. Downtown Boxing): </LABEL></td><td><INPUT type="text" name="venue" size="30"></td> </tr> <tr><td></td><td> <input type="submit" value="submit"></td></tr> </form></table> <? echo "<br><br>These is the current schedule<br><hr><br>"; $sql3 = "SELECT * FROM schedule ORDER BY id asc"; $result3 = mysql_query ($sql3, $conn); if (mysql_num_rows($result3)>0) { while ($row = mysql_fetch_array($result3, MYSQL_ASSOC)) { $ic++; $str3 .= $ic.". "; $str3 .= "<a href=\"sched_index.php?iid=".$row["id"]."&tbl=schedule\">".$row["location"]."</a> "; $str3 .= "[".$row["date"]."] "; $str3 .= "[".$row["venue"]."]<br> "; $str3 .= "[<a href=\"sched_index.php?act=rem&iid=".$row["id"]."&tbl=schedule\">REMOVE</a>]<br><br>"; } print $str3; } mysql_free_result ($result3);?></body> </html>
  5. I am swithching servers (from a university to www.3essential.com). Everything worked smooth ath the university, but in the transition to the other server, my pages are going crazy. three questions. 1. Why are they doing that? 2. I have a code for authorization, but it constantly keeps recalling the prompt (I know i am putting in the right info!) <?php $id = "aa"; // user id $pw = "aa"; // password // Check to see if $PHP_AUTH_USER already contains info if (!isset($_SERVER['PHP_AUTH_USER'])) { // If empty, send header causing dialog box to appear header('WWW-Authenticate: Basic realm="DBC"'); header('HTTP/1.0 401 Unauthorized'); exit; } else if (isset($_SERVER['PHP_AUTH_USER'])) { if (($_SERVER['PHP_AUTH_USER'] != $id) || ($_SERVER['PHP_AUTH_PW'] != $pw)) { header('WWW-Authenticate: Basic realm="DBC"'); header('HTTP/1.0 401 Unauthorized'); exit; } else { // do nothing, everything is OK -- all programs that call this will pass here } } ?> This is called using "require_once" in the parent page. Again, it worked smoothly at another server 2. I uploaded some information using the script below, but after i pressed the submit button once, it entered the information 200 times. <? if (!isset($_COOKIE['MAINT'])) die("Do you belong here? I do not recognize you! I want cookies! Make sure your browser accepts cookies!<br><a href='../home.php'>Away From Here!</a>"); $conn = mysql_connect("localhost", "***", "***") OR DIE (mysql_error()); @mysql_select_db ("databox", $conn) OR DIE (mysql_error()); if ($_POST) { $location = $_POST["location"]; $date = $_POST["date"]; $venue = $_POST["venue"]; $sql = "INSERT INTO schedule (location, date, venue) "; $sql.= "VALUES ("; $sql.= "'{$location}', '{$date}', '{$venue}')"; @mysql_query ($sql, $conn); Header("Location:".$_SERVER["PHP_SELF"]); } // Do this process of user has click a file name to view or remove if ($_GET) { $iid = $_GET["iid"]; $act = $_GET["act"]; switch ($act) { case rem: $sql = "DELETE FROM schedule WHERE id=$iid"; @mysql_query ($sql, $conn); Header("Location:./sched_index.php"); exit(); break; default: break; } }?> <html> <body> <a href='../maintaindir.php'>Return to Maintain Headquarters</a><br> <a href='../home.php'>Return Home</a> <FORM name="formcheck" method="post" enctype="multipart/form-data" onsubmit="return formCheck(this);"> <center><font size=6>Schedule Update</font><hr><br> <table> <P> <tr><td> <LABEL for="name">Location (ex. Omaha, NE): </LABEL></td> <td><INPUT type="text" name="location" size="20"></td> </tr> <tr> <td> <LABEL for="name">Date (ex. April 26): </LABEL></td><td> <INPUT type="text" name="date" size="20"></td> </tr> <tr><td><LABEL for="name">Venue (ex. Downtown Boxing): </LABEL></td><td><INPUT type="text" name="venue" size="30"></td> </tr> <tr><td></td><td> <input type="submit" value="submit"></td></tr> </form></table> I am at a loss, i don't know where to start. Should i forget about this server and try another one?
  6. damn. huh huh huh. I figured it out. I don't know why exactly, but the code just didn't work at the location I had put it-  i moved it, it works, everything is good. thank you much.
  7. this is the code i put in [code] $sql = "SELECT * FROM $table where image_id=$id"; $resultv = mysql_query($sql) or die(mysql_error()); if (!mysql_num_rows($resultv)) {     echo "There were no records"; } else {   echo "<pre>";   while ($row = mysql_fetch_assoc($resultv)) {     $images[] = $row[image_id];     print_r($row);   }   echo "</pre>"; } [/code] the result is this: Array (     [image_id] => 3     [image_type] => image/pjpeg     [image] => ÿØÿàJFIF,,ÿí LPhotoshop 3.08BIMí Resolution,,8BIM FX Global Lighting ... a lot of image data...ad infinitum. basically, i got all the row data from the specified image id.
  8. okay, you have written the code for me and explained it, but I can seem to put it together- literally. And my brain is fried on the subject (not much to fry)...so...why isn't this working:($table is being passed) [code] $sql = "SELECT * from $table"; $resultw = mysql_query($sql) or die(mysql_error()); if (!mysql_num_rows($resultw)) {     echo "There were no records"; } else {   while ($row = mysql_fetch_assoc($resultw)) {     $images[] = $row[image_id];       } } $image_forward = $images[(array_search($image_id, $images)+1)%count($images)]; $image_back = $images[(array_search($image_id , $images)-1+count($images))%count($images)]; [/code] down below, i have tried to echo some results to see what i get, but I only get the image_id: [code] echo "$image_forward, $image_id, $image_forward<br>"; echo "$images"; echo "result of array of image_id=2 " . $images[2] . "<br />"; [/code] i feel like i am missing very small (=frusterating) anyone chime in- gracias
  9. wow, okay okay, this is a tad over my head. so just to make sure.... ya know, i won't even waste your time. how would i query the values into an array. remember that the number (and id) of the images will be changing frequently, so i can't write out the array manually.
  10. I have two questions I have code that is meant to function as a repeatable slide show. So, when the slide show is at the end of 5 slides, it goes back to 1 (the first row). or vice versa- if the slide is running in revese and the slide is one, then i want it to go to slide five. the code below wouls work if the id of the pictures always was cronological from zero and not missing any. however, it is not. question #1 is: how do i make a variable that is the id of the first row in a table? bad code below: $image_back = $image_id - 1; $image_forward = $image_id ++; if ($image_back==0) {       $image_back=$num;       } if ($image_forward==$num) {       $image_forward=0;       } second question is: the table i use will be changed frequently, in that case, pictures will be added and deleted. Right now the table just creates the next chronological id, and not fill in space, so if i had a table with five pictures, the id's would look like this : 2,  4,  7,  8,  10... question #2: how do i make new data take the id ov an empty id slot? making the id start at 1 and end at the last picture input... too much thanks. i know i wrote a lot, but the answer, i think, is quite simple- i just can't write succinctly
  11. welcome back to the cyber world, don (back from the day job). I pasted that code above both of the for loops, and it echoed the number of lines in the page, but still no pics are shown. Is your code sound? I mean is the page not viewing because of me or you? Thank you so freaking much for your help. And the whole TD thing is just something i do to keep myself on my toes.
  12. maybe i could substitute a while loop for the first for loop...?
  13. okay, so don has helped me out a lot. This code looks like exactly what I need. I copy/pasted it into my page and nothing comes up. i don't think the loop is even starting. doni, where you at? $count_sql = 'SELECT * FROM imagec'; $result = mysql_query($count_sql); $num=mysql_numrows($result); for($i=0;$i<num;$i+4){   echo "<tr>";   for($j=0;$j<4;$j++){         $id=mysql_result($result,$i+$j,"image_id");     echo "<td width='' bgcolor='' align='' valign=''>";     echo "<a href=index.php?iid=$id&tbl=imagec><img src='image.php?iid=$id&tbl=imagec' width=100 height=73 ><" . "/a" . "></td>";   }   echo "</tr>"; }
  14. thanks, don, i think i am on the right track. but just to clarify a dead end... why doesn't the code below work? while ($l < $num) { $idi=mysql_result($result,$i++,"image_id"); $idj=mysql_result($result,$i++,"image_id"); $idk=mysql_result($result,$i++,"image_id"); $idl=mysql_result($result,$i++,"image_id");     echo "<tr> <td width='' bgcolor='' align='' valign=''>"; echo "<td><a href=index.php?iid=$idi&tbl=imagea><img src='image.php?iid=$idi&tbl=imagea' width=100 height=73 ></a></td>";   echo "<td width='' bgcolor='' align='' valign=''>"; echo "<td><a href=index.php?iid=$idj&tbl=imagea><img src='image.php?iid=$idj&tbl=imagea' width=100 height=73 ></a></td>"; echo "<td width='' bgcolor='' align='' valign=''>"; echo "<td><a href=index.php?iid=$idk&tbl=imagea><img src='image.php?iid=$idk&tbl=imagea' width=100 height=73 ></a></td>"; echo "<td width='' bgcolor='' align='' valign=''>"; echo "<td><a href=index.php?iid=$idl&tbl=imagea><img src='image.php?iid=$idl&tbl=imagea' width=100 height=73 ></a></td>"; $i++; echo "</tr>"; }
  15. no, that is exactly what i am trying to avoid! I want the images to be shown four across. so if there were 12 images in the table named 1-12, the page would look like this: 1  2  3  4 5  6  7  8 9 10 11 12
  16. is there a way to add more than just one (++) to the variable $i at a time?
  17. I am trying to format the images stored in a database into a table that is for pictures across, and how ever many rows it takes to display all the images. here is the code that doesn't work: echo "<TABLE border=1 cellSpacing=0 cellPadding='5%'> <TR><TD COLSPAN='6' ALIGN='MIDDLE'><font size='6'><b>Rowing Gallery</b></font></align><BR><BR><hr/></TD> </TR>"; echo "</TR> <table border='1' cellpadding='15' cellpadding='20%' ID='Table1'> <tr>"; $count_sql = 'SELECT * FROM imagea'; $result = mysql_query($count_sql); $num=mysql_numrows($result); $i=0; while ($i < $num) { $id=mysql_result($result,$i,"image_id");     echo "<tr> <td width='' bgcolor='' align='' valign=''>"; echo "<td><a href=index.php?iid=$id&tbl=imagea><img src='image.php?iid=$id&tbl=imagea' width=100 height=73 ></a></td>"; $i++;   echo "<td width='' bgcolor='' align='' valign=''>"; echo "<td><a href=index.php?iid=$id&tbl=imagea><img src='image.php?iid=$id&tbl=imagea' width=100 height=73 ></a></td>"; $i++; echo "<td width='' bgcolor='' align='' valign=''>"; echo "<td><a href=index.php?iid=$id&tbl=imagea><img src='image.php?iid=$id&tbl=imagea' width=100 height=73 ></a></td>"; $i++; echo "<td width='' bgcolor='' align='' valign=''>"; echo "<td><a href=index.php?iid=$id&tbl=imagea><img src='image.php?iid=$id&tbl=imagea' width=100 height=73 ></a></td>"; $i++; echo "</tr>"; } i know why this code doesn't work- the $i++ returnes the code to the beginning of the loop. If I do not have something to change "$i" then the same picture will be shown... what you got for me, smat people?
  18. too cool, thanks all. how to I mark this post as finished?
  19. excellent, thank you. Now I think I have those two scripts jumbled in my code pages, but I am unclear about how to call all the pictures- I can pass one picture id through the url, but I don't know how to display all of the images. So, what would an example of the looping script look like? thanks
  20. sorry- this is the script I have been working with: $sql    = "SELECT * FROM imageb"; $result = mysql_query ($sql, $conn); if (mysql_num_rows ($result)>0) {   $row = @mysql_fetch_array ($result);   $image_type = $row["image_type"];   $image = $row["image"];   Header ("Content-type: $image_type");   print $image; } I know this script won't produce more than one image- it is the script I have been tweaking, though.
  21. I have made a script to input the pictures into the database, and I can make linked files to each picture individually, but I cannot, for the life of me, figure out how to display all of the images on a page at once- not even two pictures. any thoughts?
  22. this is what the url looks like: https://people.creighton.edu/~ksb24930/newrowingweb/Pictures/image.php?iid=6&tbl=imageb this is what the code looks like (some of it): $conn = mysql_connect("datastore.creighton.edu", "rower", "ksb42685") OR DIE (mysql_error()); @mysql_select_db ("crew", $conn) OR DIE (mysql_error()); $table = $_REQUEST["tbl"]; $id = $_REQUEST["iid"]; if ($id=="") {       echo "No userid given";       exit(); } $table = $_REQUEST["tbl"]; $id = $_REQUEST["iid"]; if ($tbl=="") {       echo "No table given";       exit(); } $sql    = "SELECT * FROM imagec WHERE image_id=".$_GET["iid"]; ----------------------------------- i get a "no table given" message... ------------------------------------- here are my problems/questions: 1. why isn't $table getting defined when it is in the url? 2. I have experiemented changing the ".$_get["iid"]" t0 $id and the code breaks down.
  23. All i need to know is how to stop calling columns with the same name from different tables. Is it something to do with "while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {..."
  24. I am trying to display the results of three different tables. the three tables differ only by name, the colums names are the same. So, if i try to recall infomation about the tables on the same page, the results overlap. see code below: how do i get a query to only recall the column information of the specific table!? $sql = "SELECT * FROM imagea ORDER BY image_date desc";   $result = mysql_query ($sql, $conn);   if (mysql_num_rows($result)>0) {     while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {       $i++;       $str .= $i.". ";       $str .= "<a href=\"index.php?iid=".$row["image_id"]."\">".$row["image_name"]."</a> ";       $str .= "[".$row["image_date"]."] ";       $str .= "[".$row["image_size"]."] ";       $str .= "[".$row["image_discription"]."] ";       $str .= "[<a href=\"index.php?act=rem&iid=".$row["image_id"]."\">Remove</a>]<br>";     }     print $str;   } mysql_free_result ($result);     echo "<br><br><hr><br>";     $sql = "SELECT * FROM imageb ORDER BY image_date desc";   $result = mysql_query ($sql, $conn);   if (mysql_num_rows($result)>0) {     while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {       $i++;       $str .= $i.". ";       $str .= "<a href=\"index.php?iid=".$row["image_id"]."\">".$row["image_name"]."</a> ";       $str .= "[".$row["image_date"]."] ";       $str .= "[".$row["image_size"]."] ";       $str .= "[".$row["image_discription"]."] ";       $str .= "[<a href=\"index.php?act=rem&iid=".$row["image_id"]."\">Remove</a>]<br>";     }     print $str;   } mysql_free_result ($result);   echo "<br><br><hr><br>";     $sql = "SELECT * FROM imagec ORDER BY image_date desc";   $result = mysql_query ($sql, $conn);   if (mysql_num_rows($result)>0) {     while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {       $i++;       $str .= $i.". ";       $str .= "<a href=\"index.php?iid=".$row["image_id"]."\">".$row["image_name"]."</a> ";       $str .= "[".$row["image_date"]."] ";       $str .= "[".$row["image_size"]."] ";       $str .= "[".$row["image_discription"]."] ";       $str .= "[<a href=\"index.php?act=rem&iid=".$row["image_id"]."\">Remove</a>]<br>";     }     print $str;   }   mysql_free_result ($result); ?> </body>
×
×
  • 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.