MDanz 0 Junior Poster

I just installed wamp, so i can test my website offline. Now i get numerous Undefined index or Undefined variable errors, which i know how to fix. Now logging in works online but with wamp it doesn't work. The code isn't wrong. I imported the database online to offline. I've pin pointed what is wrong but don't know how to solve it.

here is the code where i test if the login details are correct.

$Blowfish_Pre = '$2a$05$';
$Blowfish_End = '$';
$hashed_password = crypt($password, $Blowfish_Pre . $salt . $Blowfish_End);

//check to see if they match
if ($username==$dbusername&&$hashed_password==$dbpassword){

Offline the echoed $hashed_password for the account is

$2pozHhRA6bDM

Online the echoed $hashed_password for the account is

$2J7rPSsTYb1Q

I've determined crypt is working differently online than it is offline? I am using the same php version both online and offline(php 5.2.17), Why is this and how can i solve it? I've been stuck on this all day. My website works perfectly online though.

MDanz 0 Junior Poster

I've looked everywhere and haven't found a clear step by step tutorial on how to secure sessions/cookies. Here are snippets of my code, i'd like to know how i can improve on session security to prevent fixation/hijacking and cookie safety. This is snippets of code for the user login system.

login.php

if ($username==$dbusername&&$hashed_password==$dbpassword)
                   {

                        setcookie('username[0]',$username,time()+(60*60*24*365));
                        setcookie('username[1]',$userid,time()+(60*60*24*365));

                        if($admin=='1') {
                            $_SESSION['admin'] = 1;
                        }   

                        $_SESSION['logged-in'] = 1;

                       header( 'Location: ' . $return );


                   }

logout.php

$time = time()-(60*60*24*365);

setcookie('username[0]', '',$time);
setcookie('username[1]', '',$time);
unset($_COOKIE['username']); 
unset($_SESSION['logged-in']);
unset($_SESSION['admin']);

I call session_regenerate_id() on everypage, is that correct to stop session fixation/hijacking?

session_start(); session_regenerate_id(true);

php.ini

session.use_trans_sid = 0
session.user_only_cookies = 1

Can you please tell me what i should do to improve on this? Examples would help greatly.

MDanz 0 Junior Poster

I'm trying to do a query that if mike isn't in the three highest bids for a keyword, then select the row(row that has been outbid). I tried below but i get no results, i should get rows with id 4 and 7. btw a keyword can be bidded on more than once.

$construct = "SELECT * FROM `temp-advertise` WHERE username='mike' AND bid <
                (SELECT min.bid FROM `temp-advertise` min LEFT JOIN `temp-advertise` min2 on min.keyword=min2.keyword WHERE min.username='mike' ORDER BY bid DESC LIMIT 2,1)";


id  | username| keyword | bid   |
   1 |  mike |  one     |  7    |
   2 |  tomm |  one     |  4    |
   3 |  cedr |  one     |  6    |
   4 |  mike |  two     |  1    |
   5 |  tomm |  two     |  5    |
   6 |  harr |  two     |  5    |
   7 |  mike |  one     |  3    |
   8 |  harr |  two     |  3    |

i tried another query and also get no results

$construct = "SELECT child.* FROM `temp-advertise` child LEFT JOIN `temp-advertise` parent on child.keyword=parent.keyword
                WHERE child.username='mike' GROUP BY child.keyword ORDER BY child.bid DESC LIMIT 2,999";
MDanz 0 Junior Poster

Each childrow has a parentid and position. For childrows with the same position there is one row where start='1'.

What i'm trying to do is return the pending rows with their start row.

The results that should be shown are; start(owen) pending(dave,paul). This is because they have the same position. Here is the SQL fiddle http://sqlfiddle.com/#!2/e6e54/1

  id |  name | parentid|  position|  start  |  pending |
   1 |  mike |    0    |    0     |    0    |     0    |
   2 |  dave |    1    |    1     |    0    |     1    | 
   3 |  paul |    1    |    1     |    0    |     1    |
   4 |  john |    1    |    2     |    1    |     0    |
   5 |  bret |    1    |    2     |    0    |     0    |
   6 |  owen |    1    |    1     |    1    |     0    |
   7 |  rick |    1    |    3     |    1    |     0    |
   8 |  jaye |    1    |    3     |    0    |     0    |



    $getquery = mysql_query("select child.*
from `mytable` child inner join `mytable` parent 
on parent.id=child.parentid
inner join `mytable` child2 on child.parentid=child2.parentid
and child2.pending='1'
where child.start='1' ORDER BY child.id DESC");



while($row=mysql_fetch_assoc($getquery)) {

 $name = $row['name'];

echo "<p>Name: $name </p>";

}
MDanz 0 Junior Poster

thanks... i understand. how did you print the tables? It is much easier to understand when i can visually see the data.

MDanz 0 Junior Poster

The query below is correct. It returns the rows `paul` and `rick` because they have the highest rating of the child rows. This was solved for me with the below link. I am having trouble understanding the query. I understand joins, what i don't understand is `t2.rating is null`?

http://sqlfiddle.com/#!2/97e60/2

select t1.* from mytable t1
        left join mytable t2
        on t1.parentid = t2.parentid and t1.rating < t2.rating
        join mytable parents
        on parents.id = t1.parentid
        where t2.rating is null AND parents.name like '%mike%'

`t1.rating < t2.rating` attaches the highest rated values to the LEFT table. I know `t2.rating is null` means t2.rating is false but i have no idea what it is doing in the query? Does that mean it removes from t1 where there isn't a match in the LEFT JOIN query?

my head hurts... the simpler the explanation the better.

MDanz 0 Junior Poster

Ok, as easiest as i can explain.


- There are many child.sid to parent.id
- There are many child.nid to child.sid
- There are many child.id to child.nid


child.id is just the id of a child row. And each row has rating column.

In the query i'm grouping by child.nid. But the results that are being returned are the first entry(lowest child.id) for each nid. What i want is the highest rated child.id for that nid.

$construct =  "SELECT child.* FROM outcomes child 
    JOIN outcomes parent on parent.id=child.sid JOIN    
    WHERE (parent.name LIKE '%$search%') GROUP BY child.nid,child.sid
    ORDER BY child.rating DESC";

I've tried ORDER BY child.rating DESC but this needs to happen before the GROUP BY child.nid.

Any idea how to solve this problem?

MDanz 0 Junior Poster

With the below query I'd get the results one and three. How do I get the results for `sid`; 15 and 17? I can't use a WHERE because I won't know the `sid`.

A better way of explaining is, how do I LIMIT per `sid` without grouping?

mysql_query("SELECT *
             FROM   `mytable`
             GROUP  BY `sid`
             ORDER  BY `sid` ASC
             LIMIT  0, 2");

+----+-----------+----------+
| id |       sid |      num |
+----+-----------+----------+
|  1 |        15 |      one |   
|  2 |        15 |      two |   
|  3 |        17 |    three |   
|  4 |        17 |     four |  
|  5 |        18 |     five |   
|  6 |        18 |      six |
MDanz 0 Junior Poster

I have a large array. Is there an alternate method to check if $value in the array is present in the MySql table vote and if not then insert $value into vote. This is what i am doing currently. Is there a better method?

foreach($rowids as $value) {


        $select = mysql_query("SELECT voteid FROM vote WHERE username='$username' AND voteid='$value' LIMIT 1",$this->connect);

            if(mysql_num_rows($select)==0) {

        $insert = mysql_query("INSERT INTO vote VALUES ('','$value','$username')",$this->connect);

            }
        }
MDanz 0 Junior Poster

where did i go wrong? It should update mysql(insertsubscribe function) and change the image in the anchor tag.

php

$id= $row['id'];

echo "<div class='subscribe'><a id='s$id' href='javascript:subscribe($id);'><img src='/subscribe.jpg' alt='subscribe' /></a></div>";

ajax

function subscribe(number)
{
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    	document.getElementById("s"+number).innerHTML="<img src='/unsubscribe.jpg' alt='unsubscribe' />";
    }
  }
xmlhttp.open("GET","subscribe.php?id="+number,true);
xmlhttp.send();
}

subscribe.php

<?php  session_start();  
include "database.php";

$id = $_GET['id'];

$database = new Database();
$database->opendb();
$database->insertsubscribe($id);
$database->closedb();
   
?>
MDanz 0 Junior Poster

Can i get help correcting the code below? You can just copy and paste and try it yourself. Onmouseover the popup div appears. If i click(X) the popup div should close but it doesn't. Only doubleclicking (X) closes the popup div. Onmouseover it should always display a popup div though.

<html xmlns="http://www.w3.org/1999/xhtml">
<head>

</head>
<style type="text/css">
.container {
display:block;
width:500px;
height:200px;
border:1px solid green;
}
.advert {
float:right;
overflow:hidden;
width:100px;
height:30px;
border:1px solid red;
}
.close {
float:right;
width:20px;
height:28px;
cursor:pointer;
border:1px solid black;
}
</style>
<body>

<div class="container" onmouseover='getad(39);' onmouseout='hidead(39);changeback(39);'>
<div class='advert' id="39"  style="display:none;"><div class="close"><a href="javascript:closead(39)">X</a></div></div>
<input type="text" value="1" id="ad39" />
</div>


<div class="container" onmouseover='getad(40);' onmouseout='hidead(40);changeback(40);'>
<div class='advert' id="40" style="display:none;"><div class="close"><a href="javascript:closead(40)">X</a></div></div>
<input type="text" value="1" id="ad40" />
</div>

<script type="text/javascript">

function getad(number) {
		
	if(document.getElementById('ad'+number).value==1) {
		if(document.getElementById(number).style.display == "none") {
		document.getElementById(number).style.display = "block";
		
		}
	}
	
} 

function hidead(number) {
	
	if(document.getElementById('ad'+number).value==1) {
		if(document.getElementById(number).style.display == "block") {
		document.getElementById(number).style.display = "none";
		
		}
	}
} 

function closead(number) {
	
	document.getElementById('ad'+number).value = 0;
	if(document.getElementById(number).style.display == "block") {
		document.getElementById(number).style.display = "none";
		
		}

	
	
	}

	function changeback(number) {
	
	if(document.getElementById('ad'+number).value==0) {

	
	document.getElementById('ad'+number).value = 1;
	
	}
	}
</script>
</body>
</html>
MDanz 0 Junior Poster

This is a function for a slideshow,onmouseover i want it to stop. Instead of stopping the slideshow onmouseover, it speeds up?? How can i correct this to stop onmouseover?

<body onload="nextslide();">
function nextslide() {

                // Hide current slide
          var object = document.getElementById('slide' + current); //e.g. slide1
          object.style.display = 'none';
             
          // Show next slide, if last, loop back to front
          if (current == last) { current = 1; }
          else { current++ }
          object = document.getElementById('slide' + current);
          object.style.display = 'block';
          var timeout = setTimeout(nextslide, 2500);
		 
			object.onmouseover = function(){ clearTimeout( timeout ) };
object.onmouseout = nextslide;
                                        
       }
MDanz 0 Junior Poster

i tried this code but onmouseover it doesn't stop the the slideshow?

function nextslide() {

		// Hide current slide
          object = document.getElementById('slide' + current); //e.g. slide1
          object.style.display = 'none';
              
          // Show next slide, if last, loop back to front
          if (current == last) { current = 1; }
          else { current++ }
          object = document.getElementById('slide' + current);
          object.style.display = 'block';
	  var timeout = setTimeout(nextslide, 2500);
          object.onmouseover = clearTimeout(timeout);
          object.onmouseout = timeout;		
				
       }
MDanz 0 Junior Poster

tried that and it doesn't work.

MDanz 0 Junior Poster

The width spreads across the whole page, i only want it to be as long as the content in the div. How can i solve this?

<style type="text/css">
.three {
display:block;
width:auto;
height:100px;
position:relative;
border:1px solid black;
}

.three a {
width:100%;
height:100%;
position:absolute;

}

</style>
echo "<div class='three'><a href='two'></a>test</div>";
MDanz 0 Junior Poster
RewriteRule ^user/[A-Za-z0-9-]+)/([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/?$ /profile.php?user=$1&r=$2&page=$3 [L]

this isn't working... i get an internal server error.. if i remove it the page works. Any idea how to fix this?

the url should be like below

http://www.example.com/user/testing/1/1

MDanz 0 Junior Poster

i've done this

RewriteRule ^([A-Za-z0-9-]+)/?$ profile.php?user=$1 [L]

to make

www.example.com/profile.php?user=testing

into

www.example.com/testing

What i'd like to do is change..

www.example.com/profile.php?user=testing

into

www.example.com/user=testing

What is the RewriteRule to accomplish this? Also if i used $_GET with the second clean url would it still work?

MDanz 0 Junior Poster

I've recently used mod_rewrite and changed my .htaccess allowing clean urls. Is there a tutorial that tells me how to use $_GET with a clean url?

for instance how do i get the name with the clean url($_GET method)?

messy url

example.com/play.php?id=203&name=test

clean url

example.com/videos/play/203/test

also when using forms is it as simple as changing

<form action='submit.php' action='get'>

to

<form action='submit' action='get'>

or do i have to do something else?

MDanz 0 Junior Poster

before one there are two single quotes not double quote

$search="q test\\''1";

thanks but the user isn't going to type that in. what would i have to do to change q test'1 to your example?

MDanz 0 Junior Poster
$search = "q test'1";

$search = mysql_real_escape_string($search);

mysql_query("SELECT * FROM test WHERE name='$search' ORDER BY `id` DESC LIMIT 1",$this->connect);

when i echo my select query i get this.

SELECT * FROM test WHERE name='q test\'1' ORDER BY `id` DESC LIMIT 1

in the database i have a row with name = q test\'1

the row isn't being retrieved, What do i have to change to get the query to retrieve the result?

MDanz 0 Junior Poster

?

so...

$search = "q test"yes";

MDanz 0 Junior Poster

try this

SELECT * FROM block WHERE name LIKE '%q test''yes%' ORDER BY id DESC

$search = "q test'yes";

typing out the search term manually won't solve the problem. if the user uses an apostrophe when searching it should fetch results.

MDanz 0 Junior Poster

i'm not getting any results for the query. I'm sure it has something to do with the apostrophe and back slashes

$search = "q test'yes";
$search = mysql_real_escape_string($search);
mysql_query("SELECT * FROM block WHERE name LIKE '%$search%' ORDER BY `id` DESC",$this->connect);

When i echo it out i get this

SELECT * FROM block WHERE name LIKE '%q test\\\'yes%' ORDER BY `id` DESC

is there a solution to this without turning off magic quotes?

MDanz 0 Junior Poster

i'm trying to get a clean url for my about page.

i want to change

http://www.example.com/about.php

to

http://www.example.com/about

i put my htaccess file as this

RewriteEngine On
RewriteBase /
RewriteRule ^(.+)/([0-9]+)/?$ about.php

it's not working though, i get the 404 not found error.

MDanz 0 Junior Poster

Onchange of the dropdown list, the textfield should display either "testing 3" or "testing 4" but nothing is happening.

<form action='submit.php' method='POST' name='form'>
    <select name='preset' onchange='preset(this);'>
       <option value='test1'>testing 1</option>
       <option value=test2'>testing 2</option>
   </select>

<input type='text' name='big[]' value='' />

</form>
function preset(ele) {

if(ele=="test1") {
  var action1 = "testing 3";
} else {
  var action1 = "testing 4";
}

  document.form."big[0]".value = action1;

}
MDanz 0 Junior Poster

have any recommendations on how i would debug over 3000 lines of code for that missing semicolon or curly bracket?

MDanz 0 Junior Poster

I get random Parse error: syntax error, unexpected $end in my code. All i have to do is refresh the page and the error goes away, all is working. When it appears the line is always different and when i examine the line nothing is wrong with the code. This is frustrating because i don't know how to debug it.... It's random.

Has anyone ever experienced this before. For example i got this error randomly..

Parse error: syntax error, unexpected $end in ... on line 3828

$searchterm1 = substr($searchterm, 0, $limitz1) . '..';

believe me there is nothing wrong with that line. When i refresh the error dissapears until a randomly get another parse error $end with a different line.

Any help appreciated.

MDanz 0 Junior Poster

Hello, what do professional web designers do to overcome this problem? Is there a simple solution for png transparency support in ie6? I found a fix but i don't want to buy any license to use some code.

MDanz 0 Junior Poster

My png image with no background works in firefox, chrome etc.. but when it comes to ie6,ie7 i have to use the alphaimageloader filter. What is the common way professionals approach this problem? Websites like twitter the images with no background overlap with no problems when i load them in ie6.. help appreciated.

solution?

MDanz 0 Junior Poster

This code adds a new textarea when i press the "add" button. How do i alter the code so it can remove a textarea.

e.g. i added 4 textarea's but i only intended to add 3, how do i delete the 4th textarea?

<div id='newdiv'>
</div>
<input type='button' onclick='new()' name='add' value='Add' style='font-size:12px;' />
function new() {
var htmlText =  "<div class='container'><textarea name='reason[]' style='font-size: 10px;width:500px; height:50px;' onFocus='if(this.value==\"type more information"\") { this.value=\"\"}'>type more information</textarea></div>"; 
      		
        var newElement = document.createElement('div');
	
        newElement.id = 'new1'; // Give the DIV an ID, if you need to reference it later...
		
	 newElement.innerHTML = htmlText;

     var fieldsArea = document.getElementById('newdiv');
	fieldsArea.appendChild(newElement);

}
MDanz 0 Junior Poster

ok here is a little more information...i'm having a problem, my query should get the result "michael" but instead it returns both results.


name:dave , keywords="test1, test2, test3"

name:michael, keywords="test,test9"

$search="test";
$getfirst =  mysql_query("SELECT * FROM block WHERE keyword LIKE '%$search%' ORDER BY `id` DESC",$this->connect);
MDanz 0 Junior Poster

for example.. in one column it has "test1, test2, test3, test4" .... when i search for test1... i only want rows the word 'test1' in them specifically.

$search = test1

i've tried LIKE %$search% but it get's all rows with the word 'test' in it... i want only rows with the word 'test1' in it.

MDanz 0 Junior Poster

i have a form on submit.php, with method post to the same page($PHP_SELF). If i made a mistake i want to be able to press 'Go Back' to the previous page(same page) and have the values in their textfields.

if(isset($_POST['new'])) {
 <a href='#' onClick='history.go(-1)'>Go Back</a>
}
else {
// form in here

}

The problem is.. it goes back to the page as planned(submit.php?search=test) and then it changes page to submit.php#.

I need to use onclick='history.go(-1)' because the form is made up of text fields, with a button to add more textfields done with javascript.

So if i added 3 textfields and used onclick='history.go(-1)' the 3 textfields will still be there.

MDanz 0 Junior Poster

the variable in the WHERE clause is the result of that WHERE clause. if that sounds confusing. basically the next result in the query is dependent on the previous result. If i used a while loop then i would have to keep on repeating the while loop for every result. With function recursion it repeats it for me.

unless you know a better way than function recursion to loop the below so the result($number) of the query is inputted back into the WHERE clause and repeated.

$get =  mysql_query("SELECT * FROM block WHERE sid='$number'",$this->connect);
								
while($row = mysql_fetch_assoc($get)) {
							
						
	$number = $row['id'];
}
MDanz 0 Junior Poster

the function keeps returning 1. if i echo $i within the function then it counts up to six. the function should return 6, because there are 6 results from the mysql_query, so $i iterates upto 6. please any help solving this?

$i=0;

$thewidth = $database->width($theid, $i);

echo $thewidth;
function width($theid,$i)
{
$get =  mysql_query("SELECT * FROM block WHERE sid='$theid'",$this->connect);
			
$i++;		
						
while($row = mysql_fetch_assoc($get)) {
							
						
	$number = $row['id'];
							
	$this->width($number, $i);
							
	return $i;	 
					
		}  
											
				
}
MDanz 0 Junior Poster

i have two functions. In function two it has $id=9. how do i get function one to echo $id?

how do i adjust the below example to accomplish this?

$newdb = new Database();

class Database
{

function one()
{
$newdb->two();
echo $id;
}

function two() 
{
$id = 9
return $id;
}

}
MDanz 0 Junior Poster

what i'm trying to accomplish is two boxes next to each other inside a div, which i can scroll horizontally to see the two boxes. if you copy the code below it works correctly, only because the width of the parent div is set.

<style type="text/css">


#container {
overflow:scroll;
width:100px;
}

  #parent {
overflow:hidden;
width:400px;
}

