Wednesday, 1 July 2009
|
| Clear POST variables on page refresh Richard Morley 08:14:21 |
| | I'm not sure if this is specifically a PHP problem, but here we go. Is there a way to clear the POST variables when the user refreshes a page? Specifically, my webpage POSTs a form to update or delete a record from the database -- it POSTs to itself, however. But if the user then clicks the browser's refresh button, it will try to delete or modify a non-existent record. I would like, if the users presses the refresh button, that PHP processes the page as no POST variables are set. I have a button on the page entitled "Reload" that executes a short Javascript: onclick=window.location=<? echo PHP_SELF; ?> which accomplishes the desired effect. But it tries to resend the POST information if the browser refresh button is clicked.
I read something somewhere that seemed to imply this could be done with PHP sessions? Is this the way to go? If so, how?
Thanks for any help.
Richard Morley
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
|
| | 9 answers | Add comment |
Wednesday, 24 June 2009
|
| get output in .html file Martin 12:17:45 |
| | Does somebody know how to get the output of an .php file into an .html file (server side). This in order to cache generated pages for futur visitors.
thanks
Martin
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
|
| | 3 answer | Add comment |
Monday, 25 May 2009
|
| [SMARTY] break out of foreach-loop Stefan Sturm 15:52:31 |
| | Hello list,
my question:
I have a foreach-loop. How can I break this loop before it ends?
Greetings,
Stefan Sturm
-- Smarty General Mailing List (http://smarty.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
|
| | 6 answers | Add comment |
Wednesday, 13 May 2009
|
| PHP5 and $_SERVER['DOCUMENT_ROOT'] Jenifer 15:29:56 |
| | Well, I've found my first broken program when PHP 5 is installed. The program sets a path variable like this:
$HOMEPATH = $_SERVER['DOCUMENT_ROOT']."/appdir/";
Now, I get error messages like this at the top of these pages:
Notice: Undefined index: email in /usr/local/www/data/appdir/blocks/login_block.php on line 29
Notice: Undefined index: password in /usr/local/www/data/appdir/blocks/login_block.php on line 30
I saw a few posts about setting "register_long_arrays" on in php.ini, but that change didn't help. This file is included in many files from many different directories in the program. I even tried just hard coding the path, but then get these errors on pages that use functions like
file_get_contents($HOMEPATH."theme/login.htm");
(I had hard coded the HOMEPATH variable and still get these errors)
argh. Anyone have any ideas?
Jenifer
|
| | 4 answer | Add comment |
Friday, 24 April 2009
|
| mysql_fetch_array(): supplied argument is not a valid MySQL result resource Ben Houlton 17:27:10 |
| | I'm trying to make a PHP script that automaticly makes a link on the side menu to the id page that was just made, under certain catagories. But I edited my code to cleen up soem errors and all of a sudden 3 errors came up, and I haven't been able to fix them! They are: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\Inetpub\wwwroot\main\menu.php on line 29 Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\Inetpub\wwwroot\main\menu.php on line 41 Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\Inetpub\wwwroot\main\cat.php on line 39
The code for the menu and cat *.php files are below:
menu.php: <HTML>
<HEAD>
<link href="/css/base.css" rel="STYLESHEET" type="text/css">
</HEAD>
<BODY>
<TABLE width=100% cellPadding=0 cellSpacing=0>
<TR>
<TD width=150 vAlign=top>
<?php
$register_globals;
$db = mysql_connect("localhost","root");
mysql_select_db("common",$db);
$result = mysql_query("SELECT * FROM main",$db);
echo "<center>Main</center><br>";
while ($row1 = mysql_fetch_array($result)) {
if ($row1["cat"] == 1) {
printf("<a href=\"pages.php?cat=1&id=%s\">%s</a><br>", $row1["id"], $row1["title"]);
}
}
echo "<center>Misc.</center><br>";
while ($row1 = mysql_fetch_array($result)) {
if ($row1["cat"] == 2) {
printf("<a href=\"pages.php?cat=2&id=%s\">%s</a><br>", $row1["id"], $row1["title"]);
}
}
?>
</TD>
<TD>
cat.php:
<?php
if ($submit) {
if ($id) {
$sql = "UPDATE main SET content='$content', title='$title' cat='$cat' WHERE id=$id";
} else {
$sql = "INSERT INTO main (content,title,cat) VALUES ('$content','$title','$cat')";
}
$result = mysql_query($sql);
echo "Record updated/edited!<p>Return to <A href=\"pages.php?cat=$cat&id=$id\">Index</a>.";
} elseif ($delete == areyousure) {
$sql = "SELECT * FROM main WHERE id=$id";
$result = mysql_query($sql);
echo "Are you sure you want to delete $title?<p><a href=\"$PHP_SELF?cat=$cat&id=$id&delete=true\">Yes</a> | <a href=\"$PHP_SELF\">No</a>";
} elseif ($delete == true) {
$sql = "DELETE FROM main WHERE id=$id";
$result = mysql_query($sql);
echo "$title Record deleted!<p><a href=\"$PHP_SELF?cat=$cat&id=$cat\">Return</a>";
} else {
$result = mysql_query("SELECT * FROM main",$db);
while ($row = mysql_fetch_array($result)) {
if ($id == $row["id"] && $cat == $row["cat"]) {
printf("<center><font size=5>%s</font></center><br><br>", $row["title"]);
printf("%s<br><br>", $row["content"]);
printf("<a href=\"$PHP_SELF?cat=$cat&id=%s&delete=areyousure\">(DELETE)</a><br>", $row["id"]);
printf("<a href=\"$PHP_SELF?cat=$cat&id=%s&edit_add=$cat\">(EDIT)</a><br>", $row["id"]);
}
}
echo "<P><a href=\"$PHP_SELF?cat=$cat&edit_add=$cat\">ADD A RECORD</a><P>";
}
?>
<?php
if ($edit_add) {
?>
<form method="post" action="pages.php?cat=<?php echo $cat ?>">
<?php
if ($id) {
$sql = "SELECT * FROM main WHERE id=$id";
$result = mysql_query($sql);
$row = mysql_fetch_array($result);
$id = $row["id"];
$title = $row["title"];
$cat = $row["cat"];
$content = $row["content"];
?>
<input type=hidden name="id" value="<?php echo $id ?>">
<?php
}
?>
<TABLE cellPadding="0" cellSpacing="0" border="0">
<TR>
<TD>Title:</TD>
<TD><input type="Text" name="title" value="<?php echo $title ?>"></TD>
<TD rowSpan="2" vAlign="Top">
<TABLE border="0" cellPadding="0" cellSpacing="0"> <?php
$result = mysql_query("SELECT * FROM cat",$db);
while ($cat = mysql_fetch_array($result)) {
printf("<TR><TD>%s</TD><TD><input type=\"radio\" name=\"cat\" value=\"%s\"></TD></TR>", $cat["name"], $cat["id"]);
}
?></TD></TR></TABLE></TD></TR>
<TR>
<TD>Message:</TD>
<TD rowSpan="3"><textarea name="content" rows="7" cols="40" wrap="virtual"><?php echo $content ?></TEXTAREA></TD></TR></TABLE>
<input type="Submit" name="submit" value="Enter information">
</form>
<?php
}
?>
Anny help would be highly appreciated! Thank You for your time.
-Ben
|
| | 3 answer | Add comment |
Friday, 3 April 2009
|
| stdClass to array Cere Davis 10:20:13 |
| | Hey folks,
Does anyone know of a painless way to convert a stdClass object to an associative array in php?
Also, I wonder, is there a way to "flatten" associative arrays in php? So say: $b=new array(s=>"S") $a=new array(a=>"A",b=>$b)
goes to: $z=flatten($a); z turns to: (a=>"A", b=>$b, s=>"S");
Thanks, Cere
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
|
| | 2 answer | Add comment |
Tuesday, 31 March 2009
|
| Need a job asap Daniel Joyce 01:59:09 |
| | Hey guys,
Due to the wonderful economy, my last contracting gig ended 2 months ago, and my bank accts are nearly bare.
I'd appreciate any job leads you can offer. Please forward them to the reply-to address. And I mean any. As I am having a hard time finding new contracting positions, I need at least survival job. So if your brother's uncle need's someone to help out with his landscaping business, I'm in. Know any local chains hiring? I'm there.
I'd appreciate any help you can give.
My background is in Java/C/Php/Python development with Oracle/MySql/Postgres experience. I'm also pretty handy with HTML too.
I'll forward my resume to any that request it.
-Daniel Joyce --
The Meek shall inherit the Earth, for the Brave are among the Stars!
|
| | 1 answer | Add comment |
Sunday, 22 March 2009
|
mailform Yolanda Montealegre 06:16:55 |
| | Hi everyone, I have been racking my brains trying to get a simple maiform script to work. I keep getting an Internal Server Error 500. I have the file in the cgi-bin, I have chmod permissions set correctly and my form input tags are correct and yet nothing. Does it matter if I upload in Binary or Ascii? I'm including the php code for the form, plus my HTML tags. Any help would be fabulous. I want to be able to reuse the script simply by changing email to send data, and thank you redirect page. Thanks ahead of time!! Yolanda HTML TAGS: (and yes, I have: email not E-Mail) <FORM method="POST" action="http://www.patzcuarolake.com/cgi-bin/mailform.php"> <INPUT type="hidden" name="recipient" value="famalli@hotmail.com"> <INPUT type="hidden" name="subject" value="Real Estate Information Request"> <INPUT type="hidden" name="redirect" value="http://www.patzcuarolake.com/cambrons_realestate_thankyou.htm"> <INPUT type="hidden" name="required" value="name,email,day_phone"> <INPUT type="hidden" name="print_config" value="email,subject"> <INPUT type="hidden" name="print_blank_fields" value="1"> PHP SCRIPT: <?php /********************************************************************* * >>>> DO NOT CHANGE THIS FILE OR IT MIGHT NOT WORK <<<< * >>>> WE WILL NOT SUPPORT THIS SCRIPT IF IT IS <<<< * >>>> ALTERED IN ANY WAY FROM IT'S ORIGINAL FORM <<<< * 1.) Verify they are coming from our server * 2.) Get the current Time * 3.) Get all variables from Get and Post * 4.) Make sure they entered all required fields * 5.) Send Email * 6.) Print HTML/redirect to proper page * * change this line to $debug = true; if you want to enable debugging*/ $debug = false; /********************************************************************/ if($debug) { echo "<pre>"; echo "GET Variables:"; print_r($_GET); echo "POST Variables:"; print_r($_POST); echo "</pre>"; error_reporting(E_ALL); } else { error_reporting(0); } /********************************************************************* * 1.) Verify they came from our server. *********************************************************************/ //get just the domain name from the referer and server we are on $referer=preg_replace('/^http:\/\//','',$_SERVER['HTTP_REFERER']); $referer=preg_replace('/\/.*/','',$referer); $referer=preg_replace('/^www./','',$referer); $server=preg_replace('/^www./','',$_SERVER['SERVER_NAME']); //if server does not match referer, print error page if($referer!=$server) { error($server,"Bad Referer. You can only send email through this script if you use a form on this domain.<br> If you are using a form on this domain, and still get this message, try disabling any<br> firewalls you have running, it could be blocking the headers this script checks before sending mail."); } /********************************************************************* * 2.) Get the current Time. *********************************************************************/ $date=date("l, F dS, Y \a\\t H:i:s"); /********************************************************************* * 3.) Get all variables from Get & Post put them into $fields array *********************************************************************/ if($_SERVER['REQUEST_METHOD']=="GET") { foreach($_GET as $name=>$value) { $fields[$name]=$value; } } elseif($_SERVER['REQUEST_METHOD']=="POST") { foreach($_POST as $name=>$value) { $fields[$name]=$value; } } else { error($server,"Unkown method. You must specify method=\"GET\" or method=\"POST\" in order for the mailform script to work."); } /********************************************************************* * 4.) Make sure they entered all required fields *********************************************************************/ $config=array("recipient","subject","email","realname","redirect","required", "env_report","sort","print_config","print_blank_fields","title","return_link_url", "return_link_title","missing_fields_redirect","background","bgcolor", "text_color","link_color","vlink_color","alink_color"); if(isset($fields['required'])) { $required=preg_split("/,/",$fields['required']); } else { $required=array(); } //make sure they at least have the email and receipient fields array_push($required,'email'); array_push($required,'recipient'); $required = array_unique($required); $field_keys=array_keys($fields); $missing=""; foreach($required as $value) { if(!$fields[$value] && $fields[$value]!="0"){ $missing.="<li>$value</li>"; } } //if they have missing fields if($missing) { //if they have their own missing fields page, direct them there if(isset($fields['missing_fields_redirect'])) { header("Location: ".$fields['missing_fields_redirect']); exit; } else { error($server,"You have not filled in all of the required fields. The missing fields are:<br> <ul>$missing</ul>"); } } //if the email address looks invalid if(!eregi("([_\.0-9a-z-]+@)([0-9a-z][0-9a-z-]+\.)+([a-z]{2,3})", $fields['email'])) { error($server,"Please enter a valid email address."); } foreach($config as $value) { if(preg_match("/\~|\`|\#|\%|\^|\&|\*|\(|\)|\+|\=|\{|\}|\[|\]|\<|\>|\;|\|/",$fields[$value])) { error($server, "Invalid Charaters detected in $value. You may not use any of these characters<br> ~ \` # $ % ^ & * ( ) + = { } [ ] < > ; | <br> In the form fields."); } } /********************************************************************* * 5.) Send Email *********************************************************************/ //sort fields, if needed if(isset($fields['sort'])) { if($fields['sort']=="alphabetic") { ksort($fields); } else { $fields['sort']=preg_replace('/^order:/','',$fields['sort']); $sort_order=preg_split("/,/",$fields['sort']); foreach($sort_order as $value) { $temp[$value]=$fields[$value]; } $temp_keys=array_keys($temp); foreach($fields as $name=>$value) { if(!in_array($value,$temp_keys)) { $temp[$name]=$value; } } $fields=$temp; } } //end of sort routine //create body of email message $body="Below is the result of your feedback form on www.$server. It was submitted by\n"; if(isset($fields['realname'])) { $body.=$fields['realname']." (".$fields['email'].")"; } else { $body.=$fields['email']; } $body.=" on $date \n"; $body.="---------------------------------------------------------------------------\n"; //don't print config fields: //unless they have print_config set if(isset($fields['print_config'])) { $print_config=preg_split("/,/",$fields['print_config']); $config=array_diff($config,$print_config); } foreach($fields as $name=>$value) { if(!in_array($name,$config)) { $body.="$name: $value\n"; } } $body.="---------------------------------------------------------------------------\n"; //Print off the env_report if that is set if(isset($fields['env_report'])) { $env_fields=preg_split("/,/",$fields['env_report']); foreach($env_fields as $value) { if(isset($_SERVER[$value])) { $body.="$value: ".$_SERVER[$value]."\n"; } } } //set the subject if one doesn't exist if(!isset($fields['subject'])) { $fields['subject']="www.$server Form Submission"; } //Finally, send the message! mail($fields['recipient'], $fields['subject'], $body, "From: ".$fields['email']); if($debug) { echo "<pre>"; echo "Email being sent:<br>"; print_r($body); echo "</pre>"; } /********************************************************************* * 6.) Print HTML/redirect to proper page *********************************************************************/ //if they set a redirect page, send user there if(isset($fields['redirect'])) { header("Location: ".$fields['redirect']); } //Set some default values if they are not set if(!isset($fields['print_blank_fields'])) { $fields['print_blank_fields']=1; } if(!isset($fields['title'])) { $fields['title']="Thank You!"; } if(!isset($fields['bgcolor'])) { $fields['bgcolor']="#ececec"; } if(!isset($fields['text_color'])) { $fields['text_color']="#000000"; } if(!isset($fields['link_color'])) { $fields['link_color']="#000000"; } if(!isset($fields['vlink_color'])) { $fields['vlink_color']="#000000"; } if(!isset($fields['alink_color'])) { $fields['alink_color']="#000000"; } echo <<<TERMHTML <html> <head> <title>Thank You for contacting $server</title> </head> <body bgcolor="$fields[bgcolor]" text="$fields[text_color]" link="$fields[link_color]" vlink="$fields[vlink_color]"> <center> <table border="1" bordercolor="#000000" width="600" cellpadding="4"> <tr> <td bgcolor="#FEA096"> <font face="arial" size="4" color="$fields[text_color]"><b><center>Here is what you submitted to $server on $date</center></b></font> </td> </tr> <tr> <td> TERMHTML; foreach($fields as $name=>$value) { if(!in_array($name,$config) && ($value || $fields['print_blank_fields'])) { echo "<b>$name:</b> $value<br>"; } } if(isset($fields['return_link_url']) && isset($fields['return_link_title'])) { echo "<ul><li><a href=\"$fields[return_link_url]\" target=\"_top\">$fields[return_link_title]</a></ul>"; } echo <<<TERMHTML <font face="arial" size="2"></font></td> </tr> </table><br><a href="http://www.$server">Click here to return to our main page</a></b> </body> </html> TERMHTML; /********************************************************************* * Function: Error($server,$value) * purpose: print off the error message in $value, nice and neat * Then exit program. *********************************************************************/ function error($server, $value) { echo <<<TERMHTML <html> <head><title>$server Mailform Error</title></html> <body bgcolor="$fields[bgcolor]" text="$fields[text_color]" link="$fields[link_color]" vlink="$fields[vlink_color]"> <center> <table border="1" bordercolor="#000000" width="600" cellpadding="4"> <tr> <td bgcolor="#FEA096"> <font face="arial" size="4" color="$fields[text_color]"><b><center>$server Mailform Error</center></b></font> </td> </tr> <tr> <td><b>$value</b> </td> </tr> </table><br><b>Your IP is $_SERVER[REMOTE_ADDR]</b> </center> </body> </html> TERMHTML; exit; } ?> |
| | 3 answer | Add comment |
Monday, 16 February 2009
|
| Assigning PHP Arrays to Javascript arrays Frank Kicenko 19:42:22 |
| | Hi, Question: How can assign a PHP array to a Javascript array?
Example:
while($row=$result->FetchRow()) { $serv[$i++] = $row[0]; }
var server = new Array(index); server = <?= $serv ?>;
for(ind = 0; ind < index; ind++) { alert(server[ind]); }
This doesn't work for some strange reason....
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
|
| | 7 answers | Add comment |
Thursday, 27 November 2008
|
| users & groups Jef Peeraer 17:58:57 |
| | i installed the latest version, which is 0.9.14.6. My user and group accounts are located in an ldap database. I can see all my users in phpgroupware, that's ok. I can't see the primary group a user belongs too when i edit a user. This is already defined in ldap, but doesn't show up in the selection list. i have to manually select it for each user. is this normal behaviour or is it a bug ?
jef
ps this is the only thing that stops me from using the phpgroupware tool !
|
| | 6 answers | Add comment |
Thursday, 13 November 2008
|
| Fatal error: Call to a member function fetchRow() on a non-object
in C:\Xampp\xampp\htdocs... J Kuehne 18:29:54 |
| | Hello
I am pleased if someone could explain me since is wrong the following function call: ($row = & $result->fetchRow(DB_FETCHMODE_ASSOC, $_SESSION["searchFormVars"]["offset"]+$rowCounter)); as you will find them on the bottom of the email. By the way, fetchRow() is an object from class DB(.php). However mysql_fetch_row() should have same functionality but the argument resp. the identity is different. I hardly try to do not mix up functionality from mysql- with db- members.
$search = ($_SESSION["searchFormVars"]["search_eb"]); $link = mysql_connect("localhost", "root", "040573"); mysql_select_db("knowledge", $link);
$query = setupQuery($_SESSION["searchFormVars"]["search"]);
$result=@mysql_query($query);
for ( $rowCounter = 0; ($rowCounter < SEARCH_ROWS) && (( $rowCounter + $_SESSION["searchFormVars"]["offset"]) < mysql_num_rows($result)) && ($row = & $result->fetchRow(DB_FETCHMODE_ASSOC, $_SESSION["searchFormVars"]["offset"]+$rowCounter)); $rowCounter++) {
Error message: Fatal error: Call to a member function fetchRow() on a non-object in C:\Xampp\xampp\htdocs\www2\knowledge_db\searchnew.php on line
best regards, Georg
|
| | 8 answers | Add comment |
Tuesday, 11 November 2008
|
| escaping quotes Giles 15:41:43 |
| | Hi Guys
Really simple question. How do I change the following:
print("value='" . $attributes["messageSubject"] . "'");
to have double quotes around the subject field instead. i.e.:
print("value="" . $attributes["messageSubject"] . """);
thanks
Giles Roadnight http://giles.roadnight.name
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
|
| | 11 answers | Add comment |
Saturday, 18 October 2008
|
| Cache Boaz Yahav 02:12:09 |
| | Hi
I must be missing something. I'm trying to disable the option to press the back button on a spesific page.
I added this header : header("Cache-control: no-cache");
and i also tried adding :
header("Expires: Mon, 26 Jul 1970 05:00:00 GMT"); // Date in the past header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always modified header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 header("Pragma: no-cache"); // HTTP/1.0
however, you can still use the back button.
any idea?
Sincerely
berber
Visit http://www.weberdev.com/ Today!!! To see where PHP might take you tomorrow.
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
|
| | 40 answers | Add comment |
Friday, 10 October 2008
|
| [SMARTY] Paging Richard Watt 11:03:20 |
| | Ignore that last thread about errors, I managed to fix it (I was making calls to a function on one of my classes that messed things up). Next question is regarding paging tables.
I have managed to do a multipage output of an array using only smarty, but it makes rather a lot of use of the {math} function, which I realise is not very efficient. Is there any way of doing this more efficiently (I know there is a custom paging function I can download, but I would prefer to do this in Smarty as I need a bit more than that function provides)?
{section name=styles loop=$mystyle max=#recordsPerPage# start= $smarty.get.offset|default:0} {if $smarty.section.styles.first}
<table class="table_content"> <tr> <th> Name </th> <th> Directory </th> <th> Description </th> </tr> {/if} <tr> <td class="{cycle values="rowlight,rowdark" advance=false}"> {$mystyle[styles].styleName} </td> <td class="{cycle advance=false}"> {$mystyle[styles].styleDirectory} </td> <td class="{cycle}"> {$mystyle[styles].styleDescription} </td> </tr> {if $smarty.section.styles.last} <tr> <td colspan="3"> {capture name=maxrecords}{math equation="x + y" x= $smarty.get.offset|default:0 y=#recordsPerPage#}{/capture} {capture name=lastpage}{math equation="x - y" x=$records y=#recordsPerPage#}{/capture} {$smarty.capture.lastpage} Viewing records {math equation="x + 1" x= $smarty.get.offset|default:0}-{if $records gte $smarty.capture.maxrecords}{$smarty.capture.maxrecords}{else}{$records} {/if} of {$records} <BR> {if $smarty.get.offset ne 0}<a href="./admin.php?p=style&offset=0"> <<</a>{/if} {if $smarty.get.offset ne 0}<a href="./admin.php?p=style&offset= {math equation="x - y" x=$smarty.get.offset|default:0 y=#recordsPerPage#}"><</a>{/if} {if $smarty.get.offset ne $smarty.capture.lastpage}<a href="./admin.php?p=style&offset={math equation="x + y" x= $smarty.get.offset|default:0 y=#recordsPerPage#}">></a>{/if} {if $smarty.get.offset ne $smarty.capture.lastpage}<a href="./admin.php?p=style&offset={$smarty.capture.lastpage}">>></a>{/if} </td> </tr> </table> {/if} {sectionelse} <table class="table_content"> <tr> <th> There are no records, sorry. </th> </tr> {/section}
-- Smarty General Mailing List (http://smarty.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
|
| | 21 answer | Add comment |
Friday, 3 October 2008
|
| Pagination Valerie 17:17:19 |
| | It shows next and the first 10 records but will not bring up the next 10 when next is pressed.
<?php require ('db_params.inc'); if(!$start) $start = 0; $query2 = 'SELECT count(*) as count ' . ' FROM `Wellington` ' . ' WHERE`location`="Hills"';
$result2 = mysql_query($query2); $row2 = mysql_fetch_array($result2); $numrows = $row2['count']; if($start > 1){ echo "<a href=\"" . $_SERVER['PHP_SELF']. "?start=" . ($start- 10) . "\">Previous</a><BR>"; } if($numrows > ($start + 10)){ echo "<a href=\"" . $_SERVER['PHP_SELF']. "?start=" . ($start + 10) . "\">Next</a><BR>"; }
$query='SELECT * ' . ' FROM `Wellington` ' . ' WHERE`location`="Hills" ORDER BY `LotNo` ASC LIMIT ' . $start. ',10';
$result=mysql_query($query); while ($row = mysql_fetch_assoc($result)) { $location=$row['Location']; $ln=$row['LotNo']; $price=$row['Price'];
$listing="<html> <head> </head> <body> <table align='center'> <tr> <td>$ln</td>
<td> $location</td> <td>$price</td> </tr></table> </body></html>"; echo $listing; } ?>
----- Original Message ----- From: <php-db-digest-help@lists.php.net> To: <php-db@lists.php.net> Sent: Sunday, December 05, 2004 6:50 AM Subject: php-db Digest 5 Dec 2004 11:50:43 -0000 Issue 2714
-- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
|
| | 23 answer | Add comment |
Tuesday, 23 September 2008
|
| number format Balwantsingh 21:13:18 |
| | hello,
may pls. suggest me how i can retreive number before decimal and after decimal. for example 123456.7. I want to store 123456 in a variable and 7 in another.
also how can i force the user by validations so that he can only enter data in this format only i.e. 123456.7.
thanks
with best wishes balwant
-- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
|
| | 48 answers | Add comment |
Tuesday, 9 September 2008
|
| access denied Water_foul 21:29:57 |
| | i get this error: Warning: Access denied for user: 'aaron.aichlmayr.net@localhost' (Using password: YES) in C:\Inetpub\localroot\aichlmayr.net\sites\aaron\module\runescape\runerunner\s ervices.php on line 3 and the code up to line 3 is: <?php //Database Querys $connection=Mysql_connect($dbHost , $dbName , $dbPassword); ---------------------------------------- i have included this in another script that sets $dbHost, $dbName and, $dbPassword to the correct things to connect to the db
-- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
|
| | 46 answers | Add comment |
Saturday, 6 September 2008
|
| Stupid question Liam MacKenzie 02:09:54 |
| | I have a script that outputs this: 0.023884057998657
What's the command to make it shrink down to this: 0.023
I thought it was eregi() something, but I forgot. sorry
Cheers
(I've spent the last 10 minutes reading the manual, can't find it!!!)
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
|
| | 31 answer | Add comment |
Friday, 29 August 2008
|
| Felamimail crashes Kaushik Mallick 09:42:04 |
| | I am getting this following error when trying to launch Felamimail. I looked thru all the threads and particularly bug # 886. Somebody also suggested tweaking the class.bofelamimail.inc.php file. I am not an expert in php. Could someone please provide me simple instructions to solve this problem. Much appreciated:
*Warning*: Couldn't open stream {server.ctd.net:143}INBOX in */var/www/html/phpgroupware/felamimail/inc/class.bofelamimail.inc.php* on line *698*
*Warning*: imap_getsubscribed(): supplied argument is not a valid imap resource in */var/www/html/phpgroupware/felamimail/inc/class.bofelamimail.inc.php* on line *294* *Database error Invalid SQL: select messages,recent,unseen,uidnext,uidvalidity from phpgw_felamimail_folderstatus where hostname='server.ctd.net' and accountname='kaushik' and foldername='INBOX' and accountid='6' *Session halted.* *Fatal error*: Call to undefined function: parse_navbar_end() in */var/www/html/phpgroupware/phpgwapi/inc/footer.inc.php* on line *62*
|
| | 4 answer | Add comment |
Wednesday, 23 July 2008
|
| File upload problem Frans Bakker 10:57:17 |
| | Hello everybody,
I am relatively new to PHP and for quite some days I am trying to get a file upload system going through a standard html form. To test it I use an html page called Test2.php with a form in it with enctype=\"multipart/form-data\". Here is the source code:
<?php
$AppImageDir = Web/Images";
if (isset($_FILES["ImageFile"])) { move_uploaded_file($_FILES['ImageFile']['tmp_name'], $AppImageDir."/".$_FILES['ImageFile']['name']);
}
?>
<html> <head> <title>Web site - pages form</title> </head> <body> <?php
echo " <form action=\"Test2.php\" enctype=\"multipart/form-data\" method=\"post\"> <input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"80000\"> <input type=\"file\" name=\"ImageFile\"> <input type=\"submit\" name=\"btnSubmit\" value=\"Upload\"> </form> "; ?>
</body> </html>
It is a standard straight forward image upload situation. You see that the form directs to itself (action=\"Test2.php\") and on top of the page a simple instruction to see if the file uploads correctly. As far as I can see, this is correct code. Note that the any \\ are to escape "" and further \\ (necesary in echo "" statements).
However, when I execute the page, I get the following error messages:
Warning: Unable to create '/Web/Images/cartel_feria1.jpg': Permission denied in /Web/Test2.php on line 6
Warning: Unable to move '/tmp/php0jHeNE' to '/Web/Images/cartel_feria1.jpg' in /Web/Test2.php on line 6
It seems to say that I don't have permission to execute a file upload on that page. As you can see by the directory specifications this script runs on a Linux. However, I also tried the same script on a Windows machine, with the corresponding directory specifications of course, and with the same result: permission denied.
What is wrong here, where do I set what type of permissions in order to get the file upload to work? By the way, in the php.ini FileUpload is set at yes.
Kind regards, FRANS BAKKER
-- PHP Development Mailing List <http://www.php.net/> To unsubscribe, visit: http://www.php.net/unsub.php
|
| | 70 answers | Add comment |
Tuesday, 1 July 2008
|
| Javascript question Robin Kopetzky 06:52:00 |
| | I know this may be off-topic but I've got a problem that I do not know how to work around...
I'm displaying a <SELECT> list and the problem is getting the value back after an 'onChange' event. Code is like this:
<HTML> <HEAD> <SCRIPT LANGUAGE="JAVASCRIPT"> <!-- function jump() { document.buttons.submit(); } --> </SCRIPT> </HEAD> <BODY BGCOLOR="#FFFAB4" LEFTMARGIN="0" TOPMARGIN="0"> <FORM NAME="buttons" TARGET="buttons" ACTION="buttons.php" METHOD="get"> <INPUT TYPE="hidden" NAME="pass" VALUE="1"> <CENTER>State</CENTER> <CENTER> <SELECT onChange="jump()"> <OPTION NAME="state_name" VALUE="Colorado">Colorado</OPTION> <OPTION NAME="state_name" VALUE="New Mexico">New Mexico</OPTION> </SELECT> </CENTER> </FORM> <BODY> </HTML>
I need to get the "state_name" back but all I get in the $_GET['state_name'] array is an empty value. Any clue as to why this won't work??
I don't want to use a 'Submit' button as this is very cumbersome when I add the other 3 <SELECT> lists...
Robin 'Sparky' Kopetzky Black Mesa Computers/Internet Service Grants, NM 87020
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
|
| | 70 answers | Add comment |
Thursday, 26 June 2008
|
| Please, answer my question S. M. 01:50:03 |
| | <?php
#include 'include.inc'; # mySQL host address (usually 'localhost') $db_host = "localhost";
# mySQL database name $db_name = "e_submission";
# mySQL database username $db_username = "root";
# mySQL database password $db_password = "esub";
# option to enable link to the to-do editor # to enable/disable, enter '1' to ENABLE or '0' to DISABLE (without quotes) $opt_link = 1;
function db_connect() { // Open a connection to the DBMS global $db_host, $db_name, $db_username, $db_password;
mysql_connect($db_host, $db_username, $db_password) or die ("<font color=red>Cannot connect to mySQL server</font>"); mysql_select_db($db_name) or die ("<font color=red>Cannot connect to mySQL database</font>"); }
function todo() { global $db_host, $db_name, $db_username, $db_password, $opt_link;
echo"<html>\n<head>\n<title>TO-DO List</title>\n</head>\n\n<body link=#C0C0C0 vlink=#C0C0C0 alink=#C0C0C0>\n"; echo"<font face=tahoma,arial><center><h2>TO-DO List</h2>\n\n";
db_connect(); $sql = "SELECT * FROM `announcement` ORDER BY `id` DESC LIMIT 0, 30"; $result = mysql_query($sql) or die ("Unknown mySQL error"); mysql_num_rows($result) or die ("<i>Nothing is currently on the to-do list</i> - <a href=$_SERVER[PHP_SELF]?do=edit>Edit the list</font></a>");
echo"<table border=3 cellspacing=3 cellpadding=2 bordercolor=#000000 bgcolor=#E0E0E0 width=80% style=\"font-size: 14px; border-collapse:collapse;\">\n<tr><td width=75><b>ID</b></td><td width=430><b>Title</b></td><td width=330><b>Content</b></td><td width=154><b>Date</b></td></tr>\n";
while ($row = mysql_fetch_array($result)) { echo"<tr bordercolor=#B9B3A2><td width=75>$row[id]</td><td width=430>$row[title]</td><td width=330>$row[content]</td><td width=154>$row[date_time]</td></tr>\n"; }
if ($opt_link == 1) { echo"</table>\n\n<br><br><a href=$_SERVER[PHP_SELF]?do=edit><font color=black>TO-DO List Editor</font></a><br>"; } else { echo"</font></table>\n\n<br><br>"; }
echo"<font size=1 color=#C0C0C0>Powered by <a href=http://mtnpeak.net>TO-DO List v0.2</a></font></font>\n\n</body>\n</html>"; }
function todoedit() { global $db_host, $db_name, $db_username, $db_password;
echo"<html><head><title>TO-DO List / editor</title></head> <body link=#C0C0C0 vlink=#C0C0C0 alink=#C0C0C0><center><b><font face=tahoma, arial> <center><b><h2>TO-DO List</b> / editor</h2></center> <table border=3 bordercolor=\"#000000\" style=\"border-collapse: collapse\" cellpadding=\"4\" cellspacing=\"1\" height=\"450\"><tr> <td width=50% height=\"441\"> <font>
<form action=\"$_SERVER[PHP_SELF]?do=edit\" method=\"post\"> <b>Add</b> <table border=0><tr><td width=28><font size=\"2\">ID</font></td><td width=300> <font size=\"2\">Title</font></td><td width=80><font size=\"2\">Date</font></td></tr> <tr><td>X</td><td><input type=text name=\"item1\" size=45></td><td><input type=text name=\"date1\" size=10></td></tr> <tr><tr><td></td><td><font size=\"2\">Content:</font><br><input type=text name=\"notes1\" size=45></td></tr> <tr><td></td><td align=center><input type=submit value=Add name=add></td><td></td></tr></table><br><br><br>
<form action=\"$_SERVER[PHP_SELF]?do=edit\" method=\"post\"> <b>Update</b> <table border=0><tr><td width=28><font size=\"2\">ID</font></td><td width=300> <font size=\"2\">Title</font></td><td width=80><font size=\"2\">Date</font></td></tr> <tr><td><input type=text name=\"id2\" size=1></td><td><input type=text name=\"item2\" size=45></td><td><input type=text name=\"date2\" size=10></td></tr> <tr><tr><td></td><td><font size=\"2\">Content:</font><br><input type=text name=\"notes2\" size=45></td></tr> <tr><td></td><td align=center><input type=submit value=Update name=update></td><td></td></tr></table><br><br><br>
<form action=\"$_SERVER[PHP_SELF]?do=edit\" method=\"post\"> <b>Delete</b> <table border=0><tr><td width=28><font size=\"2\">ID</font></td><td width=300> <font size=\"2\">Title</font></td><td width=80><font size=\"2\">Date</font></td></tr> <tr><td><input type=text size=1 name=id></td><td><font size=\"2\">XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX</font></td><td> <font size=\"2\">XXXXXXX</font></td></tr> <tr><td></td><td align=center> <input type=submit value=Delete name=delete style=\"color: #FF0000\"></td><td></td></tr></table>
</td><td width=50% valign=top height=\"441\">
<B>TO-DO List Preview Pane</b>   <font size=1><a href=$_SERVER[PHP_SELF]?do=edit>Refresh</a></font>";
db_connect(); $sql = "SELECT * FROM `announcement` ORDER BY `id` DESC"; $result = mysql_query($sql) or die ("Unknown mySQL error"); mysql_num_rows($result) or die ("<br><i>Nothing is currently on the to-do list</i>");
echo"<table border=1 bordercolor=\"#C0C0C0\" style=\"font-size: 12px; border-collapse: collapse\" cellpadding=\"0\" cellspacing=\"0\"><tr><td width=30><b>ID</b></td><td width=300><b>Item</b></td><td width=170><b>Content</b></td><td width=80><b>Date</b></td></tr></font>";
while ($row = mysql_fetch_array($result)) { echo"<tr><td><font size=1 face=courier>$row[id]</font></td><td><font size=1 face=courier>$row[title]</font></td><td><font size=1 face=courier>$row[content]</font></td><td><font size=1 face=courier>$row[date_time]</font></td></tr>"; }
echo"</td></tr></table><br><br><center><a href=$_SERVER[PHP_SELF]><font color=black>TO-DO List</font></a><br><font size=1 color=#C0C0C0></font></center></table></body></html>"; }
if ($_GET['do']=="edit") { if(isset($add)) { db_connect(); $sql = "INSERT INTO announcement (title, date_time, content) VALUES ('$item1', '$date1', '$notes1')"; mysql_query($sql); todoedit(); } elseif(isset($update)) { db_connect(); $sql = "UPDATE announcement SET title='$item2', date_time='$date2', content='$notes2' WHERE id='$id2'"; mysql_query($sql); todoedit(); } elseif(isset($delete)) { db_connect(); $sql = "DELETE FROM announcement WHERE id='$id'"; mysql_query($sql); todoedit(); } elseif(!isset($add) || !isset($delete) || !isset($update)) { todoedit(); }
} else { todo(); } ?>
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php |
| | 2 answer | Add comment |
Friday, 20 June 2008
|
| Problem with mcrypt_encrypt and mcrypt_decrypt. Guest 08:34:30 |
| | Hi all, i'm trying to crypt and decrypt password with the code below but i get many warnings
Warning: mcrypt_get_iv_size(): Module initialization failed in /web/htdocs/www.automationsoft.biz/home/invio_mail.php on line 36
Warning: mcrypt_create_iv(): Can not create an IV with size 0 or smaller in /web/htdocs/www.automationsoft.biz/home/invio_mail.php on line 37
Warning: mcrypt_decrypt(): Module initialization failed in /web/htdocs/www.automationsoft.biz/home/invio_mail.php on line 38 and i don't understand why, any help is appreciated. Code is below.
This code is in a script //Start crypt $iv_size=mcrypt_get_iv_size(MCRYPT_BLOWFISH,MYCRYPT_MODE_CBC); $iv=mcrypt_create_iv($iv_size,MCRYPT_RAND); $key=genera();// genera() function for rand number $emailcifrata=mcrypt_encrypt(MCRYPT_BLOWFISH,$key,$email,MYCRYPT_MODE_CBC,$iv); $emailcifrata=$key.$emailcifrata; // End crypt This code is in another script that isn't the same script of previous //Start decrypt $emailcifrata=fgets($fp); $lunghezza_str=strlen($emailcifrata); $emailcifrata=substr($emailcifrata,10); $key=substr($emailcifrata,0,($lunghezza_str-10)); $iv_size=mcrypt_get_iv_size(MCRYPT_BLOWFISH,MYCRYPT_MODE_CBC); $iv=mcrypt_create_iv($iv_size,MCRYPT_RAND); $email=mcrypt_decrypt(MCRYPT_BLOWFISH,$key,$email,MYCRYPT_MODE_CBC,$iv); // End decrypt
Thanks in advance. |
| | 1 answer | Add comment |
Tuesday, 17 June 2008
|
| [SOAP-ENV:Client] Error cannot find parameter Guest 18:37:52 |
| | Hi¸
I defined a 'Keyword' type in ".wsdl" file and I wish to pass an array of Keyword object to service.But I got this error: [SOAP-ENV:Client] Error cannot find parameter
schema: <xsd:complexType name="Keyword"> <xsd:all> <xsd:element name="id" type="xsd:integer"/> <xsd:element name="word" type="xsd:string"/> <xsd:element name="status" type="xsd:integer" nillable="true" minOccurs="0"/> <xsd:element name="shelve" type="xsd:boolean" nillable="true" minOccurs="0"/> <xsd:element name="sprice" type="xsd:float" nillable="true" minOccurs="0"/> <xsd:element name="qvalue" type="xsd:float" nillable="true" minOccurs="0"/> <xsd:element name="intgrt" type="xsd:float" nillable="true" minOccurs="0"/> <xsd:element name="rank" type="xsd:integer" nillable="true" minOccurs="0"/> <xsd:element name="mode" type="xsd:integer"/> <xsd:element name="price" type="xsd:float"/> <xsd:element name="title" type="xsd:string"/> <xsd:element name="desc" type="xsd:string"/> <xsd:element name="url" type="xsd:string"/> </xsd:all> </xsd:complexType> <xsd:element name="Keywords"> <xsd:complexType> <xsd:sequence> <xsd:element name="Keyword" type="typens:Keyword" maxOccurs="unbounded"/> </xsd:sequence> </xsd:complexType> </xsd:element>
and php client code: for($i=0;$i<$count;$i++){ $objKeyWord = new Keyword(); $objKeyWord->id = $i; $objKeyWord->word = $i."word"; $objKeyWord->status = $i; $objKeyWord->shelve = $i; $objKeyWord->sprice = $i; $objKeyWord->qvalue = $i; $objKeyWord->intgrt = $i; $objKeyWord->rank = $i; $objKeyWord->mode = $i; $objKeyWord->price = $i; $objKeyWord->title = $i."title"; $objKeyWord->desc = $i."desc"; $objKeyWord->url = $i."url"; $arrKeyWords[$i] = $objKeyWord; } try{ $return = print_r($objSoapClient->addKeyWords($arrKeyWords,$count),true); }catch(Exception $e){ throw $e; }
and soap request: <?xml version="1.0" encoding="UTF-8"?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn: rice>0</ns1 rice><ns1:title>0title</ns1:title><ns1:desc>0desc</ns1:desc><ns1:url>0url</ns1:url></ns1:Keyword><ns1:Keyword><ns1:id>1</ns1:id><ns1:word>1word</ns1:word><ns1:status>1</ns1:status><ns1:shelve>true</ns1:shelve><ns1:sprice>1</ns1:sprice><ns1:qvalue>1</ns1:qvalue><ns1:intgrt>1</ns1:intgrt><ns1:rank>1</ns1:rank><ns1:mode>1</ns1:mode><ns1 rice>1</ns1 rice><ns1:title>1title</ns1:title><ns1:desc>1desc</ns1:desc><ns1:url>1url</ns1:url></ns1:Keyword></ns1:Keywords><intGroupId>2</intGroupId></SOAP-ENV:Body></SOAP-ENV:Envelope>] -->http://api.baidu.com/v1/"><SOAP-ENV:Body><ns1:Keywords><ns1:Keyword><ns1:id>0</ns1:id><ns1:word>0word</ns1:word><ns1:status>0</ns1:status><ns1:shelve>false</ns1:shelve><ns1:sprice>0</ns1:sprice><ns1:qvalue>0</ns1:qvalue><ns1:intgrt>0</ns1:intgrt><ns1:rank>0</ns1:rank><ns1:mode>0</ns1:mode><ns1 rice>0</ns1 rice><ns1:title>0title</ns1:title><ns1:desc>0desc</ns1:desc><ns1:url>0url</ns1:url></ns1:Keyword><ns1:Keyword><ns1:id>1</ns1:id><ns1:word>1word</ns1:word><ns1:status>1</ns1:status><ns1:shelve>true</ns1:shelve><ns1:sprice>1</ns1:sprice><ns1:qvalue>1</ns1:qvalue><ns1:intgrt>1</ns1:intgrt><ns1:rank>1</ns1:rank><ns1:mode>1</ns1:mode><ns1 rice>1</ns1 rice><ns1:title>1title</ns1:title><ns1:desc>1desc</ns1:desc><ns1:url>1url</ns1:url></ns1:Keyword></ns1:Keywords><intGroupId>2</intGroupId></SOAP-ENV:Body></SOAP-ENV:Envelope>
who can help me plz? thx. æá þ
êíÃÛ Ãâñèëíß é î ¨ëé ===================================================== û õòçîúìÜáÃ é ¸ ñïî÷ ê üæ : éï ¸ ÌãÜ ¸ Ì Ñ æ38 åðÜ ô Ñîö18 100080¸ à (Tel): 8610-82602288 â 6611 E-mail: songqi@baidu.com
___________________________________________________________ ãþâ ÿå öÁ ÿñéîÄ-3.5Gõùà ¸ 20M http://cn.mail.yahoo.com |
| | Add comment |
|