sasa
Staff Alumni-
Posts
2,804 -
Joined
-
Last visited
-
Days Won
1
Everything posted by sasa
-
move lines $title=$info['title']; $genre=$info['genre']; //etc after line $info=mysql_fetch_array($result, MYSQL_ASSOC) or die (mysql_error(). " with query : ". $query."<br>"); and change form echo $_POST['title']?></textarea></td></tr> <tr><td align="right">Genre:</td><td><textarea rows="1" cols="40" name="character_name"><?php echo $_POST['genre']?></textarea></td></tr> to echo $title;?></textarea></td></tr> <tr><td align="right">Genre:</td><td><textarea rows="1" cols="40" name="character_name"><?php echo $genre;?></textarea></td></tr>
-
in start of your script you have variable $table_id (where is it setup?) general idea is that first update your database and after that show results this part of code do nothing $query_table="SELECT table_id FROM abc_tables WHERE table_id=$table_id"; $result_table=mysql_query($query_table); while ($row_table = mysql_fetch_assoc($result_table)){ $table_id = $row_table['table_id']; } this part is run only once $query_ads_rec_dates="SELECT ad_copy_rec FROM whiteboard_dates WHERE rest_id=$table_id"; $result_ads_rec_dates=mysql_query($query_ads_rec_dates); while ($row_ads_rec_dates = mysql_fetch_assoc($result_ads_rec_dates)){ $ad_copy_rec_old = $row_ads_rec_dates['ad_copy_rec']; } i think it must be executed for each row in your html table in form you must pass value of primary key of table whiteboard_dates and just updated this table (not insert)
-
can you post structure of your table
-
try <input type="Checkbox" name="featured" value="1" <?if($prod['featured']==1){echo "checked"; if(count($prod) < 2) echo ' disabled ';}?>><font class=input>Featured<br>
-
if you have act=Socom+Fire+Team+Bravo+2 in url and $act = $_GET['act']; in variable $act you have 'Socom Fire Team Bravo 2' what is wrong
-
try http://ladders.elitebattles.com/standings.php?act=Socom+Fire+Team+Bravo+2
-
[SOLVED] Set Variable name use Field name from table
sasa replied to jvrothjr's topic in PHP Coding Help
try if ($DB == "Departments") { $querystring = "Select * from ".$DB; $result=mysql_query($querystring); while(($field = mysql_fetch_field($result))) { $$field->name = $data22[$field->name]; } } -
again try <?php //conect to db $limit = 2; $fields = array("laptopname", "statusID"); if (isset($_GET['search']) and $_GET['search'] == 'Search'){ $page = trim(addslashes(strip_tags($_GET['page']))); if($page == "" OR !is_numeric($page)) $page = 1; $find = strtoupper($_GET['finda']); $find = strip_tags($_GET['finda']); $find = trim ($_GET['finda']); $find = mysql_real_escape_string($find); if (in_array($_GET['field'], $fields)) $field = $_GET['field']; else die('wrong field name'); if ($find) $where = ' WHERE '.$field." LIKE '%".$find."%'"; else $where = ' WHERE 1'; $lm = ' LIMIT '.(($page - 1) * $limit).' '.$limit; $qve_tot_row = "SELECT count(*) FROM teachersname".$where; $qve_data = "SELECT count(*) FROM teachersname".$where.$lm; $res = mysql_query($qve_tot_row); $tot_row = mysql_result($res, 0, 0); $tot_pages = ceil($tot_row / $limit); $res =mysql_query($qve_data); if (mysql_num_rows($res) > 0) { while($result = mysql_fetch_array($res)) { echo"<table width=\"200\" border=\"0\" class=\"border_bottom\"> \n"; echo "<tr> \n"; echo "<td> </td> \n"; echo "</td> \n"; echo "</tr> \n"; echo "<tr> \n"; echo "<td>"; echo "<strong>Client Name</strong>"; echo "</td>"; echo "<td width=\"75\" style =\"text-align: left\""; ?> <em><a href="search_client_details.php?recordID=<?php echo $result['Client']; ?>"><?php echo $result['Client']; ?> </a></em> <?php echo " </td> \n"; echo "</tr> \n"; echo "<tr> \n"; echo "<td>"; echo "<strong>Department Code</strong>"; echo "</td>"; echo "<td>"; echo "<em>"; echo $result['DepartmentCode']; echo "</em>"; echo "</td>"; echo "</tr> \n"; echo "<tr> \n"; echo "<td> </td> \n"; echo "</td> \n"; echo "</tr> \n"; echo "</table> \n"; echo"<br>"; } } else echo 'no result'; if ($page > 1) echo '<a href="?search=Search&finda='.$find.'&field='.$field.'&page='.($page - 1).'"> PREV </a>'; else echo ' PREV '; for ($i =1; $i <= $tot_pages; $i++) { if ($i != $page) echo '<a href="?search=Search&finda='.$find.'&field='.$field.'&page='.$i.'"> '.$i.' </a>'; else echo " $i "; } if ($page < $tot_pages) echo '<a href="?search=Search&finda='.$find.'&field='.$field.'&page='.($page + 1).'"> NEXT </a>'; else echo ' NEXT '; } else die('error'); ?>
-
you newer use $category_id after it is steup what you tray to do?
-
try <?php function bad_word($string, $array_of_bad_words, $bad_words_find = array()) { $out = true; $bad_words_find = array(); $bad_words_find = array_intersect(explode(' ',$string),$array_of_bad_words); if (count($bad_words_find)) return true; else return false; } $x="you soon see redarrow c c"; $word=array("a","see","c"); if (bad_word($x,$word)) echo "You entred a bad word!"; else echo "Word is good!"; // or echo '<hr />'; $a = array(); bad_word($x, $word, &$a); echo 'Bad words is: ',implode(', ', $a); ?>
-
on 2nd page you don't have $_GET['submit'] change paging.php to $page = $pageNum + 1; $next = " <a href=\"$self?page=$page&submit=Search&search=$search\">[Next]</a> "; $last = " <a href=\"$self?page=$maxPage&submit=Search&search=$search\">[Last Page]</a> ";
-
change order of your script 1st update database after that echo data table and form try <? include('include/user_check.php'); include('include/db_con.php'); error_reporting(0); ?> <html> <head> <title>Whiteboard</title> <script language="javascript"> function openNewWindow(url) { window.open(url,'newPage','scrollbars=no,resizable=no,width=400,height=250'); } </script> </head> <body bgcolor="white"> <script type='text/JavaScript' src='scw.js'></script> <font face="Verdana, Arial, Helvetica, sans-serif"> <div align="center"> <table width="600" border="0" cellspacing="2" cellpadding="1" bgcolor="white"> <tr> <td colspan="10" width="1343"> <div id="popup"></div> <center>Whiteboard for<br> <?php $submit = $_POST['submit']; $table_id =$_POST['table_id']; $ad_copy_rec_new = $_POST['ad_copy_rec_new']; if ($submit){ $sql = "SELET ad_copy_rec FROM whiteboard_dates WHERE rest_id 0 '$table_id'"; $result = mysql_query($sql); $ad_copy_rec_old = mysql_result($result,0,0); if($ad_copy_rec_old == ""){ $sql = "INSERT INTO whiteboard_dates (rest_id, ad_copy_rec) VALUES ('$table_id', '$ad_copy_rec_new')"; $result = mysql_query($sql); } else{ $new = $ad_copy_rec_old.",".$ad_copy_rec_new; $sql = "UPDATE whiteboard_dates SET ad_copy_rec = '$new' WHERE rest_id='$table_id'"; $result = mysql_query($sql); } } $query="SELECT rest_name FROM abc_tables WHERE table_id=$table_id"; $result=mysql_query($query); while ($row = mysql_fetch_assoc($result)){ $rest_name = $row['rest_name']; } echo"$rest_name"; ?><br> <img src="thin_horiz_line.png" width="250" height="1"></center> </td> </tr> <tr> <td align="center" valign="bottom" width="60"><font size="-2">Advertiser</font></td> <td align="center" valign="bottom" width="20"><font size="-2">Ad Size</font></td> <td align="center" valign="bottom" width="75"><font size="-2">Contract Rec</font></td> <td align="center" valign="bottom" width="35"><font size="-2">Ad Copy Rec</font></td> <td align="center" valign="bottom" width="30"><font size="-2">Pict</font></td> <td align="center" valign="bottom" width="30"><font size="-2">Copy Sent Out</font></td> <td align="center" valign="bottom" width="60"><font size="-2">Approved</font></td> </tr> <tr> <td colspan="10" width="1343"> <div align="center"> <img src="thin_horiz_line.png"></div> </td> </tr> <?php $query_table="SELECT table_id FROM abc_tables WHERE table_id=$table_id"; $result_table=mysql_query($query_table); while ($row_table = mysql_fetch_assoc($result_table)){ $table_id = $row_table['table_id']; } $query_ads_rec_dates="SELECT ad_copy_rec FROM whiteboard_dates WHERE rest_id=$table_id"; $result_ads_rec_dates=mysql_query($query_ads_rec_dates); while ($row_ads_rec_dates = mysql_fetch_assoc($result_ads_rec_dates)){ $ad_copy_rec_old = $row_ads_rec_dates['ad_copy_rec']; } $query_ads="SELECT id, company, size, date_ordered, date_approved FROM ad_order WHERE cust_id=$table_id"; $result_ads=mysql_query($query_ads); while ($row_ads = mysql_fetch_assoc($result_ads)){ $id = $row_ads['id']; $company = $row_ads['company']; $ad_size = $row_ads['size']; $contract_rec = $row_ads['date_ordered']; $approve = $row_ads['date_approved']; $approved_date = date('m/d/y',$approve); $query_ads_dates="SELECT ad_id, action, time FROM job_log WHERE ad_id=$id"; $result_ads_dates=mysql_query($query_ads_dates); while ($row_ads_dates = mysql_fetch_assoc($result_ads_dates)){ $ad_id = $row_ads_dates['ad_id']; $action = $row_ads_dates['action']; $upload = $row_ads_dates['time']; $upload_date = date('m/d/y',$upload); } ?> <tr> <td colspan="10" width="1343"><div align="center"><IMG SRC="thin_horiz_line.png"></div></TD> </TR> <tr> <td align="center" valign="top" width="60"><font size="-2"><? echo "$company"; ?></font></td> <td align="center" valign="top" width="60"><font size="-2"><? echo "$ad_size"; ?></font></td> <td align="center" valign="top" width="60"><font size="-2"><? echo "$contract_rec"; ?></font></td> <td align="center" valign="top" width="60"><font size="-2"><? echo "$ad_copy_rec_old"; ?></p> <form method="post" action="" enctype="multipart/form-data" name="FormName"> <input type="hidden" name="table_id" value=" <?php echo $table_id; ?> "> <input type="text" class="formTextbox" name="ad_copy_rec_new" size="24"/> <input type="submit" class="formTextbox" name="submit" value="Submit Ad Copy Rec Date"> </form></font></td> <?php /* if($submit && $ad_copy_rec_old == ""){ $sql = "INSERT INTO whiteboard_dates (rest_id, ad_copy_rec) VALUES ('$table_id', '$ad_copy_rec_new')"; $result = mysql_query($sql); } else{ $new = $ad_copy_rec_old.",".$ad_copy_rec_new; $sql = "UPDATE whiteboard_dates SET ad_copy_rec = '$new' WHERE rest_id='$table_id'"; $result = mysql_query($sql); } */ ?> <td align="center" valign="top" width="60"><font size="-2"><? echo ""; ?></font></td> <td align="center" width="60"><font size="-2"><?php if ($action == "999" || $action == "208"){ echo "$upload_date<br>"; } else{ echo ""; } ?></font></td> <td align="center" width="60"><font size="-2"><?php echo "$approved_date<br>"; ?></font></td> <?php } ?> <TR> <td colspan="10" width="1343"><div align="center"><IMG SRC="thin_horiz_line.png"></div></TD> </TR> </TABLE> </body> </html>
-
i try <?php $MyArray['My Key.Thing'] = 37; print_r($MyArray); ?> output X-Powered-By: PHP/4.4.4 Content-type: text/html Array ( [My Key.Thing] => 37 ) where is problem?
-
can we see paging.php
-
try if (preg_match("/[^a-zA-Z0-9 _]+/", $_POST['key']) || strlen($_POST['key']) < 2) { $_POST['key'] = "sfasd3254djs45dkjd"; } or if (!preg_match("/^[a-zA-Z0-9 _]+$/", $_POST['key']) || strlen($_POST['key']) < 2) { $_POST['key'] = "sfasd3254djs45dkjd"; } they are same
-
try <?php //conect to db $limit = 2; $fields = array("laptopname", "statusID"); if (isset($_GET['search']) and $_GET['search'] == 'Search'){ $page = trim(addslashes(strip_tags($_GET['page']))); if($page == "" OR !is_numeric($page)) $page = 1; $find = strtoupper($_GET['finda']); $find = strip_tags($_GET['finda']); $find = trim ($_GET['finda']); $find = mysql_real_escape_string($find); if (in_array($_GET['field'], $fields)) $field = $_GET['field']; else die('wrong field name'); if ($find) $where = ' WHERE '.$field." LIKE '%".$find."%'"; else $where = ' WHERE 1'; $lm = ' LIMIT '.(($page - 1) * $limit).' '.$limit; $qve_tot_row = "SELECT count(*) FROM teachersname".$where; $qve_data = "SELECT count(*) FROM teachersname".$where.$lm; $res = mysql_query($qve_tot_row); $tot_row = mysql_result($res, 0, 0); $tot_pages = ceil($tot_row / $limit); $res =mysql_query($qve_data); if (mysql_num_rows($res) > 0) { while($result = mysql_fetch_array($res)) { echo"<table width=\"200\" border=\"0\" class=\"border_bottom\"> \n"; echo "<tr> \n"; echo "<td> </td> \n"; echo "</td> \n"; echo "</tr> \n"; echo "<tr> \n"; echo "<td>"; echo "<strong>Client Name</strong>"; echo "</td>"; echo "<td width=\"75\" style =\"text-align: left\""; ?> <em><a href="search_client_details.php?recordID=<?php echo $result['Client']; ?>"><?php echo $result['Client']; ?> </a></em> <?php echo " </td> \n"; echo "</tr> \n"; echo "<tr> \n"; echo "<td>"; echo "<strong>Department Code</strong>"; echo "</td>"; echo "<td>"; echo "<em>"; echo $result['DepartmentCode']; echo "</em>"; echo "</td>"; echo "</tr> \n"; echo "<tr> \n"; echo "<td> </td> \n"; echo "</td> \n"; echo "</tr> \n"; echo "</table> \n"; echo"<br>"; } } else echo 'no result'; if ($page > 1) echo '<a href="?finda='.$find.'&field='.$field.'&page='.($page - 1).'"> PREV </a>'; else echo ' PREV '; for ($i =1; $i <= $tot_pages; $i++) { if ($i != $page) echo '<a href="?finda='.$find.'&field='.$field.'&page='.$i.'"> '.$i.' </a>'; else echo " $i "; } if ($page < $tot_pages) echo '<a href="?finda='.$find.'&field='.$field.'&page='.($page + 1).'"> NEXT </a>'; else echo ' NEXT '; } else die('error'); ?>
-
1st keywords (keywords[0]) is empty string ('') start for 2nd keyword (indeks = 1) => for($i = 1; loop all keywords => $i < count($keywords); i wont 4 in row increment 4 => $i += 4) star row => $cache .= '<tr>'; i wont in this row keywords with index $i + 0, $i +1, $i +2 and $i +3 change $j for 0 to 3 => for ($j = 0; $j < 4; $j++) check if this keyword exist if ($i + $j < count($keywords)) if exist echo ceill with keyword in it => $cache.='<td> '.$keywords[$i + $j].' </td>'."\n"; if not echo empty ceill => } else $cache .= '<td> </td>'."\n" end of row => $cache .= '</tr>'; when i loop all keywords end table => '</table>'
-
try <?php $field ='<sasa>'; if (preg_match('/["<>]/', $field)) {echo 'yes';} else echo 'no'; ?>
-
try <?php function my_in_arr($p) { $a = Array( 1 => Array('level' => 1, 'name' => 'index.php', 'path' => '/path/cms/'), 2 => Array('level' => 2, 'name' => 'functions.php', 'path' => '/path/cms/functions/'), 3 => Array('level' => 3, 'name' => 'login.php', 'path' => '/path/cms/admin/'), 4 => Array('level' => 3, 'name' => 'functions.php', 'path' => '/path/cms/admin/')); $out = false; foreach ($a as $v) if ($v['name'] == $p) $out = true; return $out; } $page = 'functions.php'; if(my_in_arr($page)) echo 'in array'; else echo 'not in array'; ?>
-
delete all old values and insert all new
-
try $sqla="UPDATE users SET points='" . ($l["points"] + 2) . "', gold='" . ($l["gold"] + 5) . "', posts='" . ($l["posts"] + 1) . "' WHERE uname='" . Decrypt_Text($UN) . "'"; i try to explain PHP convert number to string and string to number, operator + except numbers and operator . except strings old code say "UPDATE users SET points='" . $l["points"] produce something like "UPDATE users SET points='5" type strimg "UPDATE users SET points='5" + 2 convert "UPDATE users SET points='5" to number produce 0 and add 2 result is 2 (number) 2. "', gold='" . $l["gold"] => "2, gold='3" (string) "2gold='3" + 5 (1st "2gold='3" to number => 2) 2 + 5 = 7 etc
-
and what is wrong?
-
use preg_replace()