.box1 {

border:1px solid black;
float: left;
height: 101px;
width: 101px;
}

</style>

<div id='container'>
<div id='parent'>
<div class='box1'></div>
<div class='box1'></div>
</div>
</div>

if i change width:900px in the parent div to width:auto then the boxes go underneath one another. That's the problem, the parent div should auto adjust to the width of both boxes.

i'd really appreciate someone solving this. i can't have a fixed width on the parent div it should auto adjust and both boxes should be next to each other.

MDanz 0 Junior Poster

i tried this but it didn't work. the box go beneath one another.

<style type="text/css">
  #parent {
overflow:scroll;
width:100px;
}


.box1 {

border:1px solid black;
float: left;
height: 101px;
overflow-x: hidden;
overflow-y: scroll;
padding-right: 15px;
width: 101px;
}
</style>


<div id='parent'>
<div class='box1'></div>
<div class='box1'></div>
</div>
MDanz 0 Junior Poster

i don't understand .. in my code do i apply this to the parent div?

MDanz 0 Junior Poster

how do i make the overflow:scroll horizontal rather than vertical in the example below

http://www.w3schools.com/css/tryit.asp?filename=trycss_overflow

MDanz 0 Junior Poster

i want box 1 and box 2 horizontally next to each other. I want the parent div if the content overflows to scroll and box1 and box2 horizontally next to each other.

