nav33n 472 Purple hazed! Team Colleague Featured Poster

You need to store the values in a table when someone votes. In that way, a user can vote only once. Displaying the result in % can be done by simple math calculation. I haven't worked with images, so, I am not very sure about graphs.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Everytime? Do do you want a lame remark about that ? ;)

ehm.. ;)

nav33n 472 Purple hazed! Team Colleague Featured Poster

<offtopic> Cscgal, everytime I see your profile, I see different "solved threads" count ! Sometimes its 109, sometimes 110 and now its 108 ! :-/ how and why ? </offtopic>

nav33n 472 Purple hazed! Team Colleague Featured Poster

http://nl2.php.net/language.variables.variable
I don't prefer using this because its too difficult to keep track of what is in $var. If something goes wrong in the script, for example, $var is empty, then that will cause a total failure.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Simple. The first time you follow the link, you will have the id. <input type="hidden" name="id" value="<?php echo $id; ?>"> where $id is id's value.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Heh.. so, notices were the culprit here ? eh ? But, this code isn't really "brilliant". But it works. You can tune it a little more!
Umm.. It shouldn't take 2 clicks to sort. Because, first time, no records will be sorted. When you click on a column, it will see if $order is set. If its set to asc, it will change it to desc and vice versa. So, it has to do its work anyway. Strange ! :-/ But I am glad its atleast working !

nav33n 472 Purple hazed! Team Colleague Featured Poster

huh.. Thats strange.. Disable notices and try again.. The page is refreshed since its reloaded again. Strange.

nav33n 472 Purple hazed! Team Colleague Featured Poster

pass id in a hidden field when the form is submitted. Use $_REQUEST instead of $_GET. $_REQUEST can handle both $_GET and $_POST. Thats all !
Oh, have session_start on top of your script.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Here are some things you need to fix.
You are checking if $_GET is set. Say, for example, the user follows a link and gets to this page. comments.php?id=4 . Then it will enter the condition isset($_GET) and does the required action. But, when the user fills in the comment and clicks on submit, $_GET doesn't hold any value anymore. So, it skips isset($_GET) block.
Secondly, there is no session_start. And, most importantly, don't use @ to supress the errors. You will never know where you are going wrong.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Umm..strange! I haven't used much of exec's. Lets see if someone else has an answer..

nav33n 472 Purple hazed! Team Colleague Featured Poster

stristr does the same as strstr. But stristr is case-insensitive. ie., stristr("This is a test","IS"); will return true since "IS" is found in "This". Whereas, strstr("This is a test","IS"); will return false (since "IS" doesn't match with "is").

Cheers,
Nav

nav33n 472 Purple hazed! Team Colleague Featured Poster

Looks ok to me. I don't understand. What error are you getting ? What do you mean by sorting errors ?

nav33n 472 Purple hazed! Team Colleague Featured Poster

:-/ Can you post your latest code ?

nav33n 472 Purple hazed! Team Colleague Featured Poster

:) Did you change all the column links ?

nav33n 472 Purple hazed! Team Colleague Featured Poster

Then the links should be dbphone_new.php in all these cases.

<th><a href="sort.php<?php echo $value1 ?>">First Name</th>

nav33n 472 Purple hazed! Team Colleague Featured Poster

What have you named this script ? Is it called sort.php ?

nav33n 472 Purple hazed! Team Colleague Featured Poster

Nope. I have no idea what the function "left" is used for. The best way to debug your code is to echo custom messages to know the flow of the script. If you think the php tag is causing the problem, then check what the function "left" returns. You might have an exit in the function !

nav33n 472 Purple hazed! Team Colleague Featured Poster

umm.. col is the column name which you want to sort.. Is it working for you ?

nav33n 472 Purple hazed! Team Colleague Featured Poster

Umm..

if($row['col1'] == "2008") {
//print
} //else do nothing

If the record in the table has more than 2008, for example, some text with it, you can try it this way.

<?php
$str = "test - 2008 is as boring as 2007";
if(strstr($str,"2008")) {
	echo "2008 found!";
} else {
	echo "2008 not found!";
}
?>
OmniX commented: Always helpful as usual :) +1
nav33n 472 Purple hazed! Team Colleague Featured Poster

