
webmaster1
Members-
Posts
607 -
Joined
-
Last visited
Never
Everything posted by webmaster1
-
[SOLVED] Quickie: $_SESSION and the concept behind it...
webmaster1 replied to webmaster1's topic in PHP Coding Help
Great, no need then for this scenario. I think I'm going to grow lazy and fat on these global functions. -
[SOLVED] Quickie: $_SESSION and the concept behind it...
webmaster1 replied to webmaster1's topic in PHP Coding Help
Perfect. I wasn't sure when it ended. One more question on this: Is it considered best practice to keep the session alive using GET? In other words will I get away with not catering for those with disables cookies because its not a liklihood? I've noticed that IE will sometimes prompt "cookies must be enabled for this site". Is this an automatic prompt? -
Hi All, (apologies for the fractional threads) I have a page (invalid.php) that basically echoes an error message. In the background I want to write the IP address and date to insert into a mySQL table every time the page loads rather than when a submit button is clicked. How would I trigger this based on the below snippet of code: $ipaddress = getenv('REMOTE_ADDR'); query = "INSERT INTO invalid VALUES ('','$ipaddress',NOW())"; mysql_query($query);
-
[SOLVED] Quickie: $_SESSION and the concept behind it...
webmaster1 replied to webmaster1's topic in PHP Coding Help
Yep, thats only snippets of the code. I have it functioning already: <?php session_start(); $valid_username = "foo"; $valid_password = "bar"; $username = isset($_POST['username'])?$_POST['username']:""; $password = isset($_POST['password'])?$_POST['password']:""; if ($username == $valid_username && $password == $valid_password) { $_SESSION['logged'] = true; header("Location: adminhm.php"); }else { $_SESSION['logged'] = false; header("Location: invalid.html"); } ?> I was just wondering how it all actually works. Is it cached in a file in my browser somewhere? I'm not using a database because I just have the one password btw. I've come across this: -
Hi All, I'm using the global $_SESSION function to allow the user log into an admin page: if ($username == $valid_username && $password == $valid_password) { $_SESSION['logged'] = true; Each page that I want password protected checks if the session is logged. session_start(); if (!$_SESSION['logged']) This all seems to work as desired but I'd like to know if this is actually the case. How does the session know to stay logged as I navigate from page to page and how does it know to end?
-
Got the aforementiond JS image viewer script working fine so that it allows a default image prior to mousing over and hence no blank space. Here's the solution if anybody stumbles across this or would like to know how: To load a default image simply paste it in the load div area of the html page: <div id="loadarea" style="width: 600px"> <img src="IMAGEHERE.jpg" alt=""><br> </div> To ensure that there is no blank area on a mouse out simply ensure that following line of the JS file is set to FALSE: hideimgmouseout: false, //Hide enlarged image when mouse moves out of anchor link?
-
Alrite, I'll get cracking. No point in speculating when I can be doing. I'll get back to ye if I have any beef integrating the PHP with the JS.
-
Maq: By the sounds of what your saying I can define my image paths as variables and insert them into JS just like html. I'm still stuck with the problem of having a default larger image displayed before any mouseover event but I geuss thats an issue for a JS forum (any reccomendations on a frequently active JS forum?) Mchl: Yep, I've used the lightbox approach before but I want the larger image to swap out within my page (as per the above pictured example) rather than imposed over my page.
-
I'm concerned that I won't be able to integrate PHP with either of them. I stumble enough when it comes to regular mark up. If you follow this link you'll see a live demo and the complete source code of a JS solution: http://www.dynamicdrive.com/dynamicindex4/thumbnail2.htm The only problem is that it doesn't display the larger image by default. The image only shows on the mouse-over. I wouldn't know where to begin in editing the JS source code. So close but not close enough.
-
I was trying to keep it simple to get a prompt answer but I shall obey captain... Three images would be outputted into a page (via a path stored in mySQL). The image viewer would present the three images as thumbnails (via resizing, I got lazy and avoided GD). The thumbnails when clicked upon would display a larger version of the image above them (without opening a new window). The first thumbnail would be displayed by default as the larger image. It wouldn't require a thumbnail scroll function since there will only ever be three images. Is this something that PHP can faciliate? When I search for PHP image viewers online they mostly describe how to build image galleries which involves leaving the page to view the larger image.
-
Can something similar be constructed with PHP alone?
-
Wow, I honestly didn't think it would be that simple. I set page 1 to send bar and then defined bar as a variable in page 2 which I then added to my query. Easy as pie when you know how... $query="SELECT * FROM test WHERE urn = '$geturn' ORDER BY date"; I now have the output functioning exactly as illustrated in the previously posted diagram. Thanks Crayon!
-
[SOLVED] Basic mySQL query error: mysql_numrows()
webmaster1 replied to webmaster1's topic in PHP Coding Help
Changed index to urn. $query="SELECT * FROM test WHERE urn = '134' ORDER BY date"; Works perfectly! -
[SOLVED] Basic mySQL query error: mysql_numrows()
webmaster1 replied to webmaster1's topic in PHP Coding Help
I've changed my primary key name from index to [index] in mySQL and my code. I still recieve the same error: <?php mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query="SELECT * FROM test WHERE [index] = '134' ORDER BY date"; mysql_error(); $result=mysql_query($query); $num=mysql_num_rows($result); mysql_close(); ?> revraz: Was mysql_error() meant to have a semi-colon? If yes, I recieve the exact same error as above. If no, I recieve a parse error. -
[SOLVED] Basic mySQL query error: mysql_numrows()
webmaster1 replied to webmaster1's topic in PHP Coding Help
Fixed but exact same error. Perhaps its the query itself? -
Hi All, Can anybody spot whats discrepant with the below query? It works fine without the WHERE index = '134' part. It seems to be related to the number of rows. <?php mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query="SELECT * FROM test WHERE index = '134' ORDER BY date"; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); ?>
-
Shouldn't they be rewarded with some of those free sweets of yours for helping you out. (and me too for pointing it out ) Tsk! Tsk! Didn't close the door on the way out either. Mark as solved.
-
Righto, here's the looped thumbnails with a link bit: <?php include("dbinfo.php"); mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query="SELECT imageurl1 FROM test ORDER BY date"; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); echo "<b><center>Output Thumbs</center></b><br><br>"; $i=0; while ($i < $num) { $imageurl1=mysql_result($result,$i,"imageurl1"); echo "<a href="SOMELINK"><img src='$imageurl1' width='250' height='188'><a>"; //echo "$imageurl1"; $i++; } ?> The output.php?foo=bar and $_GET['foo'] concept is completley alien to me though. Is there a specific terminology for this that I can research/google?
-
I've worked the above tutorial successfully but it wasn't what I was looking for at all. Here's a diagram if it helps: I geuss I'm not looking for pagination at all. I simply need a row of data outputted into its own page after selecting a thumbnail link. Any ideas or at least a clarification of the terminology and key words I need to be searching under?
-
The following page shows the entire output to be displayed to the user when the thumbnail is clicked. <?php include("dbinfo.php"); mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query="SELECT * FROM test ORDER BY date"; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); echo "<b><center>Database Output</center></b><br><br>"; $i=0; while ($i < $num) { $index=mysql_result($result,$i,"index"); $make=mysql_result($result,$i,"make"); $model=mysql_result($result,$i,"model"); $price=mysql_result($result,$i,"price"); $engine=mysql_result($result,$i,"engine"); $transmission=mysql_result($result,$i,"transmission"); $year=mysql_result($result,$i,"year"); $colour=mysql_result($result,$i,"colour"); $mileagem=mysql_result($result,$i,"mileagem"); $mileagekm=mysql_result($result,$i,"mileagekm"); $owners=mysql_result($result,$i,"owners"); $doors=mysql_result($result,$i,"doors"); $location=mysql_result($result,$i,"location"); $info=mysql_result($result,$i,"info"); $date=mysql_result($result,$i,"date"); $ipaddress=mysql_result($result,$i,"ipaddress"); $imageurl1=mysql_result($result,$i,"imageurl1"); $imageurl2=mysql_result($result,$i,"imageurl2"); $imageurl3=mysql_result($result,$i,"imageurl3"); echo " $index</br> $make</br> $model</br> $price</br> $engine</br> $transmission</br> $year</br> $colour</br> $mileagem</br> $mileagekm</br> $owners</br> $doors</br> $location</br> $info</br> $date</br> $ipaddress</br> <img src='$imageurl1' width='250' height='188'> <img src='$imageurl2' width='250' height='188'> <img src='$imageurl3' width='250' height='188'> </br> <hr><hr> </br> "; $i++; } ?> This displays all of the mySQL table with a listing of consecutive records.
-
Hi All, I want to output the contents of a mySQL table into an individual page per each row. The user will initially be presented with a page of thumbnails which when clicked will link to a page consisting of additional information for that product. Here's the page that displays the thumnails: <?php include("dbinfo.php"); mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query="SELECT imageurl1 FROM test ORDER BY date"; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); echo "<b><center>Output Thumbs</center></b><br><br>"; $i=0; while ($i < $num) { $imageurl1=mysql_result($result,$i,"imageurl1"); echo "<img src='$imageurl1' width='250' height='188'>"; $i++; } ?> If anyone is familiar with paging I was hoping you could advise me of what I need to be looking at next.
-
Its a two way process. First the image is copied to the folder (which you have done). Next you need to write the path (url) by inserting it into your database e.g. upload/imagename.jpg When outputting you need to define your output as a variable and place it as the path within an image e.g. img src='$imageurl' which in turn will call on the image you previosly uploaded. I recommend researching how to upload and output images adeptly first. A generous amount of tutorials are sprinkled around ye old web. You'll need to start looking at sessions and basic login tutorials thereafter. Don't make the mistake of trying to nail it all in your very first script. > Learn how to insert path (url) into table > Learn how to output the image by calling its path > Learn how to work with sessions and logins