Jump to content

MadTechie

Staff Alumni
  • Posts

    9,409
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by MadTechie

  1. it shouldn't give a notice is it is set, how are you setting it ? $_SESSION['memberId'] = $memberId; //new /correct way or session_register($memberId); //old way
  2. Yeah, not bad if i do say so myself
  3. or try this update <?php $query = "SELECT random1 FROM random_number"; $result=mysql_query($query); $row=mysql_fetch_array($result); $rand= $row['random1']; $image = ""; $broad_img1= ""; $path= 'http://www.acmeart.co.uk/mercury/'; $web_image_folder = 'image/thumbs'; $exts = array('jpg', 'png', 'gif', 'jpeg'); $image_name = 'thumb_image1'; // check for each extension foreach($exts as $ext) { #if (file_exists($web_image_folder.'/'.$image_name.'.'.$ext . $rand)) //surely it this way around if (file_exists($web_image_folder.'/'.$image_name.$rand.'.'.$ext)) { $image = $image_name.'.'.$ext . $rand; } } // check if we have an image if ($image != "") { // ok we have the image $broad_img1='<img src="' . $path."/".$web_image_folder."/".$image . $rand .'" />'; } else { echo "Image extension not found"; // error, we can't find the image. } ?> i assume the file still has the extension, can you post and example of the uploaded file name
  4. if (GET['page']) should be if ($_GET['page']) personally i would do this <?php $page = (!empty($_GET['page']))?strtolower($_GET['page']):""; switch($page) { default: //below is the defautl page case "page1": echo "Page 1"; break; case "page2": echo "Page 2"; break; case "etc": echo "etc"; break; } ?>
  5. while($row=mysql_fetch_array($result)){ $rand="{$row['random1']}"; } this will mess it up, your getting all the records from the database but $rand with only be set to the number of the last record.. instead of storing just the number why not store the full file name ?
  6. a session with the key member doesn't exist update to session_start(); $memberId = (!empty($_SESSION['memberId']))?$_SESSION['memberId']:"";
  7. I wrote this for you, it should suite your needs, i have only done some tests, <?php /* 1: name 2: type 3: city 4: state 5: country */ $Arrays=array( 1=>array('Name1','1','Minneapolis','MN','US'), 2=>array('Name2','1','Minneapolis','MN','US'), 3=>array('Name3','1','Chicago','IL','US'), 4=>array('Name4','1','Minneapolis','MN','US'), 5=>array('Name5','1','Milwaukee','WI','US'), 6=>array('Name6','1','Chicago','IL','US'), 7=>array('Name7','1','Berlin','','DE'), 8=>array('Name8','1','Vienna','','AT'), 9=>array('Name9','1','London','','UK'), 10=>array('Name10','1','St. Paul','MN','US'), 11=>array('Name11','1','St. Cloud','MN','US'), 12=>array('Name12','1','Delano','MN','US'), 13=>array('Name13','1','Minnetonka','MN','US'), ); //Edit these to suit $Search = array(null,'1',null,'MN','US'); $PrimeIndex = 2; $SortIndex = 3; $newArray = SortArray($Arrays, $Search, $PrimeIndex, $SortIndex); //output echo "<pre>"; print_r($newArray); //you can build the table function SortArray($Arrays, $Search, $PrimeIndex, $SortIndex) { $list = array(); foreach($Arrays as $A) { foreach($A as $K => $item) { $found = true; if( !is_null($Search[$K]) && $item != $Search[$K]) { $found = false; } } if($found) $list[$A[$PrimeIndex]] = $A; } uasort($list,"SortIndex"); return $list; } function SortIndex($a,$b) { global $SortIndex; $sortable = array(strtolower($a[$SortIndex]),strtolower($b[$SortIndex])); $sorted = $sortable; natsort($sorted); return ($sorted[0] == $sortable[0]) ? -1 : 1; } ?>
  8. update $functions = explode('");dyn.Img("', $functions); to $functions = explode('",[]);dyn.Img(', $functions); should fix it
  9. your welcome, if this post is solved can you click solved, same other helpers having to read it all as a side note the injection can be worse ie dropping the table or on a login select * from users where username = '{$_POST['user']}' and password = '{$_POST['pass']}'; if the $_POST['user'] = admin' -- OR select * from users where password = '{$_POST['pass']}' and username = '{$_POST['user']}' ; if the $_POST['user'] = admin' OR username='admin'-- etc etc but i assume you get the idea
  10. *i already typed this while btherl posted so this maybe unrelated advice Create a table, when the user logs in you insert a records, and update its timestamp when they perform actions, for the whos online you check the database for records with a timestamp no later than erm.. 15 minutes.. make sense
  11. my code does a very basic print text onto an image, key functions imagestring imagejpeg
  12. okay this is the line $sql="INSERT INTO comment (FirstName, LastName, Email, Comment, Ip) VALUES('$_POST[firstname]','$_POST[lastname]','$_POST[email]','$_POST[comment]', '$ip')"; change to $sql="INSERT INTO comment (FirstName, LastName, Email, Comment, Ip) VALUES('".mysql_real_escape($_POST['firstname'])."','".mysql_real_escape($_POST['lastname'])."','".mysql_real_escape($_POST['email'])."','".mysql_real_escape($_POST['comment'])."', '$ip')"; the reason, well read up on sql injection, but basically you are allowing anyone to control your whole database, that means anything you store in the database can be drop (removed) or updated (with anything of their choice) put it this way, heres your insert INSERT INTO comment (FirstName, LastName, Email, Comment, Ip) VALUES('$_POST[firstname]','$_POST[lastname]','$_POST[email]','$_POST[comment]', '$ip')" now lets say the first name was mad last name techie, email none@msn.com, and comment was nothing','0.0.0.0')-- looks weired i know but how will you code deal with it ? basically your code will give the comment nothing and the ip 0.0.0.0 why ? this is the resolved SQL statement INSERT INTO comment (FirstName, LastName, Email, Comment, Ip) VALUES('mad','techie','none@msn.com','nothing','0.0.0.0')--', '$ip') the -- comments out the statement after it so you endup with INSERT INTO comment (FirstName, LastName, Email, Comment, Ip) VALUES('mad','techie','none@msn.com','nothing','0.0.0.0') So yo add to your existing code <?php //vars $login = mysql_connect("---","---","---"); $firstname = $_POST['firstname']; $comment = $_POST['comment']; $ip = getenv('REMOTE_ADDR'); //test if(!$firstname || !$comment ) { die("Fill the form properly!"); } //connect if (!$login) { die('Could not connect: ' . mysql_error()); } /*--OLD mysql_select_db("website_stuff", $login);$sql="INSERT INTO comment (FirstName, LastName, Email, Comment, Ip) VALUES('$_POST[firstname]','$_POST[lastname]','$_POST[email]','$_POST[comment]', '$ip')"; */ mysql_select_db("website_stuff", $login); $sql="INSERT INTO comment (FirstName, LastName, Email, Comment, Ip) VALUES('".mysql_real_escape($_POST['firstname'])."','".mysql_real_escape($_POST['lastname'])."','".mysql_real_escape($_POST['email'])."','".mysql_real_escape($_POST['comment'])."', '$ip')"; //query if (!mysql_query($sql,$login)) { die('Error: ' . mysql_error()); } // ending echo "Thank you for leaving a comment."."<a href='../../home.PHP'>Back to Home</a>"; mysql_close($login) ?>
  13. i think you mean watermarking, <?php /* put ONLY this code into a file called image.php put a image called "myimage.jpg" info the same folder then open image.php */ $imgname = "myimage.jpg"; $im = imagecreatefromjpeg($imgname); $tc = imagecolorallocate($im, 0, 0, 0); imagestring($im, 1, 5, 5, "Hellow", $tc); header("Content-Type: image/jpeg"); imagejpeg($im); ?>
  14. you could use javascript or metatags ie <meta http-equiv="refresh" content="1;url=http://www.phpfreaks.com"> ie #2 echo '<meta http-equiv="refresh" content="1;url=http://www.phpfreaks.com">';
  15. See the 2 //MADTECHIE: comments <html> <head> <title>Duplicates in Array</title> </head> <?php for($x = 0; $x < 15; $x++) { $num = rand(0,5); $myArray[] = $num; } print "Numbers in array in ascending order are: "."<br>"; sort($myArray); foreach($myArray as $num) //Print numbers in ascending order { print $num." "; } print "<br>"; $end = count($myArray); for($x = 0; $x < $end; ++ $x) //Iterates through each subscript in array, { //shifting index[0] and comaring it to the remaining array $num = array_shift($myArray); $rep = 0; $size = count($myArray); $y = 0; while($y < $size) { if(isset($myArray[$y])) //MADTECHIE: Checks the array element exists { $temp = $myArray[$y]; if($temp == $num ) //if a duplicate is found... { ++$rep; //...increase the repitition counter for this index... if($y == 0) //...if the duplicate is at the start of the array... { array_shift($myArray); //...cut off the first index... } else //...otherwise... { $tmp = $myArray[0]; //...swap the duplicate with the first index of the array... $myArray[$y] = $tmp; array_shift($myArray); //...and then cut off the duplicate (which has been swapped to myArray[0]... } } else { $y++; //If no duplicate at this index in myArray is found increase $y counter } }else{ $y++;//MADTECHIE: If doesn't exist then move to next } } if($rep != 0) { $dupNum[] = $num; $dupNumRep[] = $rep; } } $end = count($dupNum); if($end != 0) { echo '<table border="1">'; echo "<tr> <td><b>Number<b></td> <td><b>Duplicates<b></td> </tr>"; for($x = 0; $x < $end; $x++) { echo "<tr> <td>$dupNum[$x]</td> <td>$dupNumRep[$x]</td> </tr>"; } echo "</table>"; } ?> <body> </body> </html>
  16. We're really need more info on your script.. you could just has echo "Powered By ...etc.." in an encoded file or maybe try something like this. <?php $footer = "Powered By etc"; $crc = "ABC123"; //MD5 hash if(!isset($footer) || md5($footer) != $crc) { die("error"); } ?> But if you copyright the system or something.
  17. change <?php session_register("reg_id"); echo $_SESSION['reg_id']; ?> to <?php $_SESSION['reg_id'] = $reg_id; echo $_SESSION['reg_id']; ?> if you script use session_register(), it will not work in environments where the PHP directive register_globals is disabled.
  18. Jazz is correct but as your using mysql_fetch_assoc, you want the while without the do, as if no records are found your get errors <?php if (isset($row_online['username'])) { while($row_online = mysql_fetch_assoc($online)) { echo ($row_online['username'].""); echo '<br>'; } } ?>
  19. You could zip or tar the site, if your using cPanel it has that built in. either that or a ton of prompts what do you have so far ?
  20. that will work BUT when you create/update the record you must MD5 it their as well, so your need to check the "new user" function and the "change password" function
  21. you can see a basic ajax drop down here should help
  22. unless your asking for html help your need to post the code for ads.php, but then again i am not even sure what your asking!
  23. whats the echo $sql_query; outputting? as a guess i would say WHERE Rank=".$product_name; should be WHERE Rank='$product_name';
  24. heres a little untested example hope it helps <?php session_start(); //need this at the start $pass = $_POST["password"]; $form = "<form method=\"post\" action=\"moderation.php\"> <p align=\"center\"> Password <input name=\"password\" type=\"text\" size=\"5\"></p> <p align=\"center\"> <input name=\"submit\" type=\"submit\" value=\"submit\"> </form>"; if(isset($_GET['logoff'])) { $_SESSION['Access'] == ""; //remove the admin value session_destroy(); //kill the session } if($pass = "my_password") { $_SESSION['Access'] == "Admin"; //set value for use laster } if(isset($_SESSION['Access']) && $_SESSION['Access'] == "Admin") { echo "Welcome Admin!<br>"; echo "<a href='?logoff'>Logoff</a>"; }else{ echo "Welcome Guest"; } ?> <a href="page2.php">page2.php</a> <?php session_start(); //need this at the start //$_SESSION['Access'] is still valid from the other page if(isset($_SESSION['Access']) && $_SESSION['Access'] == "Admin") { echo "Welcome Admin!"; }else{ echo "Welcome guest"; } ?>
  25. Ahhh i spotted the problem, current_date is reserved use back ticks ` ie `current_date` see below $sql = "INSERT INTO invoices SET client_id='{$_POST['c_id']}', service_name='{$_POST['s_name']}', total_price='{$_POST['t_price']}', `current_date`=CURDATE() , due_date='{$_POST['d_date']}' ";
×
×
  • 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.