i tried below but box2 keeps going underneath box1. the scroll is necessary.

<div id='parent'>
<div id='box1'></div>
<div id='box2'></div>
</div>

#parent {
overflow:scroll;
width:100%;
}

#box1 {
float:left;
width:100px;
height:100px;
}

#box2 {
float:left;
}
MDanz 0 Junior Poster
$getrest =  mysql_query("SELECT * FROM block WHERE sid='$id' ORDER BY `id` DESC",$this->connect);

while($row1 = mysql_fetch_assoc($getrest)) {

$idz = $row1['id'];

$getmore =  mysql_query("SELECT * FROM block WHERE sid='$idz' ORDER BY `id` DESC",$this->connect);					
							 while ($row2 = mysql_fetch_assoc($getmore)) {

}

}

you see i'm using the result from the first query in the where clause of the second query. This isn't good practice as what i'm trying to accomplish could lead me doing this up to ten times. what would be a better way to do this than while loops inside of while loops?


example?

MDanz 0 Junior Poster

thanks for the help but the id's are random, they come from mysql. so subtracting 1, won't help.

e.g.
[id=239] [id=456,boxid=239][id=123,boxid=456] etc

would an array be the best way to do this? because i can't keep on doing while loops inside of while loops to get the previous id.

MDanz 0 Junior Poster

