473,320 Members | 1,947 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

I am going out of my mind, select * from not working.

117 100+
Man i am getting a tumor over this. Ok this morning i noticed my game page was all messed up.
I moved my site to a new server banner less :) it was all ok last night but now hell.

So i re did the code and cleaned it up but now it dont work at all.
It selects the box art but thats it!
I know its sending the itemid because in the url it shows it.
item.php?itemid=2

[PHP]<?
$itemid = $_REQUEST['itemid'];
$sql = "select d.title, d.directions, d.gameinfo, d.hits, d.rating, d.userid, c.category, d.gamerating, d.publisher, d.genar, d.screenshots from items d, categories c where d.itemid = $itemid and c.categoryid = d.categoryid";
$result = mysql_query($sql ,$db);

$pagetitle = $myrow["title"];
$directions = $myrow["directions"];
$gameinfo = $myrow["gameinfo"];
$hits = $myrow["hits"];
$itemrating = $myrow["rating"];
$userid = $myrow["userid"];
$category = $myrow["category"];
$gamerating = $myrow["gamerating"];
$publisher = $myrow["publisher"];
$genar = $myrow["genar"];
$screenshots = $myrow["screenshots"];
$username = "Admin";

if ($userid != 0) {

$sql = "select login from users where userid = $userid";
$result = mysql_query($sql ,$db);
$username = $myrow["login"];
}
$hits++;
$sql = "update items set hits = $hits where itemid = $itemid";
$result = mysql_query($sql ,$db);

if ($ratevalue) {

$ratecount = 0;
$ratetotal = 0;

$ip = getenv(remote_addr);

$sql = "select * from ratings where itemid = $itemid and ip = '$ip'";

$result = mysql_query($sql ,$db);

if ($myrow = mysql_fetch_array($result)) {
$ratemsg = "<font color='#FF0000' size='1'>Error:</font> <font size='1'>You have already rated this item</font>";
} else {
$sql = "insert into ratings (itemid, rating, ip) values ($itemid, $ratevalue, '$ip')";
$result2 = mysql_query($sql ,$db);

$sql = "select rating from ratings where itemid = $itemid";

$result3 = mysql_query($sql ,$db);

if ($myrow2 = mysql_fetch_array($result3)) {

do {
$ratetotal = $ratetotal + $myrow2["rating"];
$ratecount++;
}
while ($myrow2 = mysql_fetch_array($result3)); {

}

}

$newrate = $ratetotal / $ratecount;

$sql = "update items set rating = $newrate where itemid = $itemid";

$result4 = mysql_query($sql ,$db);

$ratemsg = "<font size='1'>Thank you for rating this $itemlower</font>";

}

$itemrating = $newrate;

}
?>[/PHP]
Sep 16 '07 #1
16 1830
pbmods
5,821 Expert 4TB
Heya, Breana.

What do you want your code to do? Give an example.
What is your code doing that you don't want it to do? Give an example.
What is your code *not* doing that it is supposed to? Give an example.
Sep 16 '07 #2
Breana
117 100+
Sorry, it used to get the info by the id=2 and on my page i have code echo it.

[PHP]Game Name: <?php printf($pagetitle); ?>
CATEGORY: <?php printf($category); ?>
[/PHP]
and so on, but it acts like it dont even get the info now?

Just comes out empty...
I find it strange over night not toutching it it just dies.... how?
Sep 16 '07 #3
pbmods
5,821 Expert 4TB
Heya, Breana.

Did you move your MySQL database over as well? Do you need to change your database connection parameters (Username, password, etc.)? Did you set up permissions for your MySQL Username to access your database?

Try adding this line below your mysql_query():
Expand|Select|Wrap|Line Numbers
  1. echo mysql_error();
  2.  
to see what's going on.
Sep 16 '07 #4
Breana
117 100+
Duh of course i did lol i aint blond, i dont get it..

i did the error thingie:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1

I just looked and i put a " by misteak lol.

But nothing shows up now and still no info...
Sep 16 '07 #5
pbmods
5,821 Expert 4TB
Heya, Breana.

See if your script is generating any errors.

P.S., just for you
Sep 17 '07 #6
Breana
117 100+
Thanx for the post, man i am going to cry here...
It says this now.

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
Notice: Undefined variable: myrow in /home/breana/public_html/item.php on line 14

Notice: Undefined variable: myrow in /home/breana/public_html/item.php on line 15

Notice: Undefined variable: myrow in /home/breana/public_html/item.php on line 16

Notice: Undefined variable: myrow in /home/breana/public_html/item.php on line 17

Notice: Undefined variable: myrow in /home/breana/public_html/item.php on line 18

