premiso
Members-
Posts
6,951 -
Joined
-
Last visited
-
Days Won
2
Everything posted by premiso
-
[SOLVED] Manipulate array (remove certain keys and renaming keys)
premiso replied to lindm's topic in PHP Coding Help
function remove($item) { if (is_array($item)) { foreach ($item as $key => $val) { if (substr($key,-2) == 'py') { unset($item[$key]); } } return $item; } } $b = remove($_POST); echo json_encode($b); Should work as long as $_POST is an array, so make sure you are posting data. -
[SOLVED] Dont Display Link if already clicked
premiso replied to jnerotrix's topic in PHP Coding Help
How do you know that a survey has not been completed? Answer that then add that identifier to the survey query in a WHERE clause and you got your answer. -
are you sure you created a user in the database? root should work by default unless that was modified. Check your database and make sure it allows for that username/password combo and or reset it so it matches what you want.
-
Not to dis you ghostrider, just modifying your code to be more logical, cause if you are not connected, then there is no reason to select the DB. Also that code tells nothing about the error, IE why it would not connect. <?php $con = mysql_connect(localhost, "dbname here", "dbpass here"); if(!$con){ die( "ERROR: could not connect to database!<br /> With ERROR: " . mysql_error()); } $db = mysql_select_db(dbname here, $con); ?> So if no connection kill the script and tell them why it was killed. Good for development scenarios so you can see exactly what is going wrong, etc.
-
mysql_error is what it should be, not mysql_connect_error.
-
If it is a while loop use break;
-
[SOLVED] Manipulate array (remove certain keys and renaming keys)
premiso replied to lindm's topic in PHP Coding Help
function remove(&$item) { foreach ($item as $key => $val) { if (substr($key,-2) == 'py') { unset($item[$key]); } } } $b = array_map("remove", $_POST); echo json_encode($b); I think that would work. You have to pass it by reference from what I remember.... -
unset($_SESSION['compare'][array_search($id, $_SESSION['compare'])]); Should get you the desired result.
-
I do not think so. I am sure they can recognize it but I doubt it gives you better SEO rating because of it. If it does than google just went against all the preach about with sites being SEO friendly. I would look up on GOOGLE SEO FRIENDLY and you will find out how google ranks sites. http://en.wikipedia.org/wiki/Search_engine_optimization Will give some insight as well. Just remember that content is everything. If your site is stale and does not have new content consistently you will rank lower, if your site generates alot of content you tend to rank higher. Also implementing SEO Friendly URLS tends to help a ton.
-
The IPN Script: <?php /* * ipn.php * * PHP Toolkit for PayPal v0.51 * http://www.paypal.com/pdn * * Copyright (c) 2004 PayPal Inc * * Released under Common Public License 1.0 * http://opensource.org/licenses/cpl.php * */ //get global configuration information include_once('../includes/global_config.inc.php'); //get pay pal configuration file include_once('../includes/config.inc.php'); //decide which post method to use switch($paypal[post_method]) { case "libCurl": //php compiled with libCurl support $result=libCurlPost($paypal[url],$_POST); break; case "curl": //cURL via command line $result=curlPost($paypal[url],$_POST); break; case "fso": //php fsockopen(); $result=fsockPost($paypal[url],$_POST); break; default: //use the fsockopen method as default post method $result=fsockPost($paypal[url],$_POST); break; } //check the ipn result received back from paypal if(eregi("VERIFIED",$result)) { include_once('./ipn_success.php'); } else { include_once('./ipn_error.php'); } ?>
-
If you have an SMTP server, yes. If not no. Look up SMTP servers and see if you want to try it.
-
Give it a try. I honestly do not know enough about the script to see how that data would be populated/where you get it from. I will take a look at the other code and see if I cannot figure it out. But if you try that and it works let us know. It will help get this solved. EDIT: Thinking about it, you have $request defined in the initial script, what does that print out if you print it? I am thinking that the $request variable may have the information you need? But not 100% sure.
-
Must be something really small that i can see missing!
premiso replied to raDiO_acTivE's topic in PHP Coding Help
I do not think $this is a goo variable name to use, due to OOP Try something like $this_2 and see what happens. -
Sort of, basically when you do that redirect there are no $_REQUEST data like you need there to be for the script to work. I am not sure how it should/would work, but it seems your script is missing a piece of the puzzel. I am not sure where you got the data before and why it is not coming in now, what page calls that transaction page, is it possible to store the data coming in from paypal in a session and instead of using $_REQUEST use $_SESSION ? There are alot of unknowns it seems like but the gist of it is that index.php page is not getting the data it needs through $_REQUEST for whatever reason.
-
Must be something really small that i can see missing!
premiso replied to raDiO_acTivE's topic in PHP Coding Help
Where is $this coming from on line 4? should it be $that? -
<?php include('include/config.php'); error_reporting(E_ALL); ini_set('display_errors','On'); echo $_REQUEST['unique_id']; die(); if($_REQUEST['payment_status'] == 'Completed') { /* get temp order information */ $random_id = $_REQUEST['unique_id']; Not saying that the code is doing that, your htaccess script seems to be doing it.
-
Must be something really small that i can see missing!
premiso replied to raDiO_acTivE's topic in PHP Coding Help
In this section $result contains a resource link, no "username" like you want it to. $query = "select `username` from `users` where `userid`='{$user['userid']}'"; $result = $db->query($query); $earnings = sprintf("UPDATE `users` SET `money` = `money` + %d WHERE `userid` = %u", $that['pot'], $user['userid']); $db->query($earnings); event_add($user['userid'],"You won the weekly lottery and were credited \${$that['pot']}",$c); $insert = sprintf("INSERT INTO `rafflelog` (rID,rDATE,rUSER,rAMNT) VALUES ('', unix_timestamp(),%u,%d)", $result, $that['pot']); $db->query($insert); Try this: $query = "select `username` from `users` where `userid`='{$user['userid']}'"; $result = $db->query($query); $username = $db->fetch_row($result); $username = $username['username']; $earnings = sprintf("UPDATE `users` SET `money` = `money` + %d WHERE `userid` = %u", $that['pot'], $user['userid']); $db->query($earnings); event_add($user['userid'],"You won the weekly lottery and were credited \${$that['pot']}",$c); $insert = sprintf("INSERT INTO `rafflelog` (rID,rDATE,rUSER,rAMNT) VALUES ('', unix_timestamp(),%u,%d)", $username, $that['pot']); $db->query($insert); -
If you have a known file type where every other line is the name/definition you could do this: <?php $file = array(0 => "name = val1", 1 => "jack = jackson2"); // file() functon will put file into an array foreach ($file as $val) { $split = split(" = ", $val); $$split[0] = $split[1]; // assign $name = val1 } ?> Did that not give you your answer. If the variables are in a file, like you said the above would assign $name = "val1" ? <?php $file = array(0 => "name = val1", 1 => "jack = jackson2"); // file() functon will put file into an array foreach ($file as $val) { $split = split(" = ", $val); $$split[0] = $split[1]; // assign $value['name'] = val1 } echo $jack . "<Br />"; echo $name . "<Br />"; ?> Prints out jackson2 val1
-
Not sure what you are getting at, technically you are not assing them to a variable you are just printing them out to make them appear like you are assigning them to variables. I am also not sure if a variable can start with a number...(not 100% on this but pretty sure).
-
If you have a known file type where every other line is the name/definition you could do this: <?php $file = array(0 => "name = val1", 0 => "jackson2"); // file() functon will put file into an array foreach ($file as $val) { $split = split(" = ", $val); $$split[0] = $split[1]; // assign $name = val1 } ?> Not recommended as putting them into an array is alot safer, quicker and easier to access imo. <?php $file = array(0 => "name = val1", 0 => "jackson2"); // file() functon will put file into an array foreach ($file as $val) { $split = split(" = ", $val); $values[$split[0]] = $split[1]; // assign $value['name'] = val1 } print_r($values); ?>
-
You would have to encapsulate it in quotes if it will work or else syntax error. Here is my version that should work with what you want: <?php $time1 = strtotime('4:00 PM'); $time2 = strtotime('4:30 PM'); $newtime = time(); if ($time1 < $newtime && $time2 > $newtime) { include('script.php'); } ?> Unsure if the strtotime will return right, but yea.