i've been doing while loops for this problem .. i dont think its the right way though.

i have a set of boxes each with a boxid(apart from the first), which is the id(mysql) of the previous box.

e.g.
box 1 has id 1
box 2 has id 2 and boxid 1,
box 3 has id 3 and boxid 2 etc

you see the boxid is the same as the previous id.

i want 10 boxes to display , when i'm trying to loop this i am using a while loop, but i keep on having to use another while loop inside, just to match the boxid with previous id to get the next box to display. so i would have to do 10 while loops inside one another, which isn't good practice.

is there a better way to do this? for loop?

another example

e.g.
box 1 has id 239
box 2 has id 456 and boxid 239,
box 3 has id 123 and boxid 456 etc

MDanz 0 Junior Poster

the following should return 1 row

$search= "Timothy";

$query4 = mysql_query("SELECT * FROM test1, test2, combination WHERE test1.IDONE = `combination`.IDONE AND test2.IDTWO = combination.IDTWO AND test1.NAME LIKE '%$search%'",$this->connect) or die(mysql_error());

instead it returns zero.

the query should take values from all three tables according to the where clause.

in short to describe the table structure.

3 tables(test1, test2, combination)

test1 has primary key IDONE, test2 has primary key IDTWO

combination looks like this

CREATE TABLE `combination` (
IDONE int(8) NOT NULL,
IDTWO varchar(11) NOT NULL,
INFO char(200) NOT NULL,

INDEX (IDONE, IDTWO),
PRIMARY KEY (IDONE,IDTWO),
FOREIGN KEY (IDTWO) REFERENCES `test2` (IDTWO)  ON UPDATE CASCADE ON DELETE CASCADE,
FOREIGN KEY (IDONE) REFERENCES `test1` (IDONE) ON UPDATE CASCADE ON DELETE CASCADE
) ENGINE=INNODB;

