-
Posts
5,717 -
Joined
-
Last visited
-
Days Won
6
Everything posted by Adam
-
$p->add_field('amount', $_POST['formtext1']); try that..
-
Trying to allow multiple id processing with one submission.
Adam replied to hofdiggity's topic in PHP Coding Help
Don't think anyone will just do it for you. If you do want someone to do it for you then I'd ask in the freelance section... -
Erm, very vague. What kind of code is it? If you mean return everything from within two tags, say a div element(?) you could use JavaScript with something like: var content = document.getElementById('yourElementsID').innerHTML; ... (or ".value" depending on the element, like an 'input' for example) ------------ To return the JS code I have no idea, don't know if you can? Need bit more information really... Adam
-
[SOLVED] Sending a PHP variable to a JS script
Adam replied to mark110384's topic in Javascript Help
Okay so the PHP script is called from the JavaScript using AJAX. You're then echo'in out all the variables (except $price) on the PHP side .. so firstly remember when you call a PHP script with AJAX, you only receive a string of text "searchReq.responseText" .. not the actual variables. So using $price isn't going to work... what you could do is format the and print out the string on the JS side. What I've done in the past is return the string in a var1|var2|var3 form .. then split the string into an array using the | as the delimitor. So for example: PHP echo $chartcode .'|'. $chartp .'|'. $chartdescription .'|'. $price ."\n"; JS var records = searchReq.responseText.split("\n"); for (x in records) { var str = searchReq.responseText.split('|'); var suggestTxt = str[0] + ' ' + str[1] + ' - ' + str[2]; var suggest = '<div onmouseover="javascript:suggestOver(this);" '; suggest += 'onmouseout="javascript:suggestOut(this);" '; suggest += 'onclick="javascript:setSearch(this.innerHTML, ' + str[3] + ');" '; suggest += 'class="suggest_link">' + suggestTxt + '</div>'; ss.innerHTML += suggest; } Then you'll just need to change the setSearch function to: function setSearch(value, price) { document.getElementById('chart_info').innerHTML = value + "Price: " + price; } Not tested this code so there by an error or two, but should work with a little tweaking! Adam -
Source of a local iframe as a php variable to be saved to txt file.
Adam replied to Xproterg^vi's topic in PHP Coding Help
How would view-source sort the problem? I don't actually think view-source is anything more than a browser command? (Though it's not actually supported in IE) .. I think sending view-source at the start of the file_get_contents function would just cause it to fail? -
Oh need to use "OR" not "||" Also I tested the query and it fails, I reckon it's because "character" has a meaning within mysql and it's causing an error in the SQL syntax using it as a table name. I renamed it to "players" and the messed with the query a little bit and came up with the following... This will return the 3 skill records for character #'1'.. SELECT * FROM Skill AS a, Players AS b WHERE (a.ID = b.Skill1 OR a.ID = b.Skill2 OR a.ID = b.Skill3) AND b.ID = '1' A typical return may look like: id name id player character type skill1 skill2 skill3 1 Sneak 1 John Doe Smooth Criminal Thief 1 2 3 2 Evade 1 John Doe Smooth Criminal Thief 1 2 3 3 Fight 1 John Doe Smooth Criminal Thief 1 2 3 This will return the skill info in skill slot 1 for character #'1'.. SELECT * FROM Skill AS a, Players AS b WHERE a.ID = b.Skill1 AND b.ID = '1' A typical return may look like: id name id player character type skill1 skill2 skill3 1 Sneak 1 John Doe Smooth Criminal Thief 1 2 3 -------------- The bottom line in each query sets the character in question in the query to '1'. You could very easily replace the 1 with a PHP variable such as the user's session id or a GET value sent in the URL like.. "skillInfo.php?id=##" .. Does that all make sense? Adam
-
Ah sorry, misread what you said. I got the impression you were wanting the skill definitions for a certain character's skills.. like all 3 of them.. If you just wank Skill1's details, could use something like: SELECT * FROM Skill, Character WHERE Skill.ID = Character.Skill1 The previous query I showed you before is actually quite simple: SELECT * FROM Skill, Character AS b That just means select everything from Skill, and basically set "b" as a kind of variable for the Character table, so instead of having to go: WHERE Skill.ID = Character.Skill1 || Skill.ID = Character.Skill2 || Skill.ID = Character.Skill3 can just use: WHERE ID = b.Skill1 || ID = b.Skill2 || ID = b.Skill3 And obviouslly that's just finding skill records where the skill ID matches that in either skill slot 1, 2 or 3 of the character... Did I describe that well :S Adam
-
How would I get this log to automatically clear or be limited to how many?
Adam replied to brianjw's topic in PHP Coding Help
That just moves all the log entries up a file.. like from file 1 to 2.. file 2 to 3 etc.. however frequently you set up the cron to run. There's nothing limiting the logs to 100 entries though.. I'm a little unsure myself about how you could do it.. -
How would I get this log to automatically clear or be limited to how many?
Adam replied to brianjw's topic in PHP Coding Help
Using a database would be simpler for limiting the entries, if you have one available too you? Adam -
23,1 |5,1 |5,1 I assume the ",1" after each is the rank achieved? Would make it easier if you perhaps used: Skill 1 | Skill 1 Rank | Skill 2 | Skill 2 Rank | etc. ..as the fields? Then you could go like... SELECT * FROM Skill, Character AS b WHERE ID = b.Skill1 || ID = b.Skill2 || ID = b.Skill3 (not tested) .. but that should return their 3 skills...
-
Source of a local iframe as a php variable to be saved to txt file.
Adam replied to Xproterg^vi's topic in PHP Coding Help
$source = file_get_contents("http://mysite.com/"); will return the source... -
Huh yeah not noticed that... Yeah they're stored in YYYY-MM-DD format but for some reason the query still works? Odd! Adam
-
Good explanation of the function used here: http://uk3.php.net/fgetcsv But.. basically while the variable $data still reads from the csv file and does not = false, do that code...
-
How To Create A Dropdown listing between two Date Ranges
Adam replied to KevMull's topic in PHP Coding Help
Hah I went through this just the other day, was a bit of a nightmare.. I'll give you a big help though and show you the MySQL syntax for selecting between two dates: SELECT * FROM yourTable WHERE yourDateField BETWEEN 'YYYY-MM-DD' AND 'YYYY-MM-DD' That assumes in the database table each record has a single date. Then the range of dates will replace the two YYYY-MM-DD 's, i don't know if you have two fixed dates in mind or if you're going to have a form for the user to select.. but that should help you on your way.. -
OR if that doesn't work: VALUES ('" .$row['realname']. "',
-
Do they need to be in form of 1, 2, 3, 4 etc ?? If not just create yourself a naming formula like.. md5(TodaysDate_TimeToTheSecond_Random4DigitNum) Chances are like 1 in 10 thousand per second that someone will ever get the same number.. or something daft! If they do need to be in order, could loop through, eg: $x = 1; while ( !file_exists($x . '.jpg')) { $x++; } $filename = $x . '.jpg'; ..not tested though! If you had a lot of uploads however, and it gets to like 300.jpg, or even 3000.jpg, don't wanna have to loop through each time. so could use a database or flatfile or something to store the current count... Adam
-
[SOLVED] how to zip all files in a folder using exec() command
Adam replied to php1's topic in PHP Coding Help
try using http://uk3.php.net/zip -
$row = mysqli_fetch_assoc($result); .. returns an array. you need to use: $row['realname'] in: VALUES ('$row['realname']', Adam
-
Okay so double check; $username is what it's supposed to be that the username exists in the database and.. that there isn't two of the same username seen as you're using == 1 Adam
-
ahh, do you have error reporting turned off?? here's the problem i reckon: mysql_numrows($sql) should be: mysql_num_rows($sql)
-
Instead of: if (!get_magic_quotes_gpc()) { $username = mysql_real_escape_string(stripslashes($_POST['username'])); $password = mysql_real_escape_string(stripslashes(md5($_POST['password']))); } Just use: $username = mysql_real_escape_string(stripslashes($_POST['username'])); $password = mysql_real_escape_string(stripslashes(md5($_POST['password']))); See if that works? If not try outputting the $username and $password variables, if still nothing, try changing: if (mysql_numrows($sql) == 1) { $set = mysql_fetch_array($sql); if ($password == $set['password']) { $_SESSION['username'] = $set['username']; $_SESSION['id'] = $set['id']; $_SESSION['usrlvl'] = $set['usrlvl']; $_SESSION['logged_in'] = 1; } } to: if (mysql_numrows($sql) == 1) { $set = mysql_fetch_array($sql); if ($password == $set['password']) { $_SESSION['username'] = $set['username']; $_SESSION['id'] = $set['id']; $_SESSION['usrlvl'] = $set['usrlvl']; $_SESSION['logged_in'] = 1; } else { die('Invalid password!'); } } else { die('No user found!'); } Any luck?
-
[SOLVED] sessions not carried over in firefox new tabs...
Adam replied to pavanpuligandla's topic in PHP Coding Help
No no.. thats for if they enter the login form. that codes just basically testing if they're already loggin in and redirecting them if so. And you only really need to test one session value. People tend to use something that actually means something, like.. $_SESSION['loggedIn']; so when you see: if ($_SESSION['loggedIn']) { makes sense... adding more $_SESSION values to the if can i guess be added safety but if your system works right then you shouldn't need to really.. Adam -
[SOLVED] sessions not carried over in firefox new tabs...
Adam replied to pavanpuligandla's topic in PHP Coding Help
Ah right gotchya, thought you was asking why it weren't working... could check for the time_start session you're setting, ie: <?php session_start(); if ($_SESSION['time_start']) { header("Location: memberspage.php"); } ?> put that at the top of loginpage.html (except it'll need to be .php now) and it should work fine... Adam -
[SOLVED] sessions not carried over in firefox new tabs...
Adam replied to pavanpuligandla's topic in PHP Coding Help
Okay that's just static HTML, why would the session carry over to this page? -
Oh you've missed session_start() off of the top, should be: <?php session_start(); if (!isset($_SESSION['us....... Also have you connected to the database? Just realised there's no code...