This checks if form variable msg is set and is not null. If its true, then print it ! :)

nav33n 472 Purple hazed! Team Colleague Featured Poster

Dude! check the hyperlink.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Woah ! Thats a lengthy code. One thing I noticed. Everything is in a function and that function isn't called. Just before the include, call the function main();

nav33n 472 Purple hazed! Team Colleague Featured Poster

Well, notices can be ignored. But if you want to get rid of notices without disabling it, initialize every variable before using it. Here is an example.

<?php
error_reporting(E_ALL);
$arr = array();
echo $arr['1'];
?>

This will generate the notice undefined index since $arr doesn't have any value and isn't initialized where as, this wouldn't generate any notice.

<?php
error_reporting(E_ALL);
$arr = array();
$arr['1']="";
echo $arr['1'];
?>
nav33n 472 Purple hazed! Team Colleague Featured Poster

from index.php ..

nav33n 472 Purple hazed! Team Colleague Featured Poster

:) It should work with OR.. But anyway, cheers!

nav33n 472 Purple hazed! Team Colleague Featured Poster

Note: Enabling E_NOTICE during development has some benefits. For debugging purposes: NOTICE messages will warn you about possible bugs in your code. For example, use of unassigned values is warned. It is extremely useful to find typos and to save time for debugging. NOTICE messages will warn you about bad style. For example, $arr[item] is better to be written as $arr since PHP tries to treat "item" as constant. If it is not a constant, PHP assumes it is a string index for the array.

Source : http://nl3.php.net/manual/en/errorfunc.configuration.php#ini.error-reporting

Btw, notices can be ignored. Check if col1, col2,... col7 exists in the table !

nav33n 472 Purple hazed! Team Colleague Featured Poster

Truncate is used to delete all the records from the table. You should use delete with a condition to delete single record.

nav33n 472 Purple hazed! Team Colleague Featured Poster

In some cases: yes. In the town were I live we have 'bicycle-zones'. That's means you're welcome with your car, but you have to let every bicyclist before you.

ah! Thats why everybody stops when I arrive ! ;) I like it !

nav33n 472 Purple hazed! Team Colleague Featured Poster
$query = "select * from table where home_phone like '%516%' OR work_phone like '%516%' OR mobile_phone like '%516%'";
nav33n 472 Purple hazed! Team Colleague Featured Poster

Not just Dallas. Dutch police are actually given financial targets to meet each year for traffic violations, split by category (speeding, red lights, etc.) as well as targets for impounded vehicles (which are sold for profit by the government), impounded driver's licenses (which mean someone needs to take another driving test, fee to go to the government), etc.

The grand total of all those fines is something like several hundred million Euro per year, a decent sized chunk of the total government budget.
And they still maintain that those fines are only "to promote road safety by making people think twice about violating the law".

Wow ! no wonder Dutch people follow traffic rules so obediently ! And, I guess, people on bicycle are given the highest priority ?

nav33n 472 Purple hazed! Team Colleague Featured Poster
<?php
echo "hi";
ob_flush();
flush();
exec("taskmgr.exe");
?>

This works !

nav33n 472 Purple hazed! Team Colleague Featured Poster

Try this.

<?php 

// set database server access variables: 
$host = "localhost"; 
$user = "root"; 
$pass = ""; 
$db = "test"; 

