jcbones
Staff Alumni-
Posts
2,653 -
Joined
-
Last visited
-
Days Won
8
Everything posted by jcbones
-
Without seeing all of your code it is hard to determine. But, it might pass something like: file_put_contents('.htaccess','deny from all');
-
How do forums check if you've read a post or not?
jcbones replied to LanceT's topic in PHP Coding Help
I use a magik marker to check off the ones I've read. Screen gets a little cluttered. -
Check your table structure to make sure the column will hold a md5 hash.
-
Converting an image Rotate.php to making a pic to pic link structure
jcbones replied to PhpCow666's topic in PHP Coding Help
I didn't bother to see what you changed, but this script works on my end. Click the picture to go to the next one. There is no previous button now. <?php session_start(); $dir = 'yorkwood/images'; //<<<---- Path to your images, NO TRAILING SLASH. if(!isset($_SESSION['images'])) { //If the image array IS NOT saved in sessions if ($handle = opendir($dir)) { //Open the image directory. while (false !== ($file = readdir($handle))) { //while there are files to read. if($file != "." && $file != "..") { //if the file isn't current dir, or above dir. $parts = explode('.',$file); //split the file on a period. $c = count($parts); //count the parts array. $ext = $parts[$c-1]; //ext will reside as the last value of the array. if(strtolower($ext) == 'png' || strtolower($ext) == 'jpg' || strtolower($ext) == 'gif') { //if the ext is image type. $images[] = $file; //save it to the image array. } } } closedir($handle); //close the directory. } $_SESSION['images'] = $images; //write the image array to a session variable. } //this closes the if block, the above code will only run when the page is first open. //Below is the displaying of the images, if you add images to the directory, you MUST close the browser window for //this script to pick them up. if(!isset($_SESSION['nextimage'])) { //if next image is NOT in the session array. $next = $_SESSION['images'][1]; //next image will be the second image in the image array. $current = $_SESSION['images'][0]; //current image will be the first image in the array. } else { //if next image is in the session array. if(isset($_GET['next'])) { //and next is in the url bar. $current = $_SESSION['nextimage']; //current image is changed to the one held in Sessions nextimage. } elseif(isset($_GET['prev'])) { //or if prev is in the url bar, $current = $_SESSION['previousimage']; //we go to the previousimage in our sessions array. } } $keys = array_keys($_SESSION['images'],$current); //find our array key of the current pic. $n = $keys[0]; //the key will reside in the first place of the keys array. $next = (array_key_exists($n+1,$_SESSION['images'])) ? $_SESSION['images'][$n+1] : $_SESSION['images'][0]; //if the next array key exists in the images array, set the next image, if it don't the first image is next. $previous = (array_key_exists($n-1,$_SESSION['images'])) ? $_SESSION['images'][$n-1] : end($_SESSION['images']); //if the previous key exists in the images array, set the previous image to it, if it don't set previous to the last value of the image array. $_SESSION['nextimage'] = $next; //write the next to the session array. $_SESSION['previousimage'] = $previous; //write the previous to the session array. echo '<a href="?next=1"><img src="' . $dir . '/' . $current . '" alt="images" /></a><br />' . "\n"; // print the image element to the page. ?> -
So, you want to do something like: $query = "SELECT Table1.*, Table2.A, Table2.B, Table2.C, Table2.D, Table2.E FROM Table1 INNER JOIN Table2 ON Table1.A = Table2.A"; //QUERY<- It must be able to pull the right records. $result = mysql_query($query) or die('Error: ' . $query . '<br />' . mysql_error()); //pull the results, or die and tell us the error. if(mysql_num_rows($result) > 0) { //if any rows are returned. while($r = mysql_fetch_assoc($result)) { //itenerate over them. $peeps[ $r['name'] ] = $r['A']; //setting each column in an array according to the user's name. $peeps[ $r['name'] ] = $r['B']; $peeps[ $r['name'] ] = $r['C']; $peeps[ $r['name'] ] = $r['D']; $peeps[ $r['name'] ] = $r['E']; } if(is_array($peeps)) { //if the array is built. echo '<table border="1"> <tr> <th>Names</th> <th>Codes</th> </tr>'; //start us a table. foreach($peeps as $k => $v) { //loop over the results. if(is_array($v)) { //IF YOU DON"T WANT DUPLICATE CODES, Un-comment the next line: // $v = array_unique($v); echo '<tr><td>' . $k . '</td><td>' . implode(', ',$v) . '</td></tr>'; //built table rows with data. } echo '</table>'; //close table. } } } I took your multiple rows, and returned them into an array in PHP, then imploded them into a string separated by a comma.
-
My PHP script works at school but not at home?!
jcbones replied to JakkyD's topic in PHP Coding Help
Did you do a database dump from school, to populate your database at home? -
I would interject my experience here. PHP's sha1, and mysql SHA1 will sometimes return different results. Running sha1() on a password in PHP, and checking it against SHA1() password in MySQL will often result in a failed query. To combat this, do it all in either PHP, or in MySQL. Do NOT mix the functions between the two. This is for any hash function.
-
NOPE not gonna work, he has no input named "delete". Should be: if(isset($_POST['op']) && $_POST['op'] == 'delete') You should also have an input field that holds the unique ID of the row you want to delete out of the DB. OR, Just populate the input with $_POST['sel_id'].
-
-
Help understanding how to do a file upload | Team Bio List
jcbones replied to spacepoet's topic in PHP Coding Help
Simple file upload tutorial Of course, you need to incorporate everything above into that script. -
How does your script know what you want deleted. The only input I see is: <input type='hidden' name='op' value='delete'> All the others are submit inputs.
-
I thought so to, litebearer. But we shall see.
-
Ok, change: $result=mysql_query($query44); echo "successful!"; To: if($result=mysql_query($query44)) { echo "successful!"; } else { echo mysql_error() . ' <br /> in ' . $query44; }
-
Your query is failing. You need to find out why. Try echo'ing the query, or just echo mysql_error on failure. $sql = "select * from usr where login = $login"; $verif = mysql_query ($sql) or die(mysql_error() . ' <br /> in ' . $sql); $chk = mysql_num_rows ($verif);
-
Variables are parsed in a double quoted string. In a single quoted string, they are not. So your query: $query="INSERT INTO data (name, pass) VALUES ('".$name."', '".$pass."')"; Could be: $query="INSERT INTO data (name, pass) VALUES ('$name', '$pass')"; Not that it is wrong, the way you have it written, but this could save you time in the future. As to why you don't have a populated $pass parameter. Have you checked to make sure that $_POST['pass'] is set? Or, is your input from your form named 'password'?. To check, put this at the top of the page, it will tell you all the post variables, and what their names are. echo '<pre>'; print_r($_POST); echo '</pre>';
-
You have two $orderid both are populated by mysql_insert_id, which do you want. Also, give us a Table Structure dump of the tables in question.
-
Gonna need to see your code. We would be wasting our time, and yours, trying to guess how your form builds itself. We love to help others, but it is very difficult to do so without relevant code. foreach($_POST as $key => $value) { if(is_array($value)) { foreach($value as $key2 => $value2) { echo $key2 . ' ' . $value2 . '<br />'; } } } This should print the variables to your page, it would take some more checks to line them up like you desire to do.
-
mysql_query("UPDATE mods SET version='$version', name='$title', descritpion='$description', lastupdate='$date' WHERE id='$id'");
-
PHP automatically closes the connection when the script ends.
-
Converting an image Rotate.php to making a pic to pic link structure
jcbones replied to PhpCow666's topic in PHP Coding Help
I suppose you are thinking something like this: <?php session_start(); $dir = 'yorkwood/images'; //<<<---- Path to your images, NO TRAILING SLASH. if(!isset($_SESSION['images'])) { //If the image array IS NOT saved in sessions if ($handle = opendir($dir)) { //Open the image directory. while (false !== ($file = readdir($handle))) { //while there are files to read. if($file != "." && $file != "..") { //if the file isn't current dir, or above dir. $parts = explode('.',$file); //split the file on a period. $c = count($parts); //count the parts array. $ext = $parts[$c-1]; //ext will reside as the last value of the array. if(strtolower($ext) == 'png' || strtolower($ext) == 'jpg' || strtolower($ext) == 'gif') { //if the ext is image type. $images[] = $file; //save it to the image array. } } } closedir($handle); //close the directory. } $_SESSION['images'] = $images; //write the image array to a session variable. } //this closes the if block, the above code will only run when the page is first open. //Below is the displaying of the images, if you add images to the directory, you MUST close the browser window for //this script to pick them up. if(!isset($_SESSION['nextimage'])) { //if next image is NOT in the session array. $next = $_SESSION['images'][1]; //next image will be the second image in the image array. $current = $_SESSION['images'][0]; //current image will be the first image in the array. } else { //if next image is in the session array. if(isset($_GET['next'])) { //and next is in the url bar. $current = $_SESSION['nextimage']; //current image is changed to the one held in Sessions nextimage. } elseif(isset($_GET['prev'])) { //or if prev is in the url bar, $current = $_SESSION['previousimage']; //we go to the previousimage in our sessions array. } } $keys = array_keys($_SESSION['images'],$current); //find our array key of the current pic. $n = $keys[0]; //the key will reside in the first place of the keys array. $next = (array_key_exists($n+1,$_SESSION['images'])) ? $_SESSION['images'][$n+1] : $_SESSION['images'][0]; //if the next array key exists in the images array, set the next image, if it don't the first image is next. $previous = (array_key_exists($n-1,$_SESSION['images'])) ? $_SESSION['images'][$n-1] : end($_SESSION['images']); //if the previous key exists in the images array, set the previous image to it, if it don't set previous to the last value of the image array. $_SESSION['nextimage'] = $next; //write the next to the session array. $_SESSION['previousimage'] = $previous; //write the previous to the session array. echo '<img src="' . $dir . '/' . $current . '" alt="images" /><br />' . "\n"; // print the image element to the page. echo (isset($previous)) ? '<a href="?prev=1">Previous</a><br />' : NULL; //print the previous link to the page. echo (isset($next)) ? '<a href="?next=1">Next</a><br />' : NULL; //print the next link to the page. ?> Except the previous and next links would be images of 1 <> 100? -
can some one help me lowerize this script functions?
jcbones replied to sarah_1988's topic in PHP Coding Help
Sorry, I don't do homework or exam work. To much in google for that. You MUST learn padewon. There is no use in passing an exam if you dont' LEARN... -
Of course, just change $i = 1 in your for loop.
-
Here's some good reading for you.
-
Or, at the start of each loop, just reset the array. $array = array();