Jump to content

ja_blackburn

Members
  • Posts

    37
  • Joined

  • Last visited

    Never

Everything posted by ja_blackburn

  1. My problem is that the script used to initially upload a member's profile picture is the same one that is used to update it (e.g. upload a new one). so the filename on the server will be essentially 'username.jpg' and what the script tries to do is re-upload 'username.jpg' and it doesn't work. Is there some logic I can include to the effect of: if (username.jpg already exists){ replace it }else{ just upload as normal } ??? Thanks
  2. Hello. i am building a facility for members of my website to upload profile pictures. It works, but what I want to do is have the below script check and overwrite the previous file if they want to update it. As you will see it enforces the image to be named after the username. function findexts ($filename) { $filename = strtolower($filename) ; $exts = split("[/\\.]", $filename) ; $n = count($exts)-1; $exts = $exts[$n]; return $exts; } $ext = findexts ($_FILES['uploaded']['name']); //$ran = rand () ; $ran2 = $eo_user_name."."; $target = "../images/eoprofile/"; //This assigns the subdirectory you want to save into... make sure it exists! $target = $target . $ran2.$ext; //This combines the directory, the random file name, and the extension if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) { echo "The file has been uploaded as ".$ran2.$ext; } else { echo "Sorry, there was a problem uploading your file."; } Help appreciated. Thanks...
  3. I have 3 tables in the following structure: Table: main_event Field: user_id Field: main_event_id [PK] Table: sub_event Field: main_event_id Field: sub_event_id [PK] Table: sub_event_entered Field: sub_event_entered_id [PK] Field: sub_event_id Field: race_no My aim is to perform the following query but I keep getting stuck linking the 3 tables together: SELECT sub_event_id, race_no FROM sub_event_entered WHERE user_id = $user_id What is the correct syntax of this statement linking the tables? Thanks!
  4. Hi Thanks for that. The output i'm getting is: Array ( [0] => 123a [1] => 456b [2] => 789c ) So its not quite: $output = array('123a', '123b', '123c', '456a', '456b', '456c', '789a', '789b', '789c' ) Any Ideas on how I can get it apply each item from $one to $two in consecutive groups of three? Cheers.
  5. Hi. I have two arrays: $one = array('a', 'b', 'c'); $two = array('123', '456', '789'); My desired output is: $output = array('123a', '123b', '123c', '456a', '456b', '456c', '789a', '789b', '789c' ) How can this be achieved, I have looked into functions such as array_merge() but it doesnt seem to do the job. Help greatly appreciated!
  6. Hello, I want to 'join' two corresponding array values together as in the example below. $one = array('tomato', 'ham', 'bacon'); $two = array('soup', 'sandwich', 'roll'); $final=array(?) //Desired answer = (tomatosoup, hamsandwich, baconroll) Is there a php function that can do this, or a series of functions? I am aware of array_merge but this only alternates the values from what I can see. Ideally there should be a check performed that the two are the same length before completing a merge. New to this, many thanks!
  7. If i put the code before the if ($b == 'upload') { I get an error as no value has been passed to it. I have tried your code inside the if statement and commented out everything else, and the file was uploaded successfully... a glimmer of hope Thanks for your continued support - the first time I have written something to do this...
  8. it holds value 'upload' its setup as follows: $b = my_import('data','G','ALP'); basically just GETS the value from the URL The fact it is returning the error message shows that the if statement is working? Cheers
  9. Hi, thanks for the reply.. I have slightly modified the form code as the framework I use will need the form to be posted back to itself, controlling the path by an if statement at the stop: <form enctype="multipart/form-data" action="results.php?data=upload" method="POST"> <input type="hidden" name="data" value="upload" /> Choose a file to upload: <input name="sel_file" type="file" /><br /> <input type="submit" value="submit" /> </form> The following code is at the top of the page: if ($b == 'upload') { $data = trim($_POST['data']); if($data !="upload") { /* trap */ exit(); } $filename = $_FILES['sel_file']['name']; $chk_ext = explode(".",$filename); if(strtolower($chk_ext[1]) != "csv"){ /* trap */ exit(); } if(move_uploaded_file($_FILES['sel_file']['name'], $filename)) { } else{ echo "There was an error uploading the file, please try again!"; exit(); } $lines = file($filename); //include('db.php'); /* connect to db here (don't need to do this part as I am already calling in a function */ $i=0; $x=count($lines); $table_name = "or_results"; while ($i<$x) { $temp_data = explode(",", $lines[$i]); $field1= $temp_data[0]; $field2= $temp_data[1]; $field3= $temp_data[2]; $field4= $temp_data[3]; $sql = "INSERT into ".$db['results']."(sub_event_id,race_no,position_no,time) values('$field1','$field2','$field3','$field4')"; $result = mysql_query($sql) or die(mysql_error()); } } Coming back with error message "There was an error uploading the file, please try again!" Any ideas? I may be doing something wrong around the part i have put in italics! Help greatly appreciated.
  10. Hello I am trying to do a simple CSV import of a file and then upload to mysql. I am basing my code on an example I have found and I am getting the error message 'invalid file'. The example used includes a text box for the file import field and I am referencing the file from my computer in that box 'Users/James/name.csv' My code is as follows: HTML <form action="results.php?data=upload" method='post'> Import File : <input type='text' name='sel_file' size='20'> <input type='submit' name='submit' value='submit'> </form> PHP if ($b == 'upload') { $fname = $_FILES['sel_file']['name']; $chk_ext = explode(".",$fname); if(strtolower($chk_ext[1]) == "csv") { $filename = $_FILES['sel_file']['tmp_name']; $handle = fopen($filename, "r"); while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { $sql = "INSERT into ".$db['name']."(field1,field2,field3,field4) values('$data[0]','$data[1]','$data[2]', '$data[3]')"; mysql_query($sql) or die(mysql_error()); } fclose($handle); echo "Successfully Imported"; } else { echo "Invalid File"; } } my file format is: 1,23,1,5 1,24,2,5 1,25,3,5 1,26,4,5 1,27,5,5 1,28,6,5 1,29,7,5 1,30,8,5 1,31,9,5 1,32,10,5 If anybody can help that would be good - or perhaps point out if I am going about this the wrong way - cheers
  11. Actually I have it working now, thanks for the pointer. J
  12. Thanks. Are you saying that it should read like this: $postcode = explode("::", $postcode_array); I'm returning a 'NULL' btw
  13. Hi I have a function that takes a postcode and splits it so i can enter into DB into two formats, full postcode and prefix. The function is: function check_form_postcode($postcode) { $postcode = strtoupper(str_replace(chr(32),'',$postcode)); $suffix = substr($postcode,-3,3); $prefix = substr($postcode,0,(strlen($postcode)-3)); if (preg_match('/(^[A-Z]{1,2}[0-9]{1,2}|^[A-Z]{1,2}[0-9]{1}[A-Z]{1})$/',$prefix) && preg_match('/^[0-9]{1}[ABD-HJLNP-UW-Z]{2}$/',$suffix)) { $postcode_syntax_check = 1; } else { $postcode_syntax_check = 0; } if($postcode_syntax_check){ $return = $prefix."::".$suffix; } return($return); } I POST the form data and in the top of the same page I get all of the form data and here is is where things go wrong: if ($b == 'go') { //Gets form data $main_event_name = my_import('main_event_name', 'P', 'TXT'); $main_event_type = my_import('main_event_type', 'P', 'TXT'); $main_event_date = my_import('main_event_date', 'P', 'TXT'); $main_event_city = my_import('main_event_city', 'P', 'TXT'); $postcode = my_import('postcode', 'P', 'TXT'); $main_event_added = my_import('main_event_added', 'P', 'INT'); $main_event_active = my_import('main_event_active', 'P', 'INT'); $postcode_array = check_form_postcode($postcode); $postcode = explode($postcode_array, "::"); $prefix = $postcode[0]; $fullpostcode = $postcode[0]." ".$postcode[1]; $valkey = md5(microtime()); $info = array( "main_event_name"=> $main_event_name, "main_event_type" => $main_event_type, "main_event_date" => $main_event_date, "main_event_city" => $main_event_city, "main_event_active" => $main_event_active, "main_event_added" => $sys['now'], "main_event_pcode" => $fullpostcode, "main_event_pcode_prefix" => $prefix, "eo_id" => $eo['id'] ); $table = $db['main_event']; $userid = my_insert($info, $table); When I enter into the DB all I get is the "::" no data. I know that the POST works as I can enter the data easily without the function going wrong. Thanks for any help, i am new to arrays go easy if I have made an obvious mistake! Cheers...
  14. This is whole lot: <? include'E:\domains\s\domain\user\private\mysql_connect.php'; mysql_select_db("pix", $con); $result = mysql_query("SELECT * FROM mpora); while($row = mysql_fetch_assoc($result)) { echo "<div class=\"panel\">"; echo "<div class=\"inside\">"; echo . $row['embed_url'].; echo "<h2>" . $row['heading'] . "</h2>"; echo "<p>" . $row['caption'] . "<p>"; echo "</div>"; echo "</div>"; } mysql_close($con); ?> The error is on line 40, which is the first echo of panel class. Driving me mad! Thanks for looking at it.
  15. Thanks for the reply. I need the class called panel, so I have added it in. It doesn't like the first echo statement though? while($row = mysql_fetch_assoc($result)) { echo "<div class=\"panel\">"; echo "<div class=\"inside\">"; echo "<img src=' ". $row['embed_url']." ' alt=\"Mpora Video\" />"; echo "<h2>" . $row['heading'] . "</h2>"; echo "<p>" . $row['caption'] . "<p>"; echo "</div>"; echo "</div>"; } Parse error: syntax error, unexpected T_CLASS in E:\domains\s\domain.com\user\htdocs\gallery\index.php on line 42
  16. I want to dynamically generate content and for as many records as I have in my database but put it into CSS. My mark up template i want to use is as follows: <div class="panel"> <div class="inside"> //here i will echo an embed video from youtube <h2> //here i will echo a heading</h2> <p> // here i will echo description</p> </div> </div> I know how to do this with tables but want to use CSS. I know it will be something like: <? include'E:\domains\s\domain\user\private\mysql_connect.php'; mysql_select_db("pix", $con); $result = mysql_query("SELECT * FROM table); <div class="panel"> <div class="inside"> echo "<img src=' ". $row['embed_url']." ' alt="Mpora Video" />"; echo "<h2>" . $row['heading'] . "</h2>"; echo "<p>" . $row['caption'] . "<p>"; </div> </div> mysql_close($con); ?> But i know I am missing the loop statement and and am struggling. Please help! Thanks
  17. If you scroll down on this page, it is under Mpora title http://www.spartanwetsuits.com/gallery/ I have tweaked it a bit, but because it was designed for narrower content im struggling with making the slide effect look good. For example, if you click to the right nothing happens. My stylesheet is currently like this: If you need to see the markup use the link i orginally provided for the example. While I am developing it i have just added it to an iframe. Thanks * { margin: 0; padding: 0; } body { font: 11px Helvetica, Arial, sans-serif; color:#FFFFFF; } #wrapper { width: 1000px; margin: 10px auto; } #intro { padding-bottom: 10px; } #slider { width: 900px; margin: 0 auto; position: relative; border: 10px solid #ccc; } .scroll { overflow: hidden; width: 900px; margin: 0 auto; position: relative; } .scrollContainer { position: relative; } .scrollContainer div.panel { padding: 10px; width: 480px; height: 375px; } #left-shadow { position: absolute; top: 0; left: 0; width: 12px; bottom: 0; background: url(../images/leftshadow.png) repeat-y; } #right-shadow { position: absolute; top: 0; right: 0; width: 12px; bottom: 0; background: url(../images/rightshadow.png) repeat-y; } .inside { padding: 0px; border: 1px solid #999; } .inside img { display: block; border: 1px solid #666; margin: 0 0 10px 0; width: 480px; } .inside h2 { font-weight: normal; color: #fff; font-size: 16px; margin: 0 0 8px 0; } .inside p { font-size: 11px; color: #ccc; } a { color: #999; text-decoration: none; border-bottom: 1px dotted #ccc; } a:hover { border-bottom: 1px solid #999; } .scrollButtons { position: absolute; top: 127px; cursor: pointer; } .scrollButtons.left { left: -45px; } .scrollButtons.right { right: -45px; } .hide { display: none; } #mpora_logo{ margin-left: 25px; } #mpora_footer{ margin: 10px 0px 0px 100px;
  18. Hi, I am taking this example: http://css-tricks.com/examples/MovingBoxes/ And trying to add content that is: 480 wide x 315 high. Basically, I am planning to use this to display some videos from action sports site Mpora. My problem is that when I start tweaking the CSS everything goes out of alignment. Can someone help me with the stylesheet? Thanks a lot...learning CSS! ---------------------------------------------------- * { margin: 0; padding: 0; } body { font: 11px Helvetica, Arial, sans-serif; } #wrapper { width: 800px; margin: 25px auto; } #intro { padding-bottom: 10px; } #slider { width: 800px; margin: 0 auto; position: relative; border: 10px solid #ccc; } .scroll { overflow: hidden; width: 800px; margin: 0 auto; position: relative; } .scrollContainer { position: relative; } .scrollContainer div.panel { padding: 10px; width: 274px; height: 318px; } #left-shadow { position: absolute; top: 0; left: 0; width: 12px; bottom: 0; background: url(../images/leftshadow.png) repeat-y; } #right-shadow { position: absolute; top: 0; right: 0; width: 12px; bottom: 0; background: url(../images/rightshadow.png) repeat-y; } .inside { padding: 10px; border: 1px solid #999; } .inside img { display: block; border: 1px solid #666; margin: 0 0 10px 0; width: 250px; } .inside h2 { font-weight: normal; color: #111; font-size: 16px; margin: 0 0 8px 0; } .inside p { font-size: 11px; color: #ccc; } a { color: #999; text-decoration: none; border-bottom: 1px dotted #ccc; } a:hover { border-bottom: 1px solid #999; } .scrollButtons { position: absolute; top: 127px; cursor: pointer; } .scrollButtons.left { left: -45px; } .scrollButtons.right { right: -45px; } .hide { display: none; }
  19. Thanks that did the trick. Any way of propagating this change for all of my site? All other pages failing unless i do the change maanually!
  20. I have installed Easyphp environment locally on my machine. I can do a test such as <html> <head> <title>My first page in PHP.</title> </head> <body> Current date. : <?php print (Date("l F d, Y")); ?> </body> </html> And i get the date, so this means php is working right?? When i try and load a site i am working on such as this: <? include("header.html"); ?> <div id="home"> </div> <? include("footer.html"); ?> Nothing displays. Source code of the browser shows the include commands so it isnt to converting it into HTML? Thanks.
×
×
  • 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.