// create query 
$conn=mysql_connect($host,$user,$pass);
mysql_select_db($db);
if(isset($_GET['col']) && isset($_GET['order'])) {
	$column=$_GET['col'];
	$order=$_REQUEST['order'];
	if($column == "fname"){
		if($order=="asc"){ $order="desc"; } else {
$order="asc"; }
		$value1="?col=fname&order=$order";
		$query="select * from orders order by $column $order";
	}
	if($column == "lname"){
		if($order=="asc"){ $order="desc"; } else {
$order="asc"; }
		$value2="?col=lname&order=$order";
		$query="select * from orders order by $column $order";
	}
	if($column == "phone_num"){
		if($order=="asc"){ $order="desc"; } else { 
$order="asc"; }
		$value3="?col=phone_num&order=$order";
		$query="select * from orders order by $column $order";
	}
	if($column == "ext"){
		if($order=="asc"){ $order="desc"; } else {
$order="asc"; }
		$value4="?col=ext&order=$order";
		$query="select * from orders order by $column $order";
	}
	if($column == "title"){
		if($order=="asc"){ $order="desc"; } else {
$order="asc"; }
		$value5="?col=title&order=$order";
		$query="select * from orders order by $column $order";
		}
	if($column == "dept"){
		if($order=="asc"){ $order="desc"; } else {
$order="asc"; }
		$value6="?col=dept&order=$order";
		$query="select * from orders order by $column $order";
		}
	if($column == "fax"){
		if($order=="asc"){ $order="desc"; } else {
$order="asc"; }
		$value7="?col=fax&order=$order";
		$query="select * from orders order by $column $order";
} 
} else {
		$value1="?col=fname&order=asc";
		$value2="?col=lname&order=asc";
		$value3="?col=phone_num&order=asc";
		$value4="?col=ext&order=asc";
		$value5="?col=title&order=asc";
		$value6="?col=dept&order=asc";
		$value7="?col=fax&order=asc";
		$query="select * from orders";
}  //I had to add this one or I got an invalid $end error
$result=mysql_query($query);
?>

<html>
<body>
<table border=1>
<th><a href="sort.php<?php echo $value1 ?>">First Name</th>
<th><a href="sort.php<?php echo $value2 ?>">Last Name</th>
<th><a href="sort.php<?php echo $value3 ?>">Phone Number</th>
<th><a href="sort.php<?php echo $value4 ?>">Extension</th>
<th><a href="sort.php<?php echo $value5 ?>">Title</th>
<th><a href="sort.php<?php echo $value6 ?>">Department</th>
<th><a href="sort.php<?php echo $value7 ?>">Fax Number</th>
<?php
while($row=mysql_fetch_array($result)){
	print "<tr>
	<td>".$row['col1']."</td> …
nav33n 472 Purple hazed! Team Colleague Featured Poster

You are welcome :)

nav33n 472 Purple hazed! Team Colleague Featured Poster

Yes. It displays everything it fetches for that particular id. You can limit your output by choosing what to print. As you can see, $row is an array. $row will have 7, $row will have "Ecuador offers to buy out oil companies" and so on.. Check this out.
http://nl3.php.net/mysql_fetch_array
This is how you can print only newsTit value.

//news.php
//db connection
$id = mysql_real_escape_string($_GET['id']);
$query = "select * from newstable where id = '$id'";
$result = mysql_query($query);
$row = mysql_fetch_array($result);
print $row['newsTit'];
?>
peter_budo commented: Good work, well done +8
nav33n 472 Purple hazed! Team Colleague Featured Poster

Change the table name (and column name) !

nav33n 472 Purple hazed! Team Colleague Featured Poster

Can you post relevant code ?

nav33n 472 Purple hazed! Team Colleague Featured Poster

In news.php, request id's value and fetch the data from the table for that particular id.
For example, news.php?id=4

//news.php
//db connection
$id = mysql_real_escape_string($_GET['id']);
$query = "select * from newstable where id = '$id'";
$result = mysql_query($query);
$row = mysql_fetch_array($result);
print_r($row); //display the news for id = 4
?>
nav33n 472 Purple hazed! Team Colleague Featured Poster

$level = $_SESSION;
$_SESSION["level"] = 1;
$_SESSION["level"] = 2;
$_SESSION["level"] = 3;

You are assigning 1, 2, 3 to $_SESSION. In the end, the value in $_SESSION would be 3. Here is a simple example.

//test.php
<?php
$value = 100;
if($value < 100 ) {
   $_SESSION['level'] = 1;
} elseif ($value == 100 ) {
    $_SESSION['level'] = 2;
} else {
    $_SESSION['level'] = 3;
}
include "check.php";
?>

And this is check.php

<?php
session_start();
echo $_SESSION['level'];
?>