Notice: Undefined variable: myrow in /home/breana/public_html/item.php on line 19

Notice: Undefined variable: myrow in /home/breana/public_html/item.php on line 20

Notice: Undefined variable: myrow in /home/breana/public_html/item.php on line 21

Notice: Undefined variable: myrow in /home/breana/public_html/item.php on line 22

Notice: Undefined variable: myrow in /home/breana/public_html/item.php on line 23

Notice: Undefined variable: myrow in /home/breana/public_html/item.php on line 24

Notice: Undefined variable: ratevalue in /home/breana/public_html/item.php on line 37
Sep 17 '07 #7
pbmods
5,821 Expert 4TB
Heya, Breana.

Looks like there's something funny going on with your MySQL query.

What's your SQL query look like?
Sep 17 '07 #8
Breana
117 100+
Oh god, look at my url...
Its hell opened up and ate my site...

http://911gamerz.exofire.net/item.php?itemid=2

um.. you mean this:
Expand|Select|Wrap|Line Numbers
  1. $result = mysql_query($sql ,$db);
I placed my old item.php before i changed the code and its better not a lot but sone lots of error please help me fix this i dont understand undefined ?
Sep 17 '07 #9
Breana
117 100+
line 131 - last error...
Why is it undefined?

[PHP]
if ($ratevalue) {

$ratecount = 0;
$ratetotal = 0;

$ip = getenv(remote_addr);

$sql = "select * from ratings where itemid = $itemid and ip = '$ip'";

$result = mysql_query($sql ,$db);

if ($myrow = mysql_fetch_array($result)) {
$ratemsg = "<font color=\"#FF0000\" size=\"1\">Error:</font> <font size=\"1\">You have already rated this item</font>";
} else {
$sql = "insert into ratings (itemid, rating, ip) values ($itemid, $ratevalue, '$ip')";
$result2 = mysql_query($sql ,$db);

$sql = "select rating from ratings where itemid = $itemid";

$result3 = mysql_query($sql ,$db);

if ($myrow2 = mysql_fetch_array($result3)) {

do {
$ratetotal = $ratetotal + $myrow2["rating"];
$ratecount++;
}
while ($myrow2 = mysql_fetch_array($result3)); {

}

}

$newrate = $ratetotal / $ratecount;

$sql = "update items set rating = $newrate where itemid = $itemid";

$result4 = mysql_query($sql ,$db);

$ratemsg = "<font size=\"1\">Thank you for rating this $itemlower</font>";

}

$itemrating = $newrate;

}[/PHP]
Sep 17 '07 #10
Breana
117 100+
It keeps yelling at me about this line of code:
Expand|Select|Wrap|Line Numbers
  1. if ($ratevalue) {
Why is it a Undefined variable?
Do i need to ad a definition to it...

If i change it to this:
Expand|Select|Wrap|Line Numbers
  1. if ($ratevalue = 0)
  2. {
It goes away and load the info.. but that does 0 mean...
Sep 17 '07 #11
pbmods
5,821 Expert 4TB
Heya, Breana.

Try changing it to:
Expand|Select|Wrap|Line Numbers
  1. if( ! empty($ratevalue) )
  2. {
  3.  
Sep 17 '07 #12
Breana
117 100+
Ok that works:
Expand|Select|Wrap|Line Numbers
  1.       if( ! empty($ratevalue) )
  2.       {
  3.  
But it disables the other code, like if already voted error. and so on...
When i hit vote it used to say thanks, or sorry you already voted!
But now nothing..

So should i remove the if statment and make it better?
Sep 17 '07 #13
Breana
117 100+
How can i fix this anyone?
Please help.... :(

Why is it now defined..

[PHP]if ($ratevalue)
{

$ratecount = 0;
$ratetotal = 0;

$ip = getenv(remote_addr);

$sql = "select * from ratings where itemid = $itemid and ip = '$ip'";

$result = mysql_query($sql ,$db);

if ($myrow = mysql_fetch_array($result)) {
$ratemsg = "<font color=\"#FF0000\" size=\"1\">Error:</font> <font size=\"1\">You have already rated this item</font>";
} else {
$sql = "insert into ratings (itemid, rating, ip) values ($itemid, $ratevalue, '$ip')";
$result2 = mysql_query($sql ,$db);

$sql = "select rating from ratings where itemid = $itemid";

$result3 = mysql_query($sql ,$db);

if ($myrow2 = mysql_fetch_array($result3)) {

do {
$ratetotal = $ratetotal + $myrow2["rating"];
$ratecount++;
}
while ($myrow2 = mysql_fetch_array($result3)); {

}

}

$newrate = $ratetotal / $ratecount;

$sql = "update items set rating = $newrate where itemid = $itemid";

$result4 = mysql_query($sql ,$db);

$ratemsg = "<font size=\"1\">Thank you for rating this $itemlower</font>";

}

$itemrating = $newrate;

}[/PHP]
Sep 17 '07 #14
Breana
117 100+
Well i give up, its late i am tired thax anyway... :(
Sep 17 '07 #15
pbmods
5,821 Expert 4TB
Heya, Breana.

I don't see where you define 'ratevalue' anywhere in your code. It seems that it will always be unset, so the code inside the conditional will never execute.

Did you mean to use $_GET['ratevalue'] or $_POST['ratevalue']?
Sep 17 '07 #16
Breana
117 100+
Ok, let me explane it better.
The form rate game is on the item.php, when you choose vote and hit send it posts the info to the item.php and the sql here is supost to eather send it if you havent voted allready thats why it checks for your ip.

And eather says:
Thanks, and records your ip or it says error.

But it just dont want to do it now for some reason it says undefined?
So how do i define it, below is all the elements i used.

Form id:
[PHP]<form action="item.php" method="post" name="vote" id="vote">
<input type="hidden" name="itemid" value="<?php printf($itemid) ?>" />

<input type="radio" name="ratevalue" value="5" onClick="this.form.submit();" />AWESOME&nbsp;
<input type="radio" name="ratevalue" value="4" onClick="this.form.submit();" /> GOOD&nbsp;
<input type="radio" name="ratevalue" value="3" onClick="this.form.submit();" />AVERAGE&nbsp;
<input type="radio" name="ratevalue" value="2" onClick="this.form.submit();" />POOR&nbsp;
<input type="radio" name="ratevalue" value="1" onClick="this.form.submit();" />
BAD</form>[/PHP]

SQL code:
[PHP]<?
if($ratevalue)
{

$ratecount = 0;
$ratetotal = 0;

$ip = getenv(remote_addr);

$sql = "select * from ratings where itemid = $itemid and ip = '$ip'";

$result = mysql_query($sql ,$db);

if ($myrow = mysql_fetch_array($result)) {
printf("<font color='#FF0000' size='1'>Error:</font> <font size='1'>You have already rated this item</font>");
} else {
$sql = "insert into ratings (itemid, rating, ip) values ($itemid, $ratevalue, '$ip')";
$result2 = mysql_query($sql ,$db);

$sql = "select rating from ratings where itemid = $itemid";

$result3 = mysql_query($sql ,$db);

if ($myrow2 = mysql_fetch_array($result3)) {

do {
$ratetotal = $ratetotal + $myrow2["rating"];
$ratecount++;
}
while ($myrow2 = mysql_fetch_array($result3)); {

}

}

$newrate = $ratetotal / $ratecount;

$sql = "update items set rating = $newrate where itemid = $itemid";

$result4 = mysql_query($sql ,$db);

printf("<font size='1'>Thank you for rating this $itemlower</font>");

}

$itemrating = $newrate;

}
?>[/PHP]

And it used to work, if at all possible i would like help making it better :)
Sep 17 '07 #17

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: The Lone Wolf | last post by:
hi, i'm new to php mysql and already have a problem with a simple routine $result=mysql_db_query(jcorp,"select count(*) as bar from users"); $count = mysql_result($result,0,"bar"); //<<<<<...
11
by: Arthur T. Murray | last post by:
Now, suppose that you wanted to write an AI in Python that would implement your mind-model and allow it to grow, mutate, develop. Here is one possible scenario. It would not be necessary to do...
5
by: malcolm | last post by:
Example, suppose you have these 2 tables (NOTE: My example is totally different, but I'm simply trying to setup the a simpler version, so excuse the bad design; not the point here) CarsSold {...
7
by: Nick Zdunic | last post by:
I have a remotable object running in my host application. The host starts up and creates the object. Within a method to start the remote object doing its thing it creates an object. ...
11
by: reciprocity85 | last post by:
Hello all. I have a question about what you all get paid, and what I should expect in my situation. I googled quite a bit, but not come up with any benchmarks definite enough that I would want...
132
by: Kevin | last post by:
I don't know if I should even start this topic but here goes. I'm an ex vb6 developer, now developing in C#. The reason why I started developing in C# is because the company that I worked for at...
2
by: Deac | last post by:
I have two Access 2003 tables, one has a "Zone" and "Lot1SqFt" that changes with each record. (8,000+ records) A portion of this table: CustomerID ZONE Lot1SqFt SqFtPrice ...
22
by: Rickster66 | last post by:
As Instructed this is a new thread regarding my original post: "Select Only 10 Columns Going Back" I'm sorry for the late response. I've been gathering up information and carefully with as much...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.