PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
cap2cap10
Forum Contributor
Posts: 158 Joined: Mon Apr 14, 2008 11:06 pm
Post
by cap2cap10 » Sun Sep 21, 2008 11:08 am
greetings php technorati, my check script is not working. no error, it just does absolutely nothing, as if it does not exist on the page. Here is the script:
Code: Select all
<?php
$userID = $_SESSIONS['js_login']['userID'];
$prof_stat = $_SESSIONS['js_profile']['prof_stat'];
$res_stat = $_SESSIONS['js_resume']['res_stat'];
$pic_stat = $_SESSIONS['js_resume']['pic_stat'];
$file_stat = $_SESSIONS['js_resume']['file_stat'];
if ($prof_stat == " ")
{
if ($res_stat == " ")
{
if ($pic_stat == " ")
{
if ($file_stat == " ")
{
echo "<a href=upload_profile.php><img src=images/credit-cards-logo.gif width=182 height=83 alt=Please upload your Profile! border=1></a>";
}
elseif ($prof_stat == "yes")
{
if ($res_stat == " ")
{
if ($pic_stat == " ")
{
if ($file_stat == " ")
{
echo "<a href=upload_resume_1.php><img src=images/credit-cards-logo.gif width=182 height=83 alt=Please upload your Resume! border=1></a>";
}
elseif ($prof_stat == "yes")
{
if ($res_stat == "yes")
{
if ($pic_stat == " ")
{
if ($file_stat == " ")
{
echo "<a href=upload_pic.php><img src=images/credit-cards-logo.gif width=182 height=83 alt=Please upload your Photo! border=1></a>";
}
elseif ($prof_stat == "yes")
{
if ($res_stat == "yes")
{
if ($pic_stat == "yes")
{
if ($file_stat == " ")
{
echo "<a href=upload_file.php><img src=images/credit-cards-logo.gif width=182 height=83 alt=Please upload your Files! border=1></a>";
}
elseif ($prof_stat == "yes")
{
if ($res_stat == "yes")
{
if ($pic_stat == "yes")
{
if ($file_stat == "yes")
{
echo "<img src=images/credit-cards-logo.gif width=182 height=83 alt=Please activate your Portfolio! border=1>";
}
}
}
}}}}}}}}}}}}}
?>
Ok what did I do wrong this time. It is probably something simple.
thanks in advance,
Batoe
yacahuma
Forum Regular
Posts: 870 Joined: Sun Jul 01, 2007 7:11 am
Post
by yacahuma » Sun Sep 21, 2008 4:08 pm
Before even trying to understand what you are trying to do. Have you heard of "and" operator (&&).
if ($a==1 && $b==1 && $c==1)
cap2cap10
Forum Contributor
Posts: 158 Joined: Mon Apr 14, 2008 11:06 pm
Post
by cap2cap10 » Sun Sep 21, 2008 9:33 pm
thanks; what I am trying to do is to check MySQL fields for a value (Yes or no data) using sessions and then to post a graphic depending on the values present in the MySQL fields. I was testing to see if the script will perform this task.
I added in the && and this is the new code:
Code: Select all
<?php
$userID = $_SESSIONS['js_login']['userID'];
$prof_stat = $_SESSIONS['js_profile']['prof_stat'];
$res_stat = $_SESSIONS['js_resume']['res_stat'];
$pic_stat = $_SESSIONS['js_resume']['pic_stat'];
$file_stat = $_SESSIONS['js_resume']['file_stat'];
if ($prof_stat == " " && $res_stat == " " && $pic_stat == " " && $file_stat == " ")
{
echo "<a href=upload_profile.php><img src=images/credit-cards-logo.gif width=182 height=83 alt=Please upload your Profile! border=1></a>";
}
elseif ($prof_stat == "yes" && $res_stat == " " && $pic_stat == " " && $file_stat == " ")
{
echo "<a href=upload_resume_1.php><img src=images/credit-cards-logo.gif width=182 height=83 alt=Please upload your Resume! border=1></a>";
}
elseif ($prof_stat == "yes" && $res_stat == "yes" && $pic_stat == " " && $file_stat == " ")
{
echo "<a href=upload_pic.php><img src=images/credit-cards-logo.gif width=182 height=83 alt=Please upload your Photo! border=1></a>";
}
elseif ($prof_stat == "yes" && $res_stat == "yes" && $pic_stat == "yes" && $file_stat == " ")
{
echo "<a href=upload_file.php><img src=images/credit-cards-logo.gif width=182 height=83 alt=Please upload your Files! border=1></a>";
}
elseif ($prof_stat == "yes" && $res_stat == "yes" && $pic_stat == "yes" && $file_stat == "yes")
{
echo "<img src=images/credit-cards-logo.gif width=182 height=83 alt=Please activate your Portfolio! border=1>";
}
?>
I still can't get it to post one image. Anyone know what I am doing wrong?
Batoe
yacahuma
Forum Regular
Posts: 870 Joined: Sun Jul 01, 2007 7:11 am
Post
by yacahuma » Mon Sep 22, 2008 9:11 am
you say " mysql fields", are you getting data from mysql and put it it in sessions?
Is your data going to have blanks ? " "
When I check for empty I use strlen(trim($var))
Also, print your data, to see what you have
cap2cap10
Forum Contributor
Posts: 158 Joined: Mon Apr 14, 2008 11:06 pm
Post
by cap2cap10 » Mon Sep 22, 2008 12:22 pm
How do I check for empty fields in Mysql using the userID(primary key)? Meaning If there is no userID in a table and there is one in another table, this will mean that the user has not submitted data to that table yet. If that is the case then I want to echo a link to a form for the user to upload data. This is the essence of what I am trying to accomplish.
Batoe
yacahuma
Forum Regular
Posts: 870 Joined: Sun Jul 01, 2007 7:11 am
Post
by yacahuma » Mon Sep 22, 2008 1:49 pm
if you do a select by user id on a table, you are supposed to check if you actually go something back. At that point you know that the user does not exists. You DO NOT check for empty fields in this case.