General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old April 15th, 2002, 04:04 PM
littleblackdog littleblackdog is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Location: Anchorage
Posts: 118 littleblackdog User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 17
Question trying to call id from url, having trouble stilll

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!

Reply With Quote
  #2  
Old April 16th, 2002, 02:50 AM
Ben Rowe
Guest
Dev Articles Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
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

Reply With Quote
  #3  
Old April 16th, 2002, 03:04 AM
littleblackdog littleblackdog is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Location: Anchorage
Posts: 118 littleblackdog User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 17
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.

Reply With Quote
  #4  
Old April 16th, 2002, 06:56 AM
anthony_irl anthony_irl is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Location: Ireland
Posts: 13 anthony_irl User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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:
 $sql "SELECT * FROM ecard WHERE sid='$card_id'"


Since the SID field is a VARCHAR you need single quotes around it. That may solve the problem.

Reply With Quote
  #5  
Old April 16th, 2002, 12:03 PM
littleblackdog littleblackdog is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Location: Anchorage
Posts: 118 littleblackdog User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 17
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.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > trying to call id from url, having trouble stilll


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap