Jump to content

smproph

Members
  • Posts

    57
  • Joined

  • Last visited

    Never

Everything posted by smproph

  1. While the app works on internet browsers, it is mainly designed for the iPhone. Just wanted to throw that out
  2. Me and a friend designed a web app for the Intramural department at our school. This is our first ever web app and we are pretty new to php also. If you can give us some critique on it, maybe what we could add or even what we need to fix. Thank You http://snu.uintramural.com
  3. I am new to php and did not know i could parse the email address using php instead of javascript. All I had to do was $ar=split("@",$email); $head = $ar[0]; $img[]= 'http://my.snu.edu/images/idpictures/'.$head.'-S.jpg';
  4. I'm trying to save images from a directory into mine. To get the image I am having to take the email from a database, split it and take whatever it is before the '@' sign and add it to "-S.jpg". I wrote the script and when I echo the variable it shows the correct thing, but when it tries to save it , it is trying to find the image as "script>-S.jpg". It looks like it is taking whatever is after the last '/' which in the variable since I am running javascript it is going to be </script> if you look at my variable $url. Here is the code below. Any help is appreciated. while($rows=mysql_fetch_array($result)){ $email=$rows['email']; $url= "<SCRIPT LANGUAGE=\"javascript\"> var url; var email = \"$email\"; function emailsplit () { var userid = email.split(\"@\"); var url = userid[0]; var imgid = \"http://my.snu.edu/images/idpictures/\" + url + \"-S.jpg\"; return url; } document.write(emailsplit()); </script> "; $img[]= 'http://my.snu.edu/images/idpictures/'.$url.'-S.jpg'; } function save_image($img,$fullpath='basename'){ if($fullpath=='basename'){ $fullpath = basename($img); } $ch = curl_init ($img); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_BINARYTRANSFER,1); $rawdata=curl_exec($ch); curl_close ($ch); if(file_exists($fullpath)){ unlink($fullpath); } $fp = fopen($fullpath,'x'); fwrite($fp, $rawdata); fclose($fp); } foreach($img as $i){ save_image($i); if(getimagesize(basename($i))){ echo '<h3 style="color: green;">Image ' . basename($i) . ' Downloaded OK</h3>'; }else{ echo '<h3 style="color: red;">Image ' . basename($i) . ' Download Failed</h3>'; } }
  5. I have some fields with values such as [Men's 1, Men's 2.....] They are saved as VARCHAR and when I sort it is putting Men's 10 after Men's 1. I need it to go after Men's 9. What would be the best solution to fix this?
  6. I figured it out. My value was Men's 1. MYSQL does not like " ' " apparently. Just had to mysql_real_escape_string($team); and it works great now.
  7. The problem lies in this line $sql2="SELECT picture, email, participant_name FROM $tbl_name WHERE team_no='$team'"; I copied the rest of my code below so you can see the rest of my code. Any help would be great. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <script type="text/javascript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-19722573-1']); _gaq.push(['_trackPageview']); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); </script> <meta content="yes" name="apple-mobile-web-app-capable" /> <meta content="index,follow" name="robots" /> <meta content="text/html; charset=utf-8" http-equiv="Content-Type" /> <link href="../pics/homescreen.gif" rel="apple-touch-icon" /> <meta content="minimum-scale=1.0, width=device-width, maximum-scale=0.6667, user-scalable=no" name="viewport" /> <!--[if IE]> <link rel="stylesheet" type="text/css" href="../css/styleIE.css" /> <![endif]--> <link href="../css/style.css" rel="stylesheet" media="screen" type="text/css" /> <script src="../javascript/functions.js" type="text/javascript"></script> <title>SNU Intramurals</title> <LINK REL="SHORTCUT ICON" HREF="images/favicon.ico"> </head> <body> <div id="outer"> <div id="topbar"> <div id="title"> SNU Intramurals</div> <div id="rightbutton"> <a href="../index.php">Home</a> </div> <div id="leftnav"> <a href="../gender.html">Back</a> </div> </div> <div id="content"> <ul class="pageitem"> <li class="textbox3"><span class="header3">Teams</span></li> <?php $host="localhost"; // Host name $username="*****"; // Mysql username $password="*******"; // Mysql password $db_name="********"; // Database name $tbl_name="participants"; // Table Name // Connect to server and select database. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); // Retrieve data from database $sql="SELECT DISTINCT team_no FROM $tbl_name"; $result=mysql_query($sql); // Start looping rows in mysql database. while($rows=mysql_fetch_array($result)){ $team=$rows['team_no']; ?> <li class="menu"> <a href="#"; onclick = " if(document.getElementById('<?=$team?>').style.display=='inline') {document.getElementById('<?=$team?>').style.display='none';} else if (document.getElementById('<?=$team?>').style.display='none') {document.getElementById('<?=$team?>').style.display='inline';}" > <span class="name"> <table> <tr><td><?=$team?></td></tr> </table> </span> </a> </li> <? [b]$sql2="SELECT picture, email, participant_name FROM $tbl_name WHERE team_no='$team'";[/b] $result2=mysql_query($sql2); $team2=$team; ?> <li class="textbox"><span class="name"> <table id="<?=$team?>" style="display:none;"> <? $num=1; while(($rows2=mysql_fetch_array($result2)) && ($num >= 1)){ $picture=$rows2['picture']; $email=$rows2['email']; $name=$rows2['participant_name']; if ($num == 1) { echo "<tr>"; } else if ($num == 4) { echo "</tr>"; $num = 1; } ?> <? echo "<td align='center'>"; echo "$name"; echo"<br \>"; if ($picture==T) { echo '<SCRIPT LANGUAGE="javascript"> var url; var email = "' . $email . '"; function emailsplit () { var userid = email.split("@"); var url = userid[0]; var imgid = "http://my.snu.edu/images/idpictures/" + url + "-S.jpg"; return imgid; } </SCRIPT>'; echo "<SCRIPT LANGUAGE='javascript'>document.write ('<img src=\"' + emailsplit() + '\" width=\"64\" height=\"64\" alt=\"Picture ID\" style=\"-webkit-border-radius: 8px; -moz-border-radius: 1em;\" />'); </SCRIPT>"; } else { echo "<SCRIPT LANGUAGE='javascript'>document.write ('<img src=\"http://dangerouslycareful.com/images/noimage.jpg\" width=\"64\" height=\"64\" alt=\"Picture ID\" />'); </SCRIPT>"; }; echo"<br \>"; echo"</td>"; $num++; ?> <? // close while loop } ?> </table> </span></li> <? } // close connection mysql_close(); ?> </ul> </body> </html>
×
×
  • 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.