-
Posts
759 -
Joined
-
Last visited
Everything posted by alpine
-
well drace, did you try it after the mysql_query correction? And, is the password encrypted in the table? If so, u need to match encrypted post-value against the stored db-value
-
Inside you query, ditch the &&, use AND $query = "SELECT * FROM pr0n_members WHERE username='$username' AND password='$password'";
-
No, that's fairly easy - detect based on if the title is present or not in the adress bar: <?php if(!empty($_GET['title'])){ // title is present - do search $dropdown = htmlspecialchars($_GET['title'],ENT_QUOTES); $sql = mysql_query("SELECT * FROM recipes WHERE title='$title'"); while($row = mysql_fetch_array($sql)){ echo <<<_HTML <h4> {$row['title']}<br /> {$row['ingredients']}<br /> {$row['method']}<br /> </h4> _HTML } } else // title is absent or empty - show dropdown { echo <<<_HTML <form action="this.php" method="get"> <select name="title"> _HTML; $query = mysql_query("SELECT title FROM recipes"); while($dropdown = mysql_fetch_array($query)){ echo "<option value=\"".$dropdown['title']."\">".$dropdown['title']."</option>"; } echo <<<_HTML </select> <input type="submit" name="Submit" value="Submit" /> _HTML; } ?> Should do it...
-
Name the select <select name="title"> And add the value echo "<option value=\"".$dropdown['title']."\">".$dropdown['title']."</option>";
-
You allow too much jumbo to be posted, i was able to change the background color of your page way too easy. Example: http://www.13thstar.info/forums.php?act=posts&topicid=8
-
Look at the colored part, the variable is just written outside any definition or echo and it misses the mandatory ; if ($artist_fn != "") { $artist_fullname = trim("$artist_fn $artist_ln"); //************ error is in here - else - ? *************** $artist_fullname; } else { $artist_fullname = trim("$artist_ln"); } //************************************************ Look at this <?php if ($artist_fn != "") { $artist_fullname = trim("$artist_fn $artist_ln"); } else { $artist_fullname = trim("$artist_ln"); } if ($date_acq == "0000-00-00") { $date_acq = "[unknown]"; $display_block .= "<P><strong>$title</strong> on $rec_label, by $artist_fullname<br> $my_notes <em>(acquired:$date_acq, format:$format)</em></P>"; } ?> FYI: I was only fixing your problem, not made any other improvements or changes.
-
Do you mean how to "read" the id from the adress-bar and how to use it ? Example with mysql: <?php if(!empty($_GET['member_id'])){ $member_id = $_GET['member_id']; $sql = mysql_query("SELECT * FROM members_table WHERE id='$member_id'"); if(mysql_num_rows($sql)==1){ $col = mysql_fetch_array($sql); echo "User ".$col['name']." has ID ".$col['id']; } else{ echo "No user found with ID ".$member_id; } } ?> But it boils down to how your existing members page is constructed, but $_GET['whatever'] wil get 'whatever' from the adress bar.
-
Parse error: syntax error, unexpected ';', expecting
alpine replied to suttercain's topic in PHP Coding Help
yah, good spot -
Parse error: syntax error, unexpected ';', expecting
alpine replied to suttercain's topic in PHP Coding Help
return $result;11: should be only return $result; -
Normally it should work just aswell in a php file as long as you have this outside any php tags. What's the problem then?
-
You cannot have any whitespace, lines or other output to the browser before the php start-tag OK: ------------------------------------------------------------------ <?php session_start(); ERROR: ------------------------------------------------------------------ <?php session_start(); Means it's ok to put session_start() 'anyhwhere' as long as no output is done before it.
-
Try to remove session_write_close() - it ends the session, http://no.php.net/manual/en/function.session-write-close.php
-
Its all about how you define your message string, look at this: <?php $password = "12345"; echo $password; // prints 12345 echo '$password'; // prints $password echo "$password"; // prints 12345 ?>
-
Use str_replace() instead of preg_replace() if you don't need fancy replacing rules <?php $username = str_replace(" ", "_", $username); ?>
-
why isnt this variable getting in to my query string?
alpine replied to jimmi8's topic in PHP Coding Help
In your linking part, try this: <?php echo '<li><h3>'; echo $upload; if(isset($upload)){ echo '<a href="individualarticle.php?f=1&blog_id=' .$blog_id. '">'; } else{ echo '<a href="individualarticle.php?f=0&blog_id=' .$blog_id. '">'; } echo $title .'</a>'; if(isset($upload)){ echo '<img src="pin.gif" />'; } echo <<<_HTML </h3> <p style="color: red; display: inline;">written by {$author} on {$date} Posted in <a href="categorypage.php?category_id={$cat}">{$cat1}</a></p> <p>{$body}</p> </li> <p><a href="individualarticle.php?blog_id={$blog_id}">read on...</a></p> _HTML; ?> -
Running Zonelabs Pro Firewall last couple of years - properly set up and i've been virus free ever since! No antivirus to steal recourses. It quarantines suspisious attatchments etc.
-
The problem is that you are constantly overwriting the $sql variable while the loop is running Try something like this: <?php include("check.php"); include("include.php"); if($_SESSION['auth']) { $query = mysql_query("SELECT id, title, category, status FROM software"); echo "<table align='center' cellpadding='2' cellspacing='2' width='100%'> <tr bgcolor='#1469A2'> <td width='50%'><b>Software Title</b></td> <td width='20%'><b>Category</b></td> <td width='15%'><b>Status</b></td> <td width='15%'><b>Check Out?</b></td> </tr>"; while ($data = mysql_fetch_array($query)) { echo "<tr bgcolor='#003C64'> <td width='50%'>".$data['title']."</td> <td width='20%'>".$data['category']."</td> <td width='15%'>".$data['status']."</td> <td width='15%'>"; if ($data['status'] == "Available") { echo "<form method='POST' style='margin:0px;'> <input type='hidden' name='id' value='$data['id']'> <input type='submit' name='checkout' style='border:1px #1469A2 solid;' value='Check Out'> </form>"; } else { echo "<i>Not Available</i>"; } echo "</td></tr>"; } echo "</table>"; if(isset($_POST['checkout'])) { $date = date("Y/m/d"); $username = $_COOKIE['cis_username']; $id = $_POST['id']; $sql = "UPDATE `software` SET `status` = 'Checked Out', `by` = '$username', `date` = '$date' WHERE `id` = '$id'"; mysql_query("$sql") or die (mysql_error()); echo "You have checked out <b>".$title."</b> successfully"; } } else { echo "You need to login to view this page! <a href='index.php?page=login'>Login here</a>"; } ?>
-
Here is part of a newsletter thing i wrote a while ago, i'm sure you can adjust it to your needs. Read comments <?php // prepare to save a html version of news.php // make sure you already have a blank html page to duplicate from $source_html_doc = "../newsletter/archive/blank.html"; $today = date(dmY); $new_blank_html_doc = "../newsletter/archive/news_".$today."html"; copy($source_html_doc, $new_blank_html_doc)or die('Could not copy required file'); // start getting the generated contents of news.php ob_start(); require("news.php"); // or run php contents here instead $body_news = ob_get_contents(); // write a html version of it as archive $html_change = fopen ($new_blank_html_doc, 'w'); fwrite ($html_change, $body_news); fclose ($html_change); // END ob_start ob_end_clean(); ?>
-
Dunno if this is what you are looking for, but it checks whether the required one is present and walks throug all - included optional ones Not tested. <?php //the variables /* $line[0] is the address $line[1] is a port (required) $line[2] is a port (optional) $line[3] is a port (optional) $line[4] is a port (optional) */ $check = array_slice($line, 1); if(!empty($line) && !empty($check)){ foreach($check as $port){ $fp = fsockopen ($line[0],$port, $errno, $errstr, 10); if (!$fp) { echo "<br><b>Checking $line[0]...</b><br>\n"; echo "<table border=1 cellpadding=0 cellspacing=0 bordercolor=#000000><tr>\n"; echo "<td>Status: Down, Domain: $line[0], Port: $port</td>\n"; echo "</tr>\n<tr>\n"; echo "</tr></table>\n"; } else { echo "<br><b>Checking $line[0]...</b><br>\n"; echo "<table border=1 cellpadding=0 cellspacing=0 bordercolor=#000000><tr>\n"; echo "<td>Status: Up, Domain: $line[0], Port: {$port}$a</td>\n"; echo "</tr>\n<tr>\n"; echo "</tr></table>\n"; } fclose($fp); } } else{ echo "Required port is not selected"; } ?>
-
[SOLVED] how to change @ to _AT_ and # to _SHARP_ etc
alpine replied to amb99's topic in PHP Coding Help
Sorry - a glitch with the array, but you seem to grasp it and that's the point! -
[SOLVED] how to change @ to _AT_ and # to _SHARP_ etc
alpine replied to amb99's topic in PHP Coding Help
I notice from a prev post that you are on php4, here is a str_split function to get my above example running under php4 <?php function str_split($string) { $piece = array(); $length = strlen($string); for($i=0;$i<$length;$i++) $piece[] = $string{$i}; return $piece; } ?> -
[SOLVED] how to change @ to _AT_ and # to _SHARP_ etc
alpine replied to amb99's topic in PHP Coding Help
Here is one, note that its php5 dependant due to str_split() <?php $string = "kfgak*suh@hd#t"; $invalid = array(); $filtered = array_values(str_replace(array_merge(range(a,z),range(A,Z),range(0,9),array('.')),'',str_split($string))); foreach(str_split($string) as $char){ if(in_array($char,$filtered,true)){ $invalid[] = $char; } } if(!empty($invalid)){ $string = str_replace(array("@","#"), array("_AT_","_SHARP_"), $string); $string = str_replace(array_values(str_replace(array_merge(range(a,z),range(A,Z),range(0,9),array('-','.','_')),'',str_split($string))),'_ILLEGAL_',$string); echo "<p>Following chars was not accepted:</p><ul><li>"; echo implode($invalid,'</li><li>'); echo "</li></ul>"; echo "String was translated to: $string"; } else{ echo "No illegal chars found"; } ?> This example prints out: Following chars was not accepted: * * * @ * # String was translated to: kfgak_ILLEGAL_suh_AT_hd_SHARP_t No regex though... -
Here is a non-regex version: <?php $string = "gsjdtb7l,-'%&!"; echo str_replace(array_values(str_replace(array_merge(range(a,z),range(A,Z),range(0,9),array('-','.')),'',str_split($string))),'',$string); // prints: gsjdtb7l- ?> EDIT* Requires php5 though due to str_split()
-
<?php if(in_array($activity, range(1,6))){ $activity1 = "New Member"; } ?>