Computer Webmaster Gaming Console Graphics Forum

Welcome to the Computer Webmaster Gaming Console Graphics Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.

MK PitStop Main Earn $25 Earn Money Posting Extras Members Blogs Image Hosting User Pages
Go Back   Computer Webmaster Gaming Console Graphics Forum > Webmaster Forum > Website Coding > PHP
Register FAQ/Rules Become A V.I.P. Member Search Today's Posts Mark Forums Read

PHP PHP for some can be one of the hardest website programming codes, so do you need help on your PHP script, if it is php4, php5 or lower this is the place for you for any PHP help.

Google
Closed Thread
 
LinkBack Thread Tools Display Modes
Old 07-01-2007, 5:04 PM   #1
Jeffrey Ellis
 
Jeffrey Ellis's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default If Statement not working

Hi, All--

I have the following statement in my script, which is a simple script to
lookup data from a mysql database:

I have several fields in the database, and valid and contact_sales are the
last two.

This statement is at the end of script and is failing, but I don't know why.
Instead of die, it just goes on and gives the information in the row.


if(valid == "Invalid" || contact_sales == "1")

die("There is a problem with your request. Please contact Sales at:
sales@mysite.com");

$row = mysql_fetch_row($result);
echo $row[3]


As well...I am having another problem with this script. I know how to get
the information from 1 column as above, but I don't know how to display the
entire row. Is there a way to do this?

All My Best,
Jeffrey



 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Advertisements
Old 07-01-2007, 5:04 PM   #2
E-Star
 
E-Star's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default If Statement not working

In article <BB5DDAC0.5566F%support@groundlevel.net>, Jeffrey Ellis
<support@groundlevel.net> wrote:

> Hi, All--
>
> I have the following statement in my script, which is a simple script to
> lookup data from a mysql database:
>
> I have several fields in the database, and valid and contact_sales are the
> last two.
>
> This statement is at the end of script and is failing, but I don't know why.
> Instead of die, it just goes on and gives the information in the row.
>
>
> if(valid == "Invalid" || contact_sales == "1")
>
> die("There is a problem with your request. Please contact Sales at:
> sales@mysite.com");
>


try putting in brackets {}

> $row = mysql_fetch_row($result);
> echo $row[3]
>
>
> As well...I am having another problem with this script. I know how to get
> the information from 1 column as above, but I don't know how to display the
> entire row. Is there a way to do this?
>


Make sure your sql query calls all the colums you want. I think that
mysql_fetch_row should work fine, however I use mysql_fetch_assoc.


> All My Best,
> Jeffrey
>
>
>

 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Old 07-01-2007, 5:04 PM   #3
Tom Thackrey
 
Tom Thackrey's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default If Statement not working



On 11-Aug-2003, Jeffrey Ellis <support@groundlevel.net> wrote:

> I have the following statement in my script, which is a simple script to
> lookup data from a mysql database:
>
> I have several fields in the database, and valid and contact_sales are the
> last two.
>
> This statement is at the end of script and is failing, but I don't know
> why.
> Instead of die, it just goes on and gives the information in the row.
>
>
> if(valid == "Invalid" || contact_sales == "1")
>
> die("There is a problem with your request. Please contact Sales at:
> sales@mysite.com");
>
> $row = mysql_fetch_row($result);
> echo $row[3]
>
>
> As well...I am having another problem with this script. I know how to get
> the information from 1 column as above, but I don't know how to display
> the
> entire row. Is there a way to do this?


Add the leading $ to the variable names in your if
if ($valid == 'Invalid' || $contact_sales == '1')

You were actually getting column 4. You can get the data from the $row array
by the column name, too. $row['valid'] or $row['contact_sales'], for
example.

If you want to use the column names as variables, you can use the extract
function to copy the variables from the array $row into their scalar
variable values, for example
extract($row);
would create variables $valid and $contact_sales and any other row names
returned by the SQL select.

as for displaying the entire contents of each row:
echo '<table>';
while ($row = mysql_fetch_row($result))
{
while (list($key,$value) = each($row))
{
echo '<td>',$value,'</td>';
}
echo '</tr>';
}
echo '</table>';

I suspect some of this is new to you. I suggest reading the following
http://www.php.net/manual/en/function.extract.php
http://www.php.net/manual/en/function.each.php
http://www.php.net/manual/en/function.list.php
http://www.php.net/manual/en/ref.mysql.php
http://www.php.net/manual/en/language.variables.php
study the examples, everything you asked about is there.

--
Tom Thackrey
www.creative-light.com
 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Old 07-01-2007, 5:04 PM   #4
Jeffrey Ellis
 
Jeffrey Ellis's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default If Statement not working


in article Ro0_a.717$eK7.343@newssvr25.news.prodigy.com, Tom Thackrey at
tomnr@creative-light.com wrote on 8/12/03 12:09 AM:

>
>
> On 11-Aug-2003, Jeffrey Ellis <support@groundlevel.net> wrote:
>
>> I have the following statement in my script, which is a simple script to
>> lookup data from a mysql database:
>>
>> I have several fields in the database, and valid and contact_sales are the
>> last two.
>>
>> This statement is at the end of script and is failing, but I don't know
>> why.
>> Instead of die, it just goes on and gives the information in the row.
>>
>>
>> if(valid == "Invalid" || contact_sales == "1")
>>
>> die("There is a problem with your request. Please contact Sales at:
>> sales@mysite.com");
>>
>> $row = mysql_fetch_row($result);
>> echo $row[3]
>>
>>
>> As well...I am having another problem with this script. I know how to get
>> the information from 1 column as above, but I don't know how to display
>> the
>> entire row. Is there a way to do this?

>
> Add the leading $ to the variable names in your if
> if ($valid == 'Invalid' || $contact_sales == '1')


Hi, Tom--

I thought variables were just for stored information from the form? In any
case, I did try using $ for the if statement and it is still failing.

>
> You were actually getting column 4. You can get the data from the $row array
> by the column name, too. $row['valid'] or $row['contact_sales'], for
> example.
>
> If you want to use the column names as variables, you can use the extract
> function to copy the variables from the array $row into their scalar
> variable values, for example
> extract($row);
> would create variables $valid and $contact_sales and any other row names
> returned by the SQL select.
>
> as for displaying the entire contents of each row:
> echo '<table>';
> while ($row = mysql_fetch_row($result))
> {
> while (list($key,$value) = each($row))
> {
> echo '<td>',$value,'</td>';
> }
> echo '</tr>';
> }
> echo '</table>';


Thanks, I'll try that!

>
> I suspect some of this is new to you. I suggest reading the following
> http://www.php.net/manual/en/function.extract.php
> http://www.php.net/manual/en/function.each.php
> http://www.php.net/manual/en/function.list.php
> http://www.php.net/manual/en/ref.mysql.php
> http://www.php.net/manual/en/language.variables.php
> study the examples, everything you asked about is there.


Yes, I've been reading them...

Okay, I have also now been told that the error handling in the script is not
working ( The if statement?) so that my web page is not displaying properly
all the html after this script.

This is what comes before and just after the script. Specifically what is
happening is that my rollover graphics, which actually come before the php
script, are not loading. In the following, only one of the buttons is
shown...

<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="top" width="149"
background="images/left-buttonbkg.gif"><a onmouseover="changeImages(
/*CMP*/'button_home_up',/*URL*/'images/button-home-down.gif');return true"
onmouseout="changeImages(
/*CMP*/'button_home_up',/*URL*/'images/button-home-up.gif');return true"
href="http://mysite.net/index.shtml"><img src="images/button-home-up.gif"
alt="" name="button_home_up" width="149" height="40" border="0"></a><br>
<br>
<br>
<br>
<br>
</td>
<td valign="top">
<div align="center">
<table width="100%" border="0" cellspacing="0"
cellpadding="10">
<tr>
<td bgcolor="white">
<div class="evenbigger">
<p class="evenbigger"><span
class="evenbigger"><b>Registration Lookup</b><br>
<br>
</span></p>
<?php

if(empty($email) || empty($lastFour) )


This is the section at the end of the script:


$result = mysql_query($dbQuery) or die("Couldn't get file list");
if($valid == "Invalid" || $contact_sales == "1")

die("There is a problem with your request. Please contact Sales at:
sales@mysite.net");

$row = mysql_fetch_row($result);
?>
<b>Here is Your Registration Code:</b>
<?
echo $row[3]

?>

</div>
</td>
</tr>
</table>
</div>
</td>
<td valign="top" width="195"
background="images/right-textbkg.gif">
<table width="100%" border="0" cellspacing="0"
cellpadding="10">



All My Best,
Jeffrey




 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Featured Websites
Free Space
Free Space
Free Space Free Space
Closed Thread
Tags: ,




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Find out key from Insert Statement Erland Sommarskog PHP 0 07-01-2007 3:17 PM
Include statement RA HTML 4 07-01-2007 1:45 PM
[Newby] help on a statement with both GROUP_CONCAT and JOIN clauses Stefano Bragaglia Database 0 06-10-2007 12:25 AM
HOW TO : concat text fields using a GROUP BY statement ? Fred Database 1 05-31-2007 8:41 PM
2 where clause in same statement Mysql 4.2 Xavier Houppertz Database 3 05-31-2007 8:40 PM


Featured Websites




All times are GMT +1. The time now is 12:14 AM.


Powered by: vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.0.0
Cheap Computers
MK PitStop Copyright 2005 - 2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98