This is just an example to show you how sessions work.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Can you be more specific ?

nav33n 472 Purple hazed! Team Colleague Featured Poster

Try this.

echo'<input name="tradeaid" type="hidden" id="tradeaid" value="'.$tradeaid.'">';
echo'<input name="mtitle" type="hidden" id="mtitle" value="'.<$mtitle.'">';
echo'<input name="nmain" type="hidden" id="nmain" value="'.nmain.'">';
echo '<tr><td width="90% align=left"><a onclick="submit();">'. $stitle. '</s></td></tr>';

I think its a bad practice to use <?=$varname instead of <?php echo $varname; ?>

Edit: And please use code tags while posting your code. It really helps.

nav33n 472 Purple hazed! Team Colleague Featured Poster

echo'<input name="tradeaid" type="hidden" id="tradeaid" value="<?=tradeaid?>">';
echo'<input name="mtitle" type="hidden" id="mtitle" value="<?=mtitle?>">';
echo'<input name="nmain" type="hidden" id="nmain" value="<?=nmain?>">';

missing $ in the values.

nav33n 472 Purple hazed! Team Colleague Featured Poster

$level = 1 isn't correct. Since you are comparing the value of $level, you need to use comparison operator. http://nl.php.net/operators.comparison
Secondly, where are you assigning the value to $_SESSION ? I think the value is being overwritten or something. Btw, there is no session_start() in check.php. When you assign the value to the session variable, check whats in it. In check.php, check print out the session variable value and cross check !

nav33n 472 Purple hazed! Team Colleague Featured Poster

nah! nothing.. I am just scared of Aljazeera ;)

nav33n 472 Purple hazed! Team Colleague Featured Poster

What's the structure of the table ?

nav33n 472 Purple hazed! Team Colleague Featured Poster

Order by multiple columns work this way.
For example, you have 4 records.

field1 | field2 | field3 | field4
-------+-------+--------+----------
1 | 1 | 2 | 4
-------------------------------------
2 | 2 | 100 | 5
-------------------------------------
3 | 2 | 1 | 3
-------------------------------------
4 | 3 | 500 | 6
-----------------------------------
5 | 2 | 1 | 2

If your query is,

$query = "select * from table order by field2,field3,field4";

the result would be,

field1 | field2 | field3 | field4
-------+-------+--------+----------
1 | 1 | 2 | 4
-------------------------------------
5 | 2 | 1 | 2
---------------------------------------
3 | 2 | 1 | 3
-------------------------------------
2 | 2 | 100 | 5
-------------------------------------
4 | 3 | 500 | 6
-------------------------------------

As you can see, it sorts field2 first. Then it sorts field3 maintaining the order of field2. Then maintaining the order of field2 and field3, it sorts field4.

I know my explanation isn't really good ! (Or is it more confusing ?)

Note: If you don't specify how you want to sort your records, it will sort in ascending order by default.

nav33n 472 Purple hazed! Team Colleague Featured Poster
nav33n 472 Purple hazed! Team Colleague Featured Poster

Heh.. maybe "c" and "d" are varchar fields and the rest are integer fields ? Simplest way to debug this problem is to print out the query and see what does it have at the runtime. Then execute it in phpmyadmin or mysql console. Doing so, you will know where exactly is the error.
Note: Varchar fields need to be wrapped within single quotes while integer fields dont need single quotes.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Thats it ? Its not entering the for loop ? Well, then there is the problem. Check your for loop and see if the values are being posted.

nav33n 472 Purple hazed! Team Colleague Featured Poster
$sql="INSERT INTO guests (guest_name, guest_email) VALUES";
for($i=0;$i<sizeof($_POST['username']);$i++){

$sql.="('".mysql_real_escape_string($_POST['username'][$i])."','".mysql_real_escape_string($_POST['email'][$i])."')";
if(!$i==sizeof($_POST['username'])){
$sql.=",";
}
}
echo $sql;

What does it print ?

nav33n 472 Purple hazed! Team Colleague Featured Poster

Print your query and execute it in mysql console/phpmyadmin.. Also show us the query ..