|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Free Web 2.0 Code Generator! Generate data entry and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
|
|
#1
|
|||
|
|||
|
I've been working on this for some time and still can't get it to work. Thanks for all those who have helped me over the past week. Here is the important page, to an ecard script, that calls back the card. The card receiver clicks a link in their email and go to this page:
<html> <head> <Title>Your ecard from Alaskan Central</title> </head> <body> <div align="center"> <h3>Your ecard from Alaskan Central</h3> </div align> <?php $db = @mysql_connect("localhost", "alask**", "**********"); mysql_select_db("alask**_mydb", $db); $card_id = $HTTP_GET_VARS["ID"]; //card id passed from url $sql = "SELECT * FROM ecard WHERE sid = '$card_id'"; // sql statement to retrieve the specific card if ($row = mysql_fetch_array($result)) { echo "<div align='center'> "; echo "<h1><b>Here is your ecard from</b></h1>"; echo $row["s_name"]; echo "<br>"; echo $row["image"]; echo "<br>"; echo $row["message"]; echo "</div>"; } else { echo "<h1><b>There was no card found with the card ID that was passesd</b></h1><br>\n"; exit; //if no row die } ?> <a href="ecardphoto.php">Go Back Here!</a> </body> </html> Their unique ecard page is the "card_id" but listed in my db as "sid". I am concerned about the HTTP_GET_VARS["ID"] statement, since I havn't seen it used before... This script returns an error : Warning: Supplied argument is not a valid MySQL result resource in /home/alaskanc/public_html/php/viewcard.php on line 10 and it is not calling the id at all. Any help, greatly appreciated.
__________________
bow wow! |
|
#2
|
|||
|
|||
|
change this line
$sql = "SELECT * FROM ecard WHERE sid = '$card_id'"; with this $sql = "SELECT * FROM ecard WHERE sid=$card_id"; and tell me what happens |
|
#3
|
|||
|
|||
|
the update
Baxxly posted the one I'm working from but she left out alot of the script, the db, and the view page.
Here are three pages that make up the card: ecardform.php <?php session_start(); session_register("image"); ?> <HTML> <CENTER> <IMG SRC="<?echo $image;?>"> // echoed from a page prior with two images to choose from </CENTER> <form action="sendcard.php" method=GET> Your Name: <input type=text name=s_name size=25 maxlength=50> <?escapeshellcmd($s_name);?> <p> Your Email Address: <input type=text name=s_email size=25 maxlength=50><?escapeshellcmd($s_email);?> <p> Receiver's Name: <input type=text name=r_name size=25 maxlength=50> <?escapeshellcmd($r_name);?> <p> Receiver's Email Address: <input type=text name=r_email size=25 maxlength=50> <?escapeshellcmd($r_email);?> <p> Your Personal Message:<BR> <TEXTAREA name=message cols=50 rows=5 wrap></TEXTAREA> <?escapeshellcmd($message);?> <P> <input type=submit value="Send my card!"> <input type=reset value="Clear it"> </form> </html> This is the sendcard.php page: <html> <body> <?php session_start(); function CreateID($length=16){ $Pool = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; $Pool .= "1234567890aquarian"; for($index = 0; $index < $length; $index++){ $sid .= substr($Pool,(rand()%(strlen($Pool))), 1); } return($sid); } $sid = CreateID(); $db = mysql_connect("localhost", "alwaystellthetruth", "cabbage"); mysql_select_db("alwaystellthetruth_mydb", $db); $result = mysql_query("INSERT INTO ecard VALUES('$sid', '$s_name', '$s_email','$r_name', '$r_email','$message', '$image')"); if(!$result){ $sid = CreateID(); $result = mysql_query("INSERT INTO ecard VALUES('$sid', '$s_name', '$s_email','$r_name', '$r_email','$message', '$image')"); } $mailTo = "$r_email"; $mailSubject = "You Have An E-Card!"; $mailHeader = "From: $s_name"; $message = "You lucky person, you! Someone has thought of you in a warm and fuzzy way and sent you an Alaskan Central e-card! You can view this card at the following webpage: "; $message .= "http://www.alaskancentral.com/php/viewcard.php?ID="; $message .= $sid; mail($mailTo, $mailSubject, $message, $mailHeader); session_destroy(); ?> </body> </html> Note: this ID at the end of the url will appear when the email is sent, unique, and placed into my db just as it should be, but I can't seem to call it back... Last page, the viewcard.php: <html> <head> <Title>Your ecard from Alaskan Central</title> </head> <body> <div align="center"> <h3>Your ecard from Alaskan Central</h3> </div align> <?php $db = @mysql_connect("localhost", "alwaystellthetruth", "cabbage"); mysql_select_db("alwaystellthetruth_mydb", $db); $card_id = $HTTP_GET_VARS["ID"]; //card id passed from url $sql = "SELECT * FROM ecard WHERE sid =$card_id"; // sql statement to retrieve the specific card if ($row = mysql_fetch_array($result)) { echo "<div align='center'> "; echo "<h1><b>Here is your ecard from</b></h1>"; echo $row["s_name"]; echo "<br>"; echo $row["image"]; echo "<br>"; echo $row["message"]; echo "</div>"; } else { echo "<h1><b>There was no card found with the card ID that was passesd</b></h1><br>\n"; exit; //if no row die } ?> <a href="ecardphoto.php">Go Back Here!</a> </body> </html> This page seems to the the key to all of this. I play around with it but can't seem to get it to select from the correct row. My table looks like this: all fields, first being the sid varchar (16) not auto_increment since I am assigning id's, the rest are varchar except for the image which is a blob. Do you know if the images need to exist in the db or can it be called from the server, like html? If you could give me some pointers, I'd appreciate it. I want to do so much, just hard to learn when I know no one ( literaly ) no one here in Alaska who does this. Thanks. |
|
#4
|
|||
|
|||
|
I think the problem lies with the fact that your SID column is of VARCHAR type. If I was designing this system I'd probably make this an INT field. Anyway your query should look like this in viewcard.php:
PHP Code:
Since the SID field is a VARCHAR you need single quotes around it. That may solve the problem. |
|
#5
|
|||
|
|||
|
I can change the db type, no prob. but I've tried the single quotes several times.
I think the problem is with the $http_get_vars["ID"] this is code I was sent by a helpful person, but I am unsure about it. I saw it used in another forum and the author's coments seemed to be that he/she didn't advocate using it... How do others pull the ID from a url like this, or another way to pass it on... that is the key to this whole thing. |
![]() |
| Viewing: Dev Articles Community Forums > Programming > General Programming Help > trying to call id from url, having trouble stilll |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|