i havent done the relational database wrong.. there is no mysql_errors either. any idea?

MDanz 0 Junior Poster

I want to loop the below code until $grade=80, is the code below correct

<?php 


include "grade.php"; 

		$getgrade = new Grade(); // create an instance of the class(Grade)

	echo "<ul id='navigation'>";

	for($grade=0;$grade<80;$grade+10){

	$max = $grade+9; 
	
	echo "<li><a href='#'>$grade-$max%</a>
		<ul><li>";

		$getgrade->results($grade+9); 

		echo "</li></ul>
	</li>";
	
	}

	echo "</ul>";
		

 ?>

the page isn't loading when i try it so i'm guessing i got it wrong..

MDanz 0 Junior Poster
CREATE TABLE Student{SID int( 8 ) NOT NULL AUTO_INCREMENT ,
SNAME varchar( 200 ) NOT NULL default,
ADDRESS text NOT NULL default,
POST_CODE varchar( 10 ) NOT NULL default,
PHOTO mediumblob NOT NULL default,
PRIMARY KEY ( SID ) } ENGINE = INNODB;

for this i get this error

#1064 - 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 '{ SID int(8) NOT NULL auto_increment, SNAME varchar(200) NOT NULL default, ' at line 1

MDanz 0 Junior Poster

when i put this in phpmyadmin i get errors... can anyone look over it and find a mistake..

