-
Posts
264 -
Joined
-
Last visited
Never
Posts posted by php_tom
-
-
I probably shouldn't be sticking my nose into this, and I WILL NOT make more than one post about this, but surely we can forget this heated discussion and get back to coding, and helping others. That is the purpose of this site.
Have fun scripting everybody!
-
I see...
I found this somewhere in the vast cavern of knowledge we call the web:
<script> function getQueryVariable(variable) { var query = window.location.search.substring(1); var vars = query.split("&"); for (var i=0;i<vars.length;i++) { var pair = vars[i].split("="); if (pair[0] == variable) { return pair[1]; } } alert('Query Variable ' + variable + ' not found'); } </script>
Now make a request to page.html?x=Hello
<script> alert( getQueryVariable("x") ); </script>
Note that it only works with GET, not POST.
Hope that helps.
-
You didn't really describe exactly what you want to do...
I'm guessing you have something like this in mind (?):
<script> var get_variable = '<?php echo $_GET['variable']; ?>'; alert(get_variable); </script>
If not, please explain more.
-
If you have a table for classes with these fields:
Class NumCredits Grade
---------------------------------------------------
Biology 532 6 3.5 (AB)
Basket-Weaving 3 2.0 ©
Philosophy 773 4 4.0 (A)
You can get the GPA like so:
<?php $link = mysql_connect(...); mysql_select_db(...); $tot_credits = 0; $tmp_gpa = 0; $res = mysql_query("SELECT * FROM classes"); while($row = mysql_fetch_assoc($res)) { $tmp_gpa += $row['Grade']*$row['NumCredits']; $tot_credits += $row['NumCredits']; } $gpa_final = round(($tmp_gpa/$tot_credits),3); ?>
Is this sort of what you wanted?
-
Not really a vulnerability, but I can reply to a non-existent post, e.g.,
http://meisnermusic.awardspace.com/index.php?s=2&t=1234567890&a=n
Nobody will see this, but it probably populates your DB with extra stuff.
So maybe check that a post/topic exists before letting someone reply...
-
Ya it's easy.
in tmp1.html:
<html> <body> <a href='tmp2.html#C4'>Go to chapter 4 in tmp2.html</a> </body> </html>
then in tmp2.html:
<html> <body> <p> <a href="#C4">See also Chapter 4.</a> </p> <h2>Chapter 1</h2> <p>This chapter explains ba bla bla</p> <h2>Chapter 2</h2> <p>This chapter explains ba bla bla</p> <h2>Chapter 3</h2> <p>This chapter explains ba bla bla</p> <h2><a name="C4">Chapter 4</a></h2> <p>This chapter explains ba bla bla</p> </body> </html>
Hope that helps!
-
You're right, it's JavaScript.
Try this:
<html> <head> <script> var big=false; function toggleSize() { if(big) { document.getElementById('img1').style.width='100px'; big = !big; } else { document.getElementById('img1').style.width='1000px'; big = !big; } } </script> </head> <body> <img src='myImage.jpg' id='img1' onclick='toggleSize()' width='100'/> </body> </html>
Replace 'myImage.jpg' with your image url, and set the widths to whatever you want.
Hope that helps.
-
This:
function radioclick0() {
document.myform1.log_int.disabled = "no";
}
function radioclick1() {
document.myform1.log_int.value = "0";
document.myform1.log_int.disabled = "yes";
}
should be
function radioclick0() { document.myform1.log_int.disabled = false; } function radioclick1() { document.myform1.log_int.value = "0"; document.myform1.log_int.disabled = true; }
It worked in FF for me.
-
Whoa... I just replied to a post and got this:
Warning: mysql_real_escape_string(): Access denied for user 'ndowlat'@'82.197.131.25' (using password: NO) in /home/www/obb.awardspace.com/index.php on line 70
Warning: mysql_real_escape_string(): A link to the server could not be established in /home/www/obb.awardspace.com/index.php on line 70
Warning: mysql_real_escape_string(): Access denied for user 'ndowlat'@'82.197.131.25' (using password: NO) in /home/www/obb.awardspace.com/index.php on line 71
Warning: mysql_real_escape_string(): A link to the server could not be established in /home/www/obb.awardspace.com/index.php on line 71
Warning: mysql_real_escape_string(): Access denied for user 'ndowlat'@'82.197.131.25' (using password: NO) in /home/www/obb.awardspace.com/index.php on line 106
Warning: mysql_real_escape_string(): A link to the server could not be established in /home/www/obb.awardspace.com/index.php on line 106
Warning: mysql_real_escape_string(): Access denied for user 'ndowlat'@'82.197.131.25' (using password: NO) in /home/www/obb.awardspace.com/index.php on line 107
Warning: mysql_real_escape_string(): A link to the server could not be established in /home/www/obb.awardspace.com/index.php on line 107
Warning: mysql_query(): Access denied for user 'ndowlat'@'82.197.131.25' (using password: NO) in /home/www/obb.awardspace.com/index.php on line 111
Warning: mysql_query(): A link to the server could not be established in /home/www/obb.awardspace.com/index.php on line 111
Warning: mysql_query(): Access denied for user 'ndowlat'@'82.197.131.25' (using password: NO) in /home/www/obb.awardspace.com/index.php on line 113
Warning: mysql_query(): A link to the server could not be established in /home/www/obb.awardspace.com/index.php on line 113
Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/www/obb.awardspace.com/index.php on line 113
Warning: mysql_query(): Access denied for user 'ndowlat'@'82.197.131.25' (using password: NO) in /home/www/obb.awardspace.com/index.php on line 117
Warning: mysql_query(): A link to the server could not be established in /home/www/obb.awardspace.com/index.php on line 117
Warning: mysql_query(): Access denied for user 'ndowlat'@'82.197.131.25' (using password: NO) in /home/www/obb.awardspace.com/index.php on line 118
Warning: mysql_query(): A link to the server could not be established in /home/www/obb.awardspace.com/index.php on line 118
Warning: mysql_query(): Access denied for user 'ndowlat'@'82.197.131.25' (using password: NO) in /home/www/obb.awardspace.com/index.php on line 120
Warning: mysql_query(): A link to the server could not be established in /home/www/obb.awardspace.com/index.php on line 120
Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/www/obb.awardspace.com/index.php on line 121
Warning: mysql_query(): Access denied for user 'ndowlat'@'82.197.131.25' (using password: NO) in /home/www/obb.awardspace.com/index.php on line 123
Warning: mysql_query(): A link to the server could not be established in /home/www/obb.awardspace.com/index.php on line 123
You might want to fix it!
-
dunno about dw. i use SciTE (Scientific Text Editor) it has syntax highliting for PHP.
-
did you print/echo anything out after the function call?
that would break the page... what you need to do is something like this:
"img_resize.php":
img_resize("myImage.jpg"); function img_resize($image) { $filename = $image; header('Content-type: image/jpeg'); $percent = 0.22; list($width, $height) = getimagesize($filename); $newwidth = $width * $percent; $newheight = $height * $percent; $thumb = imagecreatetruecolor($newwidth, $newheight); $source = imagecreatefromjpeg($filename); imagecopyresampled($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); imagejpeg($thumb); }
Then in "myPage.php" something like:
<img src='img_resize.php" />
Hope that helps.
-
$_SESSION['SERVER_NAME']
AAAACCCKKKKK!!! I just wasn't thinking...
What I meant was:
$_SERVER['SERVER_NAME']
So yeah you can do something like:
<?php $test= $_SERVER['SERVER_NAME']; if($test=="myDomain.com") { // Link to one SQL server here } elseif($test=="localhost") { // Link to localhost SQL server } else { // Link to some other SQL server... } ?>
-
is their any way to find out "localhost" of mysql to get the actual address?
I don't entirely understand your question but this may help:
$_SESSION['SERVER_NAME'] contains the name of the server the script is running on. So this could be 'localhost' or 'myDomain.com' or whatever.
-
Maybe this is a dumb question but its worth asking: do you have cookies enabled in your browser?
-
anything like stuf.php?variable=moreStuf is GET. But you can get either through $_REQUEST.
If they want it in POST, you can instead of using header(), maybe this:
<html> <body onload="document.getElementById('form1').submit();"> <form action='page.php' method='POST' id='form1'> <input type='hidden' name='ticketDate' value='<?php echo $_POST['ticketDate']; ?>' /> </form> </body> </html>
Of course this only works if the client has JS, otherwise they see a blank page.
And it's less secure, usually you don't put important stuff in hidden fields.
I guess you could also pass info from page to page with sessions or cookies but then it gets more complicated.
-
You need the GD lib installed for this to work (look in phpinfo() to see if you do):
function img_resize($image) { $filename = $image; header('Content-type: image/jpeg'); $percent = 0.22; list($width, $height) = getimagesize($filename); $newwidth = $width * $percent; $newheight = $height * $percent; $thumb = imagecreatetruecolor($newwidth, $newheight); $source = imagecreatefromjpeg($filename); imagecopyresampled($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); imagejpeg($thumb); }
So you use it like so:
img_resize("/images/large_pics/pic1028489.jpg");
Yeah and it only works on JPGs too, though you can fix this by using imagecreatefromgif($filename); and imagecreatefrompng($filename); if you want.
-
First of all, I'd do the data validation server-side in PHP, not client-side in JS... its more secure that way.
But your real question:
header("Location: myPage.php?date=".$_POST['ticketDate']);
Maybe that helps?
-
Here's some pseudocode:
$postTimeStamp = 1010101010; // Could get this from a DB $now = time(); $newThreshold = 1 *24*60*60; // 1 day in seconds if($now - $postTimeStamp <= $newThreshold) echo "<b>".$postContent."</b>"; else echo $postContent;
Maybe that helps you?
-
Yeah, \r is a carriage 'R'eturn (same thing [pretty much] as a 'N'ewline: \n).
In windows filesystems, a new line is \r\n
In Mac its \r
in *nix its \n
Confusing isnt it? We need some standards here...
The problem with you code could be
if (mail('mymail@gmail.com', $_POST["subject"], $Body) {
Return .= "<text>Message successfully sent</text>\r\n";
} else {
Return .= "<text>Message delivery failed...</text>\r\n";
}
what you probably mean is
if (mail('mymail@gmail.com', $_POST["subject"], $Body) { $Return .= "<text>Message successfully sent</text>\r\n"; } else { $Return .= "<text>Message delivery failed...</text>\r\n"; }
Try that, post back if it still doesn't work...
-
The following is probably too verbose, but will do the job for .wmv:
<OBJECT id='mediaPlayer' width="320" height="240" classid='CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95' codebase='http://activex.microsoft.com/activex/controls/ mplayer/en/nsmp2inf.cab#Version=5,1,52,701' standby='Loading Microsoft Windows Media Player components...' type='application/x-oleobject'> <param name='fileName' value="http://mydomain.com/video.wmv"> <param name='animationatStart' value='1'> <param name='transparentatStart' value='1'> <param name='autoStart' value='1'> <param name='ShowControls' value='0'> <param name='ShowDisplay' value='0'> <param name='ShowStatusBar' value='0'> <param name='loop' value='0'> <EMBED type='application/x-mplayer2' pluginspage='http://microsoft.com/windows/mediaplayer/ en/download/' id='mediaPlayer' name='mediaPlayer' displaysize='4' autosize='0' bgcolor='darkblue' showcontrols='0' showtracker='1' showdisplay='0' showstatusbar='0' videoborder3d='0' width="320" height="240" src="http://mydomain.com/video.wmv" autostart='1' designtimesp='5311' loop='0'> </EMBED> </OBJECT>
Of course that only works if the user has WMP installed. It might play mpegs too.
Or you can convert the movies to flash (FLV) with something like http://vani.bhargav.googlepages.com/movica (MOVICA) to convert your videos to FLV. Then use an FLV player like flowplayer (http://flowplayer.org/) or something.
Videos are fun...
-
Hey.
I lost you after the third paragraph, you'll have to explain again or put a link to your page.
But for the times and intervals stuff, I'd use timestamps. Like for each shift of each employee or whatever have a DB entry with columns like the employee name or id, the timestamp of when they start work, and the timestamp of when they finish work. You can handle all the specifics of the timestamps with PHP's mktime(), time(), and strftime(). [Look these up in the PHP function reference if you don't know them]
Maybe that helps a bit?
-
-
Hehe... either somebody totally wrecked your site, or too many people are testing...
Too many connections
It looks much better, although I haven't finished testing it completely. I'll try again later.
-
There, I broke it by making a new topic called '<textarea>'. Maybe you should 'striptags()' before you accept a thread, etc. And I'd make people sign in to post anyway.
[SOLVED] passing a variable to paginated query results
in PHP Coding Help
Posted
Your code is long and a bit hard to read because you didn't use [ code ] tags, but maybe this is the problem:
I think this should be
And similarily for the other parts where you echo the 'next 10' links, etc....