Deadman2
Members-
Posts
8 -
Joined
-
Last visited
Never
About Deadman2
- Birthday 10/11/1990
Contact Methods
-
Website URL
http://
Profile Information
-
Gender
Not Telling
Deadman2's Achievements
Newbie (1/5)
0
Reputation
-
Argh im getting so close to getting this damn thing working, there is where i stand right now. This is the current output: General new.gif General Chat 1 0 Kurt Tutorials nonew.gif PHP Tutorials 1 0 Kurt Help nonew.gif No Subboards Defined! 0 0 N/A Show Off nonew.gif No Subboards Defined! 0 0 N/A Seems alright... only thing is that General should have a 2nd subboard under it called Introductions.... General new.gif General Chat 1 0 Kurt nonew.gif Intros 1 0 Kurt Tutorials nonew.gif PHP Tutorials 1 0 Kurt Help nonew.gif No Subboards Defined! 0 0 N/A Show Off nonew.gif No Subboards Defined! 0 0 N/A Thats what it should be displaying but its not... I am creating a multi-dim array based off of database output and this is the array that is being created: Array ( [1] => Array ( [title] => General [cat_row] => Array ( [1] => Array ( [icon] => new.gif [title] => General Chat [topic_count] => 1 [reply_count] => 0 [last_poster] => Kurt ) [2] => Array ( [icon] => nonew.gif [title] => Introductions [topic_count] => 1 [reply_count] => 0 [last_poster] => Kurt ) ) ) [2] => Array ( [title] => Tutorials [cat_row] => Array ( [1] => Array ( [icon] => nonew.gif [title] => PHP Tutorials [topic_count] => 1 [reply_count] => 0 [last_poster] => Kurt ) ) ) [3] => Array ( [title] => Help [cat_row] => Array ( [2] => Array ( [icon] => nonew.gif [title] => No Subboards Defined! [topic_count] => 0 [reply_count] => 0 [last_poster] => N/A ) ) ) [4] => Array ( [title] => Show Off [cat_row] => Array ( [2] => Array ( [icon] => nonew.gif [title] => No Subboards Defined! [topic_count] => 0 [reply_count] => 0 [last_poster] => N/A ) ) ) ) And once again here is the looping function: <?php function loop_replace( $loop, $vars = array( ), $error_line, $error_file ) { if ( $this->has_error == true ) { return; } else if ( $this->has_error == false ) { $this->current_loop_block = $this->generate_block_ref_data( $loop, array( " BEGIN ", " END " ), "loop" ); foreach ( $vars as $variable_name => $variable_content ) { if ( is_numeric( $variable_name ) && is_array( $variable_content ) ) { $rough_loop = $this->current_loop_block[2]; if ( is_array( $variable_content ) ) { foreach( $variable_content as $variable_name_2 => $variable_content_2 ) { if ( !is_array( $variable_content_2 ) ) { /** Associative Array Loops array( "title" => "Board Name" ) **/ $rough_loop = str_replace( $this->replacement_variable_prefix . $loop . "." . $variable_name_2 . $this->replacement_variable_suffix, $variable_content_2, $rough_loop ); } else if ( is_array( $variable_content_2 ) ) { /** Nested Array Loops array( "title" => "Name", "nested_loop" => array( "title" => "Sub Name" ) ) */ $this->current_nested_loop_block = $this->generate_block_ref_data( $variable_name_2, array( " BEGIN ", " END " ), "loop", $rough_loop ); $rough_nested_loop = $this->current_nested_loop_block[2]; foreach ( $variable_content_2 as $variable_name_nested => $variable_content_nested ) { if ( is_numeric( $variable_name_nested ) && is_array( $variable_content_nested ) ) { if ( is_array( $variable_content_nested ) ) { foreach( $variable_content_nested as $variable_name_nested_2 => $variable_content_nested_2 ) { $rough_nested_loop = str_replace( $this->replacement_variable_prefix . $variable_name_2 . "." . $variable_name_nested_2 . $this->replacement_variable_suffix, $variable_content_nested_2, $rough_nested_loop ); } } } $parsed_nested_loop = @rtrim( $rough_nested_loop ); } $this->current_nested_loop_block[3] = $parsed_nested_loop; $rough_loop = str_replace( $this->replacement_loop_prefix . " BEGIN " . $variable_name_2 . $this->replacement_loop_suffix . substr( $rough_loop, $this->current_nested_loop_block[0], $this->current_nested_loop_block[1] ) . $this->replacement_loop_prefix . " END " . $variable_name_2 . $this->replacement_loop_suffix, $this->current_nested_loop_block[3], $rough_loop ); $this->current_nested_loop_block = array( ); } } } } $parsed_loop .= rtrim( $rough_loop ); } $this->current_loop_block[3] = $parsed_loop; $this->current_template_html = str_replace( $this->replacement_loop_prefix . " BEGIN " . $loop . $this->replacement_loop_suffix . substr( $this->current_template_html, $this->current_loop_block[0], $this->current_loop_block[1] ) . $this->replacement_loop_prefix . " END " . $loop . $this->replacement_loop_suffix, $this->current_loop_block[3], $this->current_template_html ); $this->current_loop_block = array( ); } } ?> and the generate_block_ref_data function: <?php function generate_block_ref_data( $name, $tag, $type, $content = "" ) { $tag_start = ( $type == "loop" ) ? $this->replacement_loop_prefix . $tag[0] . $name . $this->replacement_loop_suffix : $this->replacement_variable_prefix . $tag[0] . $name . $this->replacement_variable_suffix; $tag_end = ( $type == "loop" ) ? $this->replacement_loop_prefix . $tag[1] . $name . $this->replacement_loop_suffix : $this->replacement_variable_prefix . $tag[1] . $name . $this->replacement_variable_suffix; $tag_start_pos = ( $content != null ) ? strpos( $content, $tag_start ) + strlen( $tag_start ) : strpos( $this->current_template_html, $tag_start ) + strlen( $tag_start ); $tag_end_pos = ( $content != null ) ? strpos( $content, $tag_end ) : strpos( $this->current_template_html, $tag_end ); $tag_length = $tag_end_pos - $tag_start_pos; return array( 0 => $tag_start_pos, 1 => $tag_length, 2 => ( $content != null ) ? substr( $content, $tag_start_pos, $tag_length ) : substr( $this->current_template_html, $tag_start_pos, $tag_length ), 3 => "" ); } ?> It seems like it is not adding the correct rows together as it should be.
-
Alright I have made a few new changes to the function: <?php function loop_replace( $loop, $vars = array( ), $error_line, $error_file ) { if ( $this->has_error == true ) { return; } else if ( $this->has_error == false ) { $this->current_loop_block = $this->generate_block_ref_data( $loop, array( " BEGIN ", " END " ), "loop" ); foreach ( $vars as $variable_name => $variable_content ) { if ( is_numeric( $variable_name ) && is_array( $variable_content ) ) { $rough_loop = $this->current_loop_block[2]; if ( is_array( $variable_content ) ) { foreach( $variable_content as $variable_name_2 => $variable_content_2 ) { if ( !is_array( $variable_content_2 ) ) { /** Associative Array Loops array( "title" => "Board Name" ) **/ $rough_loop = str_replace( $this->replacement_variable_prefix . $loop . "." . $variable_name_2 . $this->replacement_variable_suffix, $variable_content_2, $rough_loop ); } else if ( is_array( $variable_content_2 ) ) { /** Nested Array Loops array( "title" => "Name", "nested_loop" => array( "title" => "Sub Name" ) ) $this->current_nested_loop_block = $this->generate_block_ref_data( $variable_name_2, array( " BEGIN ", " END " ), "loop", $rough_loop ); foreach ( $variable_content_2 as $variable_name_nested => $variable_content_nested ) { $rough_nested_loop = $this->current_nested_loop_block[2]; foreach ( $variable_content_nested as $variable_name_nested_2 => $variable_content_nested_2 ) { $rough_nested_loop = str_replace( $this->replacement_variable_prefix . $variable_name_2 . "." . $variable_name_nested_2 . $this->replacement_variable_suffix, $variable_content_nested_2, $rough_nested_loop ); } $parsed_nested_loop .= @rtrim( $rough_nested_loop ); $rough_nested_loop = ""; } $this->current_nested_loop_block[3] = $parsed_nested_loop; $rough_loop = str_replace( $this->replacement_loop_prefix . " BEGIN " . $variable_name_2 . $this->replacement_loop_suffix . substr( $rough_loop, $this->current_nested_loop_block[0], $this->current_nested_loop_block[1] ) . $this->replacement_loop_prefix . " END " . $variable_name_2 . $this->replacement_loop_suffix, $this->current_nested_loop_block[3], $rough_loop ); $this->current_nested_loop_block = array( ); */ $this->current_nested_loop_block = $this->generate_block_ref_data( $variable_name_2, array( " BEGIN ", " END " ), "loop", $rough_loop ); foreach ( $variable_content_2 as $variable_name_nested => $variable_content_nested ) { if ( is_numeric( $variable_name_nested ) && is_array( $variable_content_nested ) ) { $rough_nested_loop = $this->current_nested_loop_block[2]; if ( is_array( $variable_content_nested ) ) { foreach( $variable_content_nested as $variable_name_nested_2 => $variable_content_nested_2 ) { $rough_nested_loop = str_replace( $this->replacement_variable_prefix . $variable_name_2 . "." . $variable_name_nested_2 . $this->replacement_variable_suffix, $variable_content_nested_2, $rough_nested_loop ); } } $parsed_nested_loop .= @rtrim( $rough_nested_loop ); $rough_nested_loop = ""; } $this->current_nested_loop_block[3] = $parsed_nested_loop; $rough_loop = str_replace( $this->replacement_loop_prefix . " BEGIN " . $variable_name_2 . $this->replacement_loop_suffix . substr( $rough_loop, $this->current_nested_loop_block[0], $this->current_nested_loop_block[1] ) . $this->replacement_loop_prefix . " END " . $variable_name_2 . $this->replacement_loop_suffix, $this->current_nested_loop_block[3], $rough_loop ); $this->current_nested_loop_block = array( ); } // End Nested Looping.... } } } } $parsed_loop .= rtrim( $rough_loop ); } $this->current_loop_block[3] = $parsed_loop; $this->current_template_html = str_replace( $this->replacement_loop_prefix . " BEGIN " . $loop . $this->replacement_loop_suffix . substr( $this->current_template_html, $this->current_loop_block[0], $this->current_loop_block[1] ) . $this->replacement_loop_prefix . " END " . $loop . $this->replacement_loop_suffix, $this->current_loop_block[3], $this->current_template_html ); $this->current_loop_block = array( ); } } ?> Now its outputting: General new.gif General Chat 1 0 Tutorials new.gif General Chat 1 0 new.gif PHP Tutorials 1 0
-
Here is the looping function: <?php function loop_replace( $loop, $vars = array( ), $error_line, $error_file ) { if ( $this->has_error == true ) { return; } else if ( $this->has_error == false ) { $this->current_loop_block = $this->generate_block_ref_data( $loop, array( " BEGIN ", " END " ), "loop" ); foreach ( $vars as $variable_name => $variable_content ) { if ( is_numeric( $variable_name ) && is_array( $variable_content ) ) { $rough_loop = $this->current_loop_block[2]; if ( is_array( $variable_content ) ) { foreach( $variable_content as $variable_name_2 => $variable_content_2 ) { if ( !is_array( $variable_content_2 ) ) { /** Associative Array Loops array( "title" => "Board Name" ) **/ $rough_loop = str_replace( $this->replacement_variable_prefix . $loop . "." . $variable_name_2 . $this->replacement_variable_suffix, $variable_content_2, $rough_loop ); } else if ( is_array( $variable_content_2 ) ) { /** Nested Array Loops array( "title" => "Name", "nested_loop" => array( "title" => "Sub Name" ) ) **/ $this->current_nested_loop_block = $this->generate_block_ref_data( $variable_name_2, array( " BEGIN ", " END " ), "loop", $rough_loop ); foreach ( $variable_content_2 as $variable_name_nested => $variable_content_nested ) { $rough_nested_loop = $this->current_nested_loop_block[2]; foreach ( $variable_content_nested as $variable_name_nested_2 => $variable_content_nested_2 ) { $rough_nested_loop = str_replace( $this->replacement_variable_prefix . $variable_name_2 . "." . $variable_name_nested_2 . $this->replacement_variable_suffix, $variable_content_nested_2, $rough_nested_loop ); } $parsed_nested_loop .= rtrim( $rough_nested_loop ); } $this->current_nested_loop_block[3] = $parsed_nested_loop; $rough_loop = str_replace( $this->replacement_loop_prefix . " BEGIN " . $variable_name_2 . $this->replacement_loop_suffix . substr( $rough_loop, $this->current_nested_loop_block[0], $this->current_nested_loop_block[1] ) . $this->replacement_loop_prefix . " END " . $variable_name_2 . $this->replacement_loop_suffix, $this->current_nested_loop_block[3], $rough_loop ); $this->current_nested_loop_block = array( ); } } } } $parsed_loop .= rtrim( $rough_loop ); } $this->current_loop_block[3] = $parsed_loop; $this->current_template_html = str_replace( $this->replacement_loop_prefix . " BEGIN " . $loop . $this->replacement_loop_suffix . substr( $this->current_template_html, $this->current_loop_block[0], $this->current_loop_block[1] ) . $this->replacement_loop_prefix . " END " . $loop . $this->replacement_loop_suffix, $this->current_loop_block[3], $this->current_template_html ); $this->current_loop_block = array( ); } } ?> And here is the generate_block_ref_data function: <?php function generate_block_ref_data( $name, $tag, $type, $content = "" ) { $tag_start = ( $type == "loop" ) ? $this->replacement_loop_prefix . $tag[0] . $name . $this->replacement_loop_suffix : $this->replacement_variable_prefix . $tag[0] . $name . $this->replacement_variable_suffix; $tag_end = ( $type == "loop" ) ? $this->replacement_loop_prefix . $tag[1] . $name . $this->replacement_loop_suffix : $this->replacement_variable_prefix . $tag[1] . $name . $this->replacement_variable_suffix; $tag_start_pos = ( $content != null ) ? strpos( $content, $tag_start ) + strlen( $tag_start ) : strpos( $this->current_template_html, $tag_start ) + strlen( $tag_start ); $tag_end_pos = ( $content != null ) ? strpos( $content, $tag_end ) : strpos( $this->current_template_html, $tag_end ); $tag_length = $tag_end_pos - $tag_start_pos; return array( 0 => $tag_start_pos, 1 => $tag_length, 2 => ( $content != null ) ? substr( $content, $tag_start_pos, $tag_length ) : substr( $this->current_template_html, $tag_start_pos, $tag_length ), 3 => "" ); } ?>
-
Right so ive been developing a template engine for awhile now and its turned into one massive class and ive hit a snag on it. This snippet of code is supposed to compile a nested loop block, its working but theres a small snag... Its supposed to output: General new.gif General Chat 1 0 new.gif Introductions 1 0 Tutorials new.gif PHP Tutorials 1 0 But insted it is outputting: General new.gif General Chat 1 0 new.gif Introductions 1 0 Tutorials new.gif General Chat 1 0 new.gif Introductions 1 0 new.gif PHP Tutorials 1 0 Its running off a multi-dim array that currently outputs to: Array ( [1] => Array ( [icon] => new.gif [title] => General Chat ) [2] => Array ( [icon] => new.gif [title] => Introductions ) ) Array ( [1] => Array ( [icon] => new.gif [title] => PHP Tutorials ) ) As you probably noticed it looks all correct so im guessing it is a problem within the code itself and here is a snippet of it: $this->current_nested_loop_block = $this->generate_block_ref_data( $variable_name_2, array( " BEGIN ", " END " ), "loop", $rough_loop ); foreach ( $variable_content_2 as $variable_name_nested => $variable_content_nested ) { $rough_nested_loop = $this->current_nested_loop_block[2]; foreach ( $variable_content_nested as $variable_name_nested_2 => $variable_content_nested_2 ) { $rough_nested_loop = str_replace( $this->replacement_variable_prefix . $variable_name_2 . "." . $variable_name_nested_2 . $this->replacement_variable_suffix, $variable_content_nested_2, $rough_nested_loop ); } $parsed_nested_loop .= rtrim( $rough_nested_loop ); } $this->current_nested_loop_block[3] = $parsed_nested_loop; $rough_loop = str_replace( $this->replacement_loop_prefix . " BEGIN " . $variable_name_2 . $this->replacement_loop_suffix . substr( $rough_loop, $this->current_nested_loop_block[0], $this->current_nested_loop_block[1] ) . $this->replacement_loop_prefix . " END " . $variable_name_2 . $this->replacement_loop_suffix, $this->current_nested_loop_block[3], $rough_loop ); $this->current_nested_loop_block = array( ); Basically it first captures the cat_row looping tags: <!-- BEGIN cat_row --> and <!-- END cat_row --> then writes the contents of whats between the tags to a variable named current_nested_loop_block, then it is supposed to loop each row array ( [1] => Array ) etc, then its supposed to loop through each tag ( [icon] and [title] ) etc, and replace each {cat_row.tag} with the appropriate data. So for each of the rows it searches for: <!-- BEGIN cat_row --> <tr> <td><img src="{img_base_dir}icon_{cat_row.icon}" alt="{cat_row.icon}" /></td> <td>{cat_row.title}</td> <td>{cat_row.topic_count}</td> <td>{cat_row.reply_count}</td> </tr> <!-- END cat_row --> And replaces it with the correct data and its supposed to do that for each of the rows. Sooo anyone see the problem?!
-
w00t after some time ive gotten it to work [!--PHP-Head--][div class=\'phptop\']PHP[/div][div class=\'phpmain\'][!--PHP-EHead--] [span style=\"color:#0000BB\"]<?php [/span][span style=\"color:#007700\"]include([/span][span style=\"color:#DD0000\"]\'dbconnect.php\'[/span][span style=\"color:#007700\"]); [/span][span style=\"color:#0000BB\"]?> [/span]<html> <head> <title>Banning System!</title> <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"> </head> <body> <form name=\"register\" method=\"post\" action=\"[span style=\"color:#0000BB\"]<?php $php_self ?>[/span]\"> <table width=\"50%\" border=\"0\" cellspacing=\"1\" cellpadding=\"2\"> <tr> <td>Ip Address:</td> <td><input name=\"ip\" type=\"text\" id=\"ip\"></td> </tr> <tr> <td>Date:<br> </td> <td><input name=\"date\" type=\"text\" id=\"date\"></td> </tr> <tr> <td>Reason:</td> <td><input name=\"reason\" type=\"text\" id=\"reason\" size=\"38\"></td> </tr> <tr> <td> </td> <td><input name=\"submit\" type=\"submit\" id=\"submit\" value=\"Submit\"></td> </tr> </table> </form> [span style=\"color:#0000BB\"]<?php [/span][span style=\"color:#007700\"]if(isset([/span][span style=\"color:#0000BB\"]$_POST[/span][span style=\"color:#007700\"][[/span][span style=\"color:#DD0000\"]\'submit\'[/span][span style=\"color:#007700\"]])) { [/span][span style=\"color:#0000BB\"]$ip [/span][span style=\"color:#007700\"]= ([/span][span style=\"color:#0000BB\"]$_POST[/span][span style=\"color:#007700\"][[/span][span style=\"color:#DD0000\"]\'ip\'[/span][span style=\"color:#007700\"]]); [/span][span style=\"color:#0000BB\"]$date [/span][span style=\"color:#007700\"]= ([/span][span style=\"color:#0000BB\"]$_POST[/span][span style=\"color:#007700\"][[/span][span style=\"color:#DD0000\"]\'date\'[/span][span style=\"color:#007700\"]]); [/span][span style=\"color:#0000BB\"]$reason [/span][span style=\"color:#007700\"]= ([/span][span style=\"color:#0000BB\"]$_POST[/span][span style=\"color:#007700\"][[/span][span style=\"color:#DD0000\"]\'reason\'[/span][span style=\"color:#007700\"]]); [/span][span style=\"color:#0000BB\"]$check [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]mysql_query[/span][span style=\"color:#007700\"]([/span][span style=\"color:#DD0000\"]\"SELECT * FROM banned WHERE ip=\'$ip\'\"[/span][span style=\"color:#007700\"]); if([/span][span style=\"color:#0000BB\"]mysql_num_rows[/span][span style=\"color:#007700\"]([/span][span style=\"color:#0000BB\"]$check[/span][span style=\"color:#007700\"])==[/span][span style=\"color:#0000BB\"]0[/span][span style=\"color:#007700\"]) { echo [/span][span style=\"color:#0000BB\"]mysql_error[/span][span style=\"color:#007700\"](); [/span][span style=\"color:#0000BB\"]mysql_query[/span][span style=\"color:#007700\"]([/span][span style=\"color:#DD0000\"]\"INSERT INTO banned VALUES (\'$ip\',\'$date\',\'$reason\')\"[/span][span style=\"color:#007700\"]); echo [/span][span style=\"color:#DD0000\"]\'<p>Ip Address Banned!</p>\'[/span][span style=\"color:#007700\"]; } else { echo [/span][span style=\"color:#DD0000\"]\"Sorry, but the ip address, $ip has already been banned.\"[/span][span style=\"color:#007700\"]; } } [/span][span style=\"color:#0000BB\"]?> [/span]</body> </html> [/span][!--PHP-Foot--][/div][!--PHP-EFoot--]
-
here [!--PHP-Head--][div class=\'phptop\']PHP[/div][div class=\'phpmain\'][!--PHP-EHead--] [span style=\"color:#0000BB\"]<?php extract [/span][span style=\"color:#007700\"]( [/span][span style=\"color:#0000BB\"]$_POST [/span][span style=\"color:#007700\"]); [/span][span style=\"color:#0000BB\"]mysql_connect [/span][span style=\"color:#007700\"]( [/span][span style=\"color:#DD0000\"]\'blah\'[/span][span style=\"color:#007700\"], [/span][span style=\"color:#DD0000\"]\'blah\'[/span][span style=\"color:#007700\"], [/span][span style=\"color:#DD0000\"]\'blah\' [/span][span style=\"color:#007700\"]); [/span][span style=\"color:#0000BB\"]mysql_select_db[/span][span style=\"color:#007700\"]( [/span][span style=\"color:#DD0000\"]\'blah\'[/span][span style=\"color:#007700\"]); [/span][span style=\"color:#0000BB\"]$resultsearch [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]mysql_query[/span][span style=\"color:#007700\"]([/span][span style=\"color:#DD0000\"]\"SELECT ip FROM banned WHERE ip=\'$ip\'\"[/span][span style=\"color:#007700\"]); if([/span][span style=\"color:#0000BB\"]mysql_num_rows[/span][span style=\"color:#007700\"]([/span][span style=\"color:#0000BB\"]$resultsearch[/span][span style=\"color:#007700\"]) == [/span][span style=\"color:#0000BB\"]1[/span][span style=\"color:#007700\"]) { { echo [/span][span style=\"color:#DD0000\"]\"<center><b>IP Address Allready Banned</b></center>\" [/span][span style=\"color:#007700\"]} else { [/span][span style=\"color:#0000BB\"]$result [/span][span style=\"color:#007700\"]= [/span][span style=\"color:#0000BB\"]mysql_query [/span][span style=\"color:#007700\"]( [/span][span style=\"color:#DD0000\"]\"INSERT INTO banned VALUES ( \'$ip\', \'$date\',\'$reason\' )\" [/span][span style=\"color:#007700\"]); if([/span][span style=\"color:#0000BB\"]$result[/span][span style=\"color:#007700\"]!=[/span][span style=\"color:#0000BB\"]FALSE[/span][span style=\"color:#007700\"]) { echo [/span][span style=\"color:#DD0000\"]\"<center><b>IP Address Banned!</b></center>\" [/span][span style=\"color:#007700\"]} [/span][span style=\"color:#0000BB\"]mysql_close [/span][span style=\"color:#007700\"](); [/span][span style=\"color:#0000BB\"]?>[/span] [/span][!--PHP-Foot--][/div][!--PHP-EFoot--] i change it abit..
-
ok ive made an "attempt" to make this work and i keep drawing a blank. [!--PHP-Head--][div class=\'phptop\']PHP[/div][div class=\'phpmain\'][!--PHP-EHead--] [span style=\"color:#0000BB\"]<?php extract [/span][span style=\"color:#007700\"]( [/span][span style=\"color:#0000BB\"]$_POST [/span][span style=\"color:#007700\"]); [/span][span style=\"color:#0000BB\"]mysql_connect [/span][span style=\"color:#007700\"]( [/span][span style=\"color:#DD0000\"]\'blah\'[/span][span style=\"color:#007700\"], [/span][span style=\"color:#DD0000\"]\'blah\'[/span][span style=\"color:#007700\"], [/span][span style=\"color:#DD0000\"]\'blah\' [/span][span style=\"color:#007700\"]); [/span][span style=\"color:#0000BB\"]mysql_select_db[/span][span style=\"color:#007700\"]( [/span][span style=\"color:#DD0000\"]\'blah\'[/span][span style=\"color:#007700\"]); [/span][span style=\"color:#0000BB\"]$ip[/span][span style=\"color:#007700\"]=(isset([/span][span style=\"color:#0000BB\"]$_POST[/span][span style=\"color:#007700\"][[/span][span style=\"color:#DD0000\"]\'ip\'[/span][span style=\"color:#007700\"]]))? [/span][span style=\"color:#0000BB\"]$_POST[/span][span style=\"color:#007700\"][[/span][span style=\"color:#DD0000\"]\'ip\'[/span][span style=\"color:#007700\"]]: [/span][span style=\"color:#DD0000\"]\'\'[/span][span style=\"color:#007700\"]; [/span][span style=\"color:#0000BB\"]$date[/span][span style=\"color:#007700\"]=(isset([/span][span style=\"color:#0000BB\"]$_POST[/span][span style=\"color:#007700\"][[/span][span style=\"color:#DD0000\"]\'date\'[/span][span style=\"color:#007700\"]]))? [/span][span style=\"color:#0000BB\"]$_POST[/span][span style=\"color:#007700\"][[/span][span style=\"color:#DD0000\"]\'date\'[/span][span style=\"color:#007700\"]]: [/span][span style=\"color:#DD0000\"]\'\'[/span][span style=\"color:#007700\"]; [/span][span style=\"color:#0000BB\"]$reason[/span][span style=\"color:#007700\"]=(isset([/span][span style=\"color:#0000BB\"]$_POST[/span][span style=\"color:#007700\"][[/span][span style=\"color:#DD0000\"]\'reason\'[/span][span style=\"color:#007700\"]]))? [/span][span style=\"color:#0000BB\"]$_POST[/span][span style=\"color:#007700\"][[/span][span style=\"color:#DD0000\"]\'reason\'[/span][span style=\"color:#007700\"]]: [/span][span style=\"color:#DD0000\"]\'\'[/span][span style=\"color:#007700\"]; if (empty([/span][span style=\"color:#0000BB\"]$ip[/span][span style=\"color:#007700\"]) || empty([/span][span style=\"color:#0000BB\"]$date[/span][span style=\"color:#007700\"]) || empty([/span][span style=\"color:#0000BB\"]$time[/span][span style=\"color:#007700\"])){ die([/span][span style=\"color:#DD0000\"]\'Please, fill all fields\'[/span][span style=\"color:#007700\"]); } if ([/span][span style=\"color:#0000BB\"]mysql_num_rows[/span][span style=\"color:#007700\"]([/span][span style=\"color:#0000BB\"]$result[/span][span style=\"color:#007700\"])>[/span][span style=\"color:#0000BB\"]0[/span][span style=\"color:#007700\"]) { die([/span][span style=\"color:#DD0000\"]\'This IP Address Is Allready Banned!\'[/span][span style=\"color:#007700\"]); } else { [/span][span style=\"color:#0000BB\"]mysql_query [/span][span style=\"color:#007700\"]( [/span][span style=\"color:#DD0000\"]\"INSERT INTO banned VALUES ( \'$ip\', \'$date\',\'$reason\' )\" [/span][span style=\"color:#007700\"]); [/span][span style=\"color:#0000BB\"]mysql_close [/span][span style=\"color:#007700\"](); echo [/span][span style=\"color:#DD0000\"]\"<center><b>IP Address Added</b></center>\" [/span][span style=\"color:#007700\"]} [/span][span style=\"color:#0000BB\"]?> [/span] [/span][!--PHP-Foot--][/div][!--PHP-EFoot--] what am i doing wrong? can anyone help fix up this code????
-
Hey, i need some help with this I need my script to be able to check to see if an ip exists before it inserts it into the mysql database any ideas? heres my script. [!--PHP-Head--][div class=\'phptop\']PHP[/div][div class=\'phpmain\'][!--PHP-EHead--] [span style=\"color:#0000BB\"]<?php extract [/span][span style=\"color:#007700\"]( [/span][span style=\"color:#0000BB\"]$_POST [/span][span style=\"color:#007700\"]); [/span][span style=\"color:#0000BB\"]mysql_connect [/span][span style=\"color:#007700\"]( [/span][span style=\"color:#DD0000\"]\'host\'[/span][span style=\"color:#007700\"], [/span][span style=\"color:#DD0000\"]\'user\'[/span][span style=\"color:#007700\"], [/span][span style=\"color:#DD0000\"]\'password\' [/span][span style=\"color:#007700\"]); [/span][span style=\"color:#0000BB\"]mysql_select_db[/span][span style=\"color:#007700\"]( [/span][span style=\"color:#DD0000\"]\'database\'[/span][span style=\"color:#007700\"]); [/span][span style=\"color:#0000BB\"]mysql_query [/span][span style=\"color:#007700\"]( [/span][span style=\"color:#DD0000\"]\"INSERT INTO banned VALUES ( \'$ip\', \'$date\',\'$reason\' )\" [/span][span style=\"color:#007700\"]); [/span][span style=\"color:#0000BB\"]mysql_close [/span][span style=\"color:#007700\"](); echo [/span][span style=\"color:#DD0000\"]\"IP Added\" [/span][span style=\"color:#0000BB\"]?>[/span] [/span][!--PHP-Foot--][/div][!--PHP-EFoot--] if the ip had allready been added it would say: "IP Address has allready been banned." but if ip has not been enterd befor the script would insert the ip to the database and say: "IP Added." >.< i need some help!!!