CREATE TABLE Student {

SID int NOT NULL default,
SNAME varchar(200) NOT NULL default,
ADDRESS text NOT NULL default,
POST_CODE varchar(10) NOT NULL default,
PHOTO mediumblob NOT NULL default,

Primary Key (SID)


} ENGINE=INNODB



CREATE TABLE Course {

CID int NOT NULL default,
CNAME varchar(200) NOT NULL default,
DEPARTMENT text NOT NULL default,

Primary Key (CID)

} ENGINE=INNODB


CREATE TABLE Student-Course {
SID int NOT NULL default,
CID int NOT NULL default,
GRADE varchar(200) NOT NULL default,
COMMENTS text NOT NULL default,

Primary Key (SID,CID),
FOREIGN KEY (CID) REFERENCES Course (CID)  ON UPDATE CASCADE ON DELETE CASCADE,
FOREIGN KEY (SID) REFERENCES Student (SID) ON UPDATE CASCADE ON DELETE CASCADE
} ENGINE=INNODB
MDanz 0 Junior Poster
foreach ($items as $product ) {
echo $product;
?><input type="text" size="2" value="<?php  
\\display quantity here
  ?>" name="quantity" /><?php
}

$items is an array. It has multiple values, some duplicate. How do i count the duplicate values in the array and display in this foreach loop?

i know array_count_values($product) but putting that in the foreach loop won't accomplish what i want.

another thing. i can get the foreach loop to not display duplicates by doing this

foreach (array_unique($items) as $product ) {
echo $product;
?><input type="text" size="2" value="<?php  
\\display quantity here
  ?>" name="quantity" /><?php
}

how would i accomplish both.

basically i want it to display the quantity without displaying duplicate rows. aka shopping cart.

MDanz 0 Junior Poster

i'm having trouble getting this to work. i want mysql to delete a row where the word 'example' is within a paragraph of a column.

e.g. in the column reply.. it has a paragraph with the word 'example' in it.

$deletebadreply1=  mysql_query("DELETE FROM `Reply` WHERE `reply` LIKE '%example%'") or die (mysql_error());

i tried the above and it isnt deleting the row. how do i resolve this?