devstudio
-
Posts
30 -
Joined
-
Last visited
Never
Posts posted by devstudio
-
-
Perfect. Happy I could provide the lead.
-
It's late, I will simply present another method.
index.php
<div id="top_sellers_col1" onMouseOver="document.getElementById('ts_over_col1').style.display='block'" onMouseOut="document.getElementById('ts_over_col1').style.display='none"> <div id="ts_over_col1" class="dd-hidden">£32.99<br />RRP: £600<br />Save: A lot! <a href="javascript:void(0);"> <img src="bully.jpg" width="117px" height="178px" alt="Bully" class="col_img" /> <div id="col_info">Bully: Scholarship Edition<br />(Xbox 360)</div> </a></div>
body.css (relevant data)
#col_info { /* You will want to change this styling */ z-index:1000; clear:both; margin:0; padding:0; font: 16px/28px arial; font-weight:bold; padding-top:5px; position: absolute; } .dd-shown { display:block; } .dd-hidden { display:none; }
All of that should parse. I am off to bed, if you need more help... I will check in the morning.
P.S. Looks like your original code had an extra div in there near "Save a Lot!" -- That may have been your problem all along.
Best, Nathan
-
I am not entirely sure I understand. But I am going to assume your "WHERE" clause is all that needs to change.
switch($category) { case 'WEBSITES': $whereTxt = " WHERE category = 'websites'"; break; case 'SOMETHINGELSE': $whereTxt = " WHERE category = 'SOMETHINGELSE'"; break; } if($whereTxt) { $queryTxt = "SELECT * FROM table ".$whereTxt; } else { // Select everything, or error? }
No idea by what you mean that you need to do the same thing in JS.
Best, Nathan
-
Here is a good/basic example:
http://www.w3schools.com/js/js_form_validation.asp
You will find that they use an onSubmit for the entire form. Remove that, and simply do an onChange, to validate the field as they leave it. When the entire form validates properly you can update your submit button.
Hint: You can use disabled on the button: <input id="submitButton" type="submit" disable="true"> -- When it validates use: document.getElementbyId('submitButton').disable="false";
Best, Nathan
-
Sets a configuration option in your ini file. (http://us3.php.net/ini_set)
ini_set ("SMTP","mail.pitpro.com.au"); -- Sets your SMTP server in PHP ini to the server listed.
ini_set('sendmail_from',"sales@pitpro.com.au") -- Sets your return address in PHP ini. -- btw, just noticed this line doesn't have a semicolon terminating the end. Perhaps if you have errors surpressed, this is just a simple parse error?
Best, Nathan
-
foreach($_POST as $key => $val) { if($key = "submit") {break;} if($key != "submit") { foreach($val as $date => $gig) { mysql_query($query) or print "First: " and die(mysql_error()); mysql_query($query2) or print "Second: " and die(mysql_error()); } } }
if($key = "submit") {break;} - Will always evaluate to true because you are using an assignment operator (successfully, which returns true/1).
if($key == "submit") {break;}
As far as what you didn't understand. Sounds like you ended up implementing it in the end anyways.
Best, Nathan
-
New lines in text areas are "\n".
Explode on \n and you should get what you are looking for.
Best,
Nathan
-
Change all of your link references to look like these:
To Select Game: <a href="<?php echo $_SERVER['PHP_SELF'] ?>?game=GH">Guitar Heo</a> To Select Console: <a href="<?php echo $_SERVER['PHP_SELF'] ?>?game=<?php ehco $_GET['game']; ?>&console=PS2">PS2</a> To Select Difficulty: <a href="<?php echo $_SERVER['PHP_SELF'] ?>?game=<?php ehco $_GET['game']; ?>&console=<?php ehco $_GET['console']; ?>&diff=Easy">Easy</a> <a href="<?php echo $_SERVER['PHP_SELF'] ?>?game=<?php ehco $_GET['game']; ?>&console=<?php ehco $_GET['console']; ?>&diff=Medium">Medium</a> [etc...]
Best, Nathan
-
In that case, you can use the REQUEST_URI, as explained in the first example.
However if it is to be architected like the example link, I would still use the switch case to determine what main "action" they are performing and then in the suburl's just include what is relevant from the current information.
<?php if(!empty($_GET['id']) && file_exists("./$_GET[id].php")){ include("./$_GET[id].php"); } print("<a href=\"?id=hello\">Hello Page</a> | <a href=\"?id=goodbye\">Goodbye Page</a><br><br>"); switch($_GET['id']) { case 'hello': break; echo "<a href=\"?id=".$_GET['id']."&sub_id=Bob\">Hello Bob</a>"; echo "<a href=\"?id=".$_GET['id']."&sub_id=John\">Hello John</a>"; case 'goodbye': echo "<a href=\"?id=".$_GET['id']."&sub_id=Bob\">Goodbye Bob</a>"; echo "<a href=\"?id=".$_GET['id']."&sub_id=John\">Goodbye John</a>"; break; } ?>
-
Should be able to do:
mysql_query("UPDATE users SET money=money+money WHERE username='$username'"); -or- mysql_query("UPDATE users SET money=money*2 WHERE username='$username'");
MYSQL is probably better at it then php, because the value will never even be set in php's memory this way.
Best, Nathan
-
Switch to Euros?!
If you have access to MySQL this may be of some help.
-
It is indeed most-likely a server problem.
You should be getting a mailer daemon at the reply-to address. Try changing the reply-to address to one of your hotmail accounts.
If you could see a mailer-daemon, my guess would be something with the RCPTHOSTS config: Error 553.
In a nutshell, the server you are trying to send from isn't authenticated or allowed to send messages to the SMTP server you are mailing to, but for whatever odd reason is acting with authority when routing mail to hotmail.
Best, Nathan
-
http://www.php.net/array_intersect ... should do it.
-
Naming Convention (because of php4)
Functions and MethodsFunctions and methods should be named using lowercase and words should be separated with an underscore. Functions should in addition have the grouping/module name as a prefix, to avoid name collisions between modules.
Private class members (meaning class members that are intended to be used only from within the same class in which they are declared; PHP 4 does not support truly-enforceable private namespaces) are preceded by a single underscore.
http://drupal.org/coding-standards
Best, Nathan
-
This would best be done with regular expressions, I am not a regular expression guru, but I would recommend checking out the regular expressions forum on these boards.
Best, Nathan
-
No Problem. If it's working please mark this thread as "Solved."
-
Is it Tot getting lost? Is it being assigned as "$field"?
If so, fix is below, $field is being printed in the javascript popUp literally.
<? $NewJoyCard = mysql_query("SELECT count(*) FROM subscribers WHERE formid = 4 and DATE(FROM_UNIXTIME(requestdate)) = CURRENT_DATE()"); php foreach($rowTotJoyCard as $field){ if($field >0){?> <a href="javascript:popUp('details2.php?MR=TotJoyCard&Reg=Total Joy Card Signups&Tot=<?php echo $field; ?>')"><?php echo $field; ?></a><?php } else{echo "0";} } ?>
-
Serialization certainly isn't required.
But to keep some sanity, I would recommend building a multidimensional array.
// Assign Page 1 $_SESSION['page_1'] = $_POST; // Assign Page 2 $_SESSION['page_2'] = $_POST; // Assign Page 3 $_SESSION['page_3'] = $_POST;
-
No Problem. Hope this clarifies.
<?php function format_size($size, $round = 0) { //Size must be bytes! $sizes = array('B', 'kB', 'MB', 'GB'); for ($i=0; $size > 1024 && $i < count($sizes) - 1; $i++) $size /= 1024; return round($size,$round).$sizes[$i]; } function filesize_r($path){ if(!file_exists($path)) return 0; if(is_file($path)) return filesize($path); $ret = 0; foreach(glob($path."/*") as $fn) $ret += filesize_r($fn); return $ret; } $path = "gal"; $raw_filesize = filesize_r($path); echo "Folder $path = ".format_size($raw_filesize); ?>
-
I think that makes fine sense.
As long as $_POST is only what you want. Of course you can unset() anything out of $_POST before serializing.
Keep in mind these types of User Interfaces is what AJAX is all about.
Best, Nathan
-
You could run your final filesize value through this function. (from: http://us2.php.net/filesize)
<?php function format_size($size, $round = 0) { //Size must be bytes! $sizes = array('B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'); for ($i=0; $size > 1024 && $i < count($sizes) - 1; $i++) $size /= 1024; return round($size,$round).$sizes[$i]; } ?>
[...] in-case someone doesn't want it to go up to 'TB' and deletes 'TB' onwards but the file size is larger than 1024GB this checks to see if you have outreached the size of $sizesKiloBytes, MegaBytes and Gigabytes only.
<?php function format_size($size, $round = 0) { //Size must be bytes! $sizes = array('B', 'kB', 'MB', 'GB'); for ($i=0; $size > 1024 && $i < count($sizes) - 1; $i++) $size /= 1024; return round($size,$round).$sizes[$i]; } ?>
-
I always find it easiest to make sure all form data is passed as an array.
<input type="text" name="formData[name]">
Elegant is a matter of opinion.
- Dump each pages form data ($_GET[formData or $_POST[formData]) into a session and append to that session with each subsequent page, on the last page insert from the session.
- Serialize each pages formdata and place that serialized string into a hidden field. Append to the string on subsequent pages. Unserialize on the final page and perform your operations.
Best, Nathan
- Dump each pages form data ($_GET[formData or $_POST[formData]) into a session and append to that session with each subsequent page, on the last page insert from the session.
-
Simply: http://www.php.net/mysql_list_fields
*oops* Looks like that has been deprecated. Read Example #1 on that link for "new" way.
That example will show you the resulting array for the query, you can use a simple conditional statement to check to see if a particular field exists.
Best, Nathan
-
If you are building an entire application, I would recommend using a database abstraction layer.
Even if it is custom-made by you. Just abstract your functions: mysql_connect, mysql_query, etc, and call them via, custom_mysql_query so that you can make changes to code cleaning, etc later.
Example (this is *old*, so please forgive any shortcomings):
$db_user = ''; $db_pass = ''; $db_name = ''; $tbl_pages = ''; $db_connection = mysql_pconnect('localhost', $db_user, $db_pass) or die("Unable to connect to database."); mysql_select_db($db_name, $db_connection); function db_query($query_string) { global $db_connection; $result_set = mysql_query($query_string, $db_connection) or $error =1; if($error == 1) { $return = 0; } else { $return = $result_set; } return($return); } function db_affected() { global $db_connection; $affected = mysql_affected_rows($db_connection); return($affected); } function db_fetch_array($result_set) { $row_array = mysql_fetch_array($result_set); return($row_array); } function db_fetch_row($result_set) { $row_array = mysql_fetch_row($result_set); return($row_array); } function db_insert_id() { global $db_connection; $insert_id = mysql_insert_id($db_connection); return $insert_id; } function db_num_rows($result_set) { $num_rows = mysql_num_rows($result_set); return($num_rows); } function db_build_insert($table, $array) { $str = "INSERT INTO $table "; $strn = "("; $strv = " VALUES ("; while(list($name,$value) = each($array)) { if(is_bool($value) and ($value != "")) { $strn .= "$name, "; $strv .= ($value ? "true":"false") . ", "; continue; } if(is_string($value) and ($value != "")) { $strn .= "$name, "; $strv .= "'$value', "; continue; } if (!is_null($value) and ($value != "")) { $strn .= "$name, "; $strv .= "$value, "; continue; } } $strn[strlen($strn)-2] = ')'; $strv[strlen($strv)-2] = ')'; $str .= $strn . $strv; return $str; } function db_build_update($table, $array, $where) { if($where != "") { $str = "UPDATE $table SET "; while(list($name,$value) = each($array)) { if(is_string($value) && ($value != '')) { $strp .= "$name='$value', "; } elseif($value != "") { $strp .= "$name=$value, "; } else { $strp .= "$name=NULL, "; } } $strw = " WHERE $where"; $strp = substr($strp, 0, -2); $str .= $strp.$strw; } else { die('<strong>Unconditional Update is not Supported</strong>'); } return $str; }
You can sanitize everything before running mysql_query, in the db_query function.
The other nice thing about this is you can print every query statement in a debugging mode, if you added a print line to the db_query() function.
*Note: Couple of cool builder functions in there, db_build_update and db_build_insert, they accept arrays, and do the fancy sql language for you. Please note, definitely sanitize the input on those arrrays or the resulting sql string!
Best, Nathan
New Div onmouseover help.
in Javascript Help
Posted
My apologies for the oversights.
Happy it is working for you! Best, Nathan