Jump to content

btherl

Staff Alumni
  • Posts

    3,893
  • Joined

  • Last visited

Everything posted by btherl

  1. Yes it will work. Well, the fetching of the result will work the same way, whether it's php or dll (or asp or aspx or php5 or php4 etc etc). What you'll get in either case is a string as the result, which you'll then need to interpret.
  2. I would like to know how since afaik an update can not be made based on a subset of the same table. Maybe it can't. I'm not an expert in mysql. Here is your example John: $result = mysqli_query($db, 'SELECT org_name,org_city,count(*) FROM content_type_resource GROUP BY org_name,org_city HAVING COUNT(*)>1'); while ($row = mysqli_fetch_object($result)) { $upd_sql = 'UPDATE content_type_resource ' . " SET org_dupe = {$row->count} " . " WHERE org_name = '" . $row->org_name . "'" . " AND org_city = '" . $row->org_city . "'"; $upd_result = mysqli_query($db, $upd_sql) or die("Error in $upd_sql"); } The code is unfortunately untested. I hope someone familiar with mysqli can help.. The idea is just to run an update using the count, name and city fetched from the outer query.
  3. Just add an update statement within your loop. Make sure you don't use the same variable name $result for the update The update will just need to specify which org_name and org_city need updating, which you have available from $row. It can be done in a single query as well, which may be useful if efficiency is important. IF you want to know how to do that, ask
  4. Curl can help you here. It will take a bit of time to get used to, but it can do what you need.
  5. 100 guests? What are they all doing? You can always get a part time job and then donate
  6. I'm not sure I understand your question, but I think you need this: if (mysql_num_rows($result) == 1) { print "It already exists!"; } else { print "It doesn't exist yet!"; } This assumes that pid is unique in your table.
  7. Yes they are slower, but double quotes also substitue backslash sequence such as "\r" and "\n". Those don't get replaced in single quotes.
  8. Try this: $res2 = mysql_query("SELECT COUNT(*) FROM $gallery_pictures WHERE aid = {$row['aid']}");
  9. Really? I've never noticed a newbie help forum. And the questions in php help are usually quite newbie. I think those guidelines need updating
  10. or $keyword=split("\n",str_replace(array("\r\n","\n\r","\r"),"\n",$input));
  11. What happens if you print out that url you are redirecting to instead of redirecting to it? Is it what it should be?
  12. if (preg_match('|^[0-9a-z]*$|i', $_REQUEST['field'])) { print "Yup that's valid"; } else { print "Nope, that ain't valid"; } The regexp matches "0 or more characters from 0-9 or a-z, ignoring case, starting at the start and ending at the end". If there's any character not in those ranges then it can't match, because it must start at the start and end at the end (which is the meaning of ^ and $).
  13. My short answer is no, it's not easy unfortunately. Integrating four products would require a reasonably experienced php programmer. As for your problem with phpauction and phpbb, try posting in the third party php scripts forum. Someone with experience with these may be able to help you. The problem may or may not be related to mysql.
  14. This is newbie help Yes they are right to worry that the upgrade may break something. Even though the language changed very little, it's likely that a changed setting in php.ini will cause random scripts to start dying (or worse, fail but not give any indication they are failing). It's possible to use both on the same webserver, but not recommended. As for parsing XML in v4, I can't give much advice about that. You can try the packages at http://pear.php.net if you're not satisfied with the parser provided in PHP.
  15. %0d is also known as "\r" or "control M", the carriage return character. $str = str_replace("\r", '', $str) should get rid of it.
  16. Try printing out urlencode($keyword[$i]) for each $i. That should show up any extra charaters that you can't see.
  17. Now with highlighting! (I haven't modified the code, apart from de-shortifying the opening php tags) <?php include_once "config.php"; include_once "left_index.php"; include_once "right_index.php"; function main() { ?> <table width="420" border="0" align="center" cellpadding="0" cellspacing="0" dwcopytype="CopyTableCell"> <tr> <td valign="top"> <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td> <?php if ( isset($_REQUEST["msg"])&&$_REQUEST['msg']<>"") { ?> <table align="center" bgcolor="#FEFCFC" border="0" cellpadding="5" > <tr> <td><font face="verdana, arial" size="1" color="#666666"> <?php print($_REQUEST['msg']); ?> </font></td> </tr> </table> <?php }//end if ?> </td> </tr> <tr> <td> </td> </tr> <tr> <td><form name="form2" method="post" action="showcategory.php"> <table width="100%" border="0" cellspacing="0" cellpadding="2"> <tr> <td width="17%"><FONT color=#000000><strong><font color="#000000" size="2" >SEARCH</font></strong></FONT></td> <td width="31%"><input type="text" name="keyword"></td> <td width="24%"><select name="cid"> <?php $cats=mysql_query("select * from sbwmd_categories where pid=0"); while($rst=mysql_fetch_array($cats)) { ?> <option value="<? echo $rst["id"]; ?>"><? echo $rst["cat_name"]; ?></option> <?php }//end while ?> </select></td> <td width="28%"><input type="submit" name="Submit2" value="Go" class="input"></td> </tr> </table> </form></td> </tr> <tr> <td> </td> </tr> <tr> <td><table width="100%" border="0" cellpadding="0" cellspacing="0" bordercolor="#000000"> <tr> <td height="25" background="images/bargb.gif"> <div align="left"><FONT color=#000000><strong> <font color="#FFFFFF" face="Tahoma, Verdana, Arial, Helvetica, sans-serif"> <font color="#000000">Software Categories </font></font></strong></FONT></div></td> </tr> <tr> <td bgcolor="#F3F3F3"><table width="100%" border="0" cellspacing="2" cellpadding="1"> <?php $cats1=mysql_query("select * from sbwmd_categories where pid=0 "); $cnt=1; while($rst=mysql_fetch_array($cats1)) { if(($cnt%2)==1) { ?> <tr> <?php } //end if?> <td width="50%" bgcolor="#FFFFFF" > <table width="100%"> <tr> <td width="55"> <img src="images/folder.gif" width="50" height="45"></td> <td> <div align="justify"><font color="#FF0000" size="3"> <strong> <a href="showcategory.php?cid=<?php echo $rst["id"]?>" class="biglink"?>" class="biglink" ><? echo $rst["cat_name"]; ?>[/url] </strong> <font color="#666666" size="1"> ( <?php /////////////////////////////////////////////// /////////////////////////////////////////////// /// GENERATE CLIST //////////////////////////////////////////// $rst1_query=mysql_query("Select * from sbwmd_categories where pid=" . $rst["id"]); $clist=$rst["id"]; while ( $rst1=mysql_fetch_array($rst1_query) ) { $clist.="," . $rst1["id"]; while ( $rst1=mysql_fetch_array($rst1_query) ) { $clist.="," . $rst1["id"]; } $rst1_query=mysql_query("Select * from sbwmd_categories where pid IN (" . $clist . ") and id not in ( ". $clist . ")") ; } /// CLIST GENERATED ///////////////////////////////////////// //echo "[" . $clist . "]"; $rst1_query=mysql_query("Select count(*) from sbwmd_softwares where approved='yes' and cid in (" . $clist . ")" ); $rst1=mysql_fetch_array($rst1_query); $items=$rst1[0] ; echo $items ; //////////////////////////////////////////// //////////////////////////////////////////// //////////////////////////////////////////// ?> resources)</font></font> </div></td> </tr> </table></td> <?php if(($cnt%2)==0) { ?> </tr> <?php } //end if?> <?php $cnt++; }//end while ?> </table> </td> </tr> </table></td> </tr> </table> <p> </p> <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" dwcopytype="CopyTableRow"> <tr> <td height="25" background="images/bargb.gif"> <div align="left"><FONT color=#000000><strong><font color="#000000" face="Tahoma, Verdana, Arial, Helvetica, sans-serif"> Featured Resources</font></strong></FONT></div></td> </tr> <tr> <td bgcolor="#f3f3f3" ><table width="100%" border="0" cellspacing="2" cellpadding="1"> <?php $featured_sites=mysql_query("select * from sbwmd_featuredads "); $cnt=0;$num=0; while($rst=mysql_fetch_array($featured_sites)) { if(($cnt%2)==1) { $num++; ?> <tr> <?php } //end if?> <td width="100%" bgcolor="#ffffff"> <div align="justify"> <a class="insidelink" href="<?php echo $rst["url"]; ?>" target="_blank" ?>" target="_blank"><? echo $rst["name_url"]; ?>[/url] <font color="#666666"> <?php echo str_replace("\n"," ",$rst["fd_desc"]); ?></font></div><BR></td> <?php if(($cnt%2)==0) { ?> </tr> <?php } //end if?> <?php $cnt++; }//end while ?> </table></td> </tr> </table> </td> </tr> </table> <?php }// end main ?> <?php include_once "template.php"; ?>
  18. Hi, You can't do it in one statement. Instead, do a select to see if it exists, followed by an insert. If you want to be safe against concurrent inserts, then do it like this: BEGIN SELECT ... if doesn't exist, INSERT COMMIT PS: This is the mysql forum. Postgresql forum is over here: http://www.phpfreaks.com/forums/index.php/board,37.0.html
  19. Mysql: "Although this MySQL extension is compatible with MySQL 4.1.0 and greater, it doesn't support the extra functionality that these versions provide. For that, use the MySQLi extension." Mysqli: "The mysqli extension allows you to access the functionality provided by MySQL 4.1 and above."
  20. There's a cute trick I've used to work around php's lack of goto: while (an if condition) { blah blah if (some condition) { break; # goto end } blah if (some other condition) { break; # goto end } blah break; # finish while loop } # This is "end" Dijkstra is rolling in his grave I'm sure.. but seriously, a well considered use of goto can make code clearer. Basically it's an "if" but I turned it into a "while", so I can break out of it.
  21. I believe strict XHTML doesn't allow input and select outside of particular elements. It's given you a list of elements it is allowed inside. Check the source of http://validator.w3.org/ for a valid example. But seriously, I would rather relax your doctype than make all your html strict. It'll drive you bonkers Your warning is probably from the "<" in your javascript (which is "data"). I'm not sure what the "strict" way to do it is.
  22. You probably need single quotes around $newtext. Also you should escape $newtext with mysql_real_escape_string(), as well as all the other variables, to avoid mysql injection.
  23. The problem is when you use array elements (like $row['image']) inside a double-quoted string. You need to "protect" them from misinterpretation like this: print "The image is $row['image']"; # WRONG, will give error print "The image is {$row['image']}\n"; # RIGHT, no error teng84's method also works (he is using "." to stick strings together with variables).
  24. Is vsprintf suitable? http://sg.php.net/manual/en/function.vsprintf.php
  25. "The "preg_replace" is no longer working for this." Can you elaborate on this? How isn't it working?
×
×
  • 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.