Jump to content

grozanc

Members
  • Posts

    28
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

grozanc's Achievements

Member

Member (2/5)

0

Reputation

  1. Wow, talk about not thinking things through. I originally tried $string_extracredit = 0; as I used that in other spots and stopped the error but didn't think to use $string_extracredit = ''; Anyway, thanks for the help. You solved the problem!
  2. Hello Everyone, I've got the following snippet of code that is use to retrieve student's grades when they log into the class website. I've been using the bit of code for years, but I'm switching to a new CMS and for the first time I get the "Notice: Undefined variable error". After a lot of searching I found a solution that I can't figure out how to implement because my variables are coming from an array and not a single instance. Can anyone show me how I should use isset() or empty() to fix the undeclared variable? The undeclared variable error in the following code is $string_extracredit and the error is appearing on line 5. Thanks, Gary $query_extracredit = "SELECT title, points FROM $section WHERE oasis_id='$oasis_id' && extracredit='1' ORDER BY date ASC"; $result_extracredit = mysql_query($query_extracredit) or die('Error, query failed'); if (mysql_num_rows($result_extracredit) > 0) { while(list($extracredit_title, $extracredit_points) = mysql_fetch_array($result_extracredit)) $string_extracredit .= "".$extracredit_title.": ".$extracredit_points." Points<br/>"; } echo "$string_extracredit";
  3. OK, I've tried the following and nothing seems to work. Can anyone spot what I'm doing wrong. I'm a newb when it comes to PHP so I don't expect that I'm doing this right. Please let me know if I'm not giving you enough information to be able to help. $prod_str = $order->products[$i]['qty'] . " x " . $order->html_entity_decode(products[$i]['name']); Page Load Error $prod_str = $order->products[$i]['qty'] . " x " . html_entity_decode($order->products[$i]['name']); Page renders but ascii character aren't converted. html_entity_decode($prod_str = $order->products[$i]['qty'] . " x " . $order->products[$i]['name']); Page renders but ascii character aren't converted. $prod_str = $order->products[$i]['qty'] . " x " . $order->products[$i]['name']; $prod_str = html_entity_decode($prod_str); Page renders but ascii character aren't converted.
  4. Anyone have any ideas or do I need to supply more info
  5. Hello Everyone, I have a pdf that is automatically generated, unfortunately it's pulling ascii codes from the database and displaying them as ascii. I want to use the html_entity_decode() command to make the ascii display as the actual symbol (in my case a trade mark symbol instead of ™). Here is the line of code the outputs the information from the database $prod_str = $order->products[$i]['qty'] . " x " . $order->products[$i]['name']; My question is where would I wrap the html_entity_decode() around to change products[$i]['name'] from ascii to text? Thanks, Gary
  6. I'm trying to dump three pieces of information into a database from a form, two of the pieces are coming from an array. I can get one piece of information from an array in, but I can't get the second. My latest attempt is to create the entry with the first array and then update that entry with the second array but that isn't working either. I'm a noob when it comes to this stuff so if this is explained somewhere please point me in the right direction. I've listed what I have below. The first foreach array works and the values are dumped into the database. I can't get the second foreach array to update the previous filed. I'm sure there is a better way to do this, but I don't have a clue. Any help would be appreciated, and yes, I did search google, but I guess I'm not using the right key words! Thanks, Gary <SELECT NAME="oasis_id[]"> <OPTION VALUE=""> </OPTION> <OPTION VALUE=\"".$oasis_id.".Present\"> Present </OPTION> <OPTION VALUE=\"".$oasis_id.".Absent\"> Absent </OPTION> </SELECT> <INPUT TYPE="TEXT" NAME="particpation_points[]" > <INPUT TYPE="SUBMIT" VALUE="Submit" > $class = $_POST['class']; $attendance_date = $_POST['attendance_date']; foreach($_POST['oasis_id'] as $oasis_id) { $query = "INSERT INTO $class (attendance_date, attendance) values ('$attendance_date','$oasis_id')"; mysql_query($query) or die('Error, query failed : ' . mysql_error()); } foreach ($_POST['particpation_points'] as $particpation_points) { $query2 = "UPDATE $class SET particpation_points='$particpation_points' WHERE oasis_id='$oasis_id' && attendance_date='$attendance_date'"; mysql_query($query2) or die('Error, query failed : ' . mysql_error()); }
  7. Hello Again, I don't want to mark this as "SOLVED" because the change I made doesn't seem like it should have worked. But, changing $i = 0; to $i = 1; allowed the last image name in the array to be inserted into the database. If anyone can say for certain that this code is correct, please let me know! Thanks, Gary
  8. Thanks for the help, but unfortunately it didn't work completely. Now, if I upload one image, the image name doesn't get stored in the database, if I upload two images only the first image name goes into the database. If I upload three images, the first two names get stored, and the last images name doesn't. So basically the name for the last file uploaded is getting lost. Any suggestions? // Post Variables $challenge = $_POST['challenge']; $insight = $_POST['insight']; $oasis_id = $_POST['oasis_id']; $filename=serialize($_POST['filename']); // Upload Images $i = 0; while(list($key,$value) = each($_FILES['image']['name'])) { $_name = 'filename' . $i++; $$_name = ''; if(!empty($value)) { $$_name = $value; $add = 'upimage/'.$$_name; copy($_FILES['image']['tmp_name'][$key], $add); chmod($add, 0777); } } // Insert into database $query = "INSERT INTO table ( oasis_id, challenge, insight, uploadedfile1, uploadedfile2, uploadedfile3 )". "values ( '$oasis_id', '$challenge', '$insight', '$filename1', '$filename2', '$filename3')"; mysql_query($query) or die('Error, query failed : ' . mysql_error());
  9. Hello All, First, I'm new to php and I have spent a lot of time searching forums and google for the answer to my question with no luck, so if it's a topic already covered, PLEASE reply with a link or point me in the right direction. OK, I have a form that let's users upload multiple images. The upload portion works fine. What I can't figure out how to do is put the image name of each file that gets uploaded all into the same table record. I also need each file name to be put into it's own column in the table. For example, file1, file2 and file3 will get dumped into the same record and into it's respective column (uploaded_image1, uploaded_image2, uploaded_image3). I've included the working upload code and the code that inserts some of the information into the database (just not the image names). echo "<textarea name=challenge rows=15 cols=60> </textarea><br/><br/>" echo "<textarea name=insight rows=15 cols=60> </textarea><br/><br/>" for($i=1; $i<=$max_no_img; $i++){ echo "Image $i <input type=file name='image[]' ><br/>"; } echo "<input type=submit value=Submit>"; // Connect to DB $host = 'xxx'; $user = 'xxx'; $pass = 'xxx'; $db = 'xxx'; mysql_connect($host,$user,$pass) or die(mysql_error()); mysql_select_db($db) or die(mysql_error()); // Post Variables $challenge = $_POST['challenge']; $insight = $_POST['insight']; $filename=serialize($_POST['filename']); // Upload Images while(list($key,$value) = each($_FILES[image][name])) { if(!empty($value)) { $filename = $value; $add = "upimage/$filename"; copy($_FILES[image][tmp_name][$key], $add); chmod("$add",0777); } } // Insert into database $query = "INSERT INTO table ( challenge, insight, uploaded_image1, uploaded_image2, uploaded_image3,)". "values ( '$challenge', '$insight', '$filename' '$filename2' '$filename3')"; mysql_query($query) or die('Error, query failed : ' . mysql_error()); I know just enough about php that the reason the above wont work, is because $filename2 and $filename3 haven't been given a value. Unfortunately, I have no idea how to separate that information in the array. If anyone can point me in the right direction I'd be forever grateful! Thanks, Gary
  10. Hello All, Thanks for the help. I didn't find a solution, but I did realize that my line of questioning wasn't going to solve this problem. Again, thanks!
  11. "empty" is the actual text information is the table column.
  12. Hello, I have a field in a MySQL table that defaults to "empty" unless it's written over. I'm using the following code to assign a variable based on what's written in that MySQL field. $query2 = "SELECT * FROM $table"; $row = mysql_fetch_assoc(mysql_query($query2)); if ($row['name'] == 'empty') { $joblink = "no download"; } else { $joblink = "download"; }; However, it doesn't seem to recognize the if statement and defaults to else part of the if statement regardless of what actually in the filed. Any ideas? Thanks, Gary
  13. Hello All, I'm working on a web site that needs to list all the rows in a table. This is how I have been doing it. # $query = "SELECT link, page_title, page_content, path FROM $table WHERE approved ORDER BY page_title ASC"; # $result = mysql_query($query) or die('Error, query failed'); # if (mysql_num_rows($result) > 0 ) { # while(list($link, $page_title, $page_content, $path ) = mysql_fetch_array($result)) # $string .= "<a href=".$link." class=maplinkrev target=_blank>".$page_title."</a><br>".nl2br($row['page_content'])."<br><br>"; # } # echo "$string"; This works fine. However, not every entry will always have a link and I need to figure out how to use an if statement to display the link only when it's in the table row but still display the page title. I have no idea of where to begin to look to find the answer to this! Any help would be appreciated. Regards, Gary
  14. Hello, I'm trying to use an if statement to either display a jpg or flv image that has the link stored in a database. The file names will vary, but the .jpg or .flv will always be the same. How do I tell the if statement to ignore everything before the .jpg or .flv file? Below is an example of what I'm using. if ($row['image1'] == jpg) { echo "<img name=mainimage src='".$row['image1']."'><br>"; } Basically, what should I put in place of "jpg" so it will distinguish between file types? Thanks, Gary
  15. Hello All, I'm new to all this and have run into a problem I can't figure out or find any resources/help when I do searches. I have a page where users can go and retrieve several different entries from the database. I can get the results to display on the screen via echo. However, I want the results emailed and the most I can manage is to get one row of results not all of them. How can I get the results of the query displayed in the body of the email message? Any help or pointing in the right direction would be appreciated. You can see the code below. <form method="POST" action=""> <font class="forms">Enter Email Address:</font> <input type="text" name="email" class="story"><br><br> <input type="submit" value="retrieve" class="btn"><br><br> </form> </font> <? if($_SERVER['REQUEST_METHOD'] == 'POST') { $host = 'localhost'; $user = 'xxxxxx; $pass = 'xxxxxx'; $db = 'xxxxxx'; mysql_connect($host,$user,$pass) or die(mysql_error()); mysql_select_db($db) or die(mysql_error()); $email=$_POST['email']; $query = "SELECT first_name, entry_type, entry_id, password FROM uploads_entryid WHERE email = '$email'"; $result = mysql_query($query) or die('Error, query failed'); while(list($first_name, $entry_type, $entry_id, $password) = mysql_fetch_array($result)) echo "Hello $first_name,<br><li>$entry_type:<br>Entry ID: $entry_id<br>Password: $password</li>"; } ?> <?php // Email Username, Password and Story ID $to = "$email"; $from = "xxxxxx"; $subject = "Your Pavement Memoirs Username & Password"; $message = <<<EOF <html> <body> Hello $first_name,<br> <br> Thank you for your submission! Feel free to use the following entry id’s, and passwords when logging in to Pavement Memoirs to make adjustments to your post. <br><br> <br><br> Keep in mind each time you edit your post, the new submission will not be viewable until it’s reviewed to keep the site PG rated. <br><br> </body> </html> EOF; $headers = "From: $from\r\n"; $headers .= "Content-type: text/html\r\n"; $to = "$to, $from"; mail($to, $subject, $message, $headers); ?>
×
×
  • 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.