Kadafiz commented: thank you +0
<?php
print_r($_GET);
?>
i never tried including a php file using javascript external, if you really want to include a php file user php include() or require() instead
hey zagga i also had problem on sending mail, i cannot send even if i edited my php.ini mail setting i get from thunderbird SMTP setting.
[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = smtp.googlemail.com
; http://php.net/smtp-port
smtp_port = 465
; For Win32 only.
; http://php.net/sendmail-from
sendmail_from = vaultdweller123@gmail
so is it fixed?
yeah i found it, the jfunction has no closing parenthesis.
change it from
onclick="jfunc('.$row["id"].','.$row["event"].','.$i.'"
to
onclick="jfunc('.$row["id"].','.$row["event"].','.$i.')"
you can click it to see the error part... then paste it here so i can examine
i don't know why its not calling the jfunc(), where did you put the javascript? can u put it on the head <head> section of the page, coz i dont know what's wrong here
that's weird??? coz. i can redirect here in my test
this is just a sample script so i can test the redirection
<script type="text/javascript">
function jfunc(athlete,event,res){
var result = document.getElementById('time'+res).value;
window.location = "?athlete="+athlete+"&event="+event+"&res="+result;
}
</script>
<a href='javascript:void(0)' onclick="jfunc(1,1,1)" />click</a><input type="text" name="time1" id="time1" />
ok...upon clicking the update button did it reload? can you paste the query string? i mean the url generated upon clicking the update. coz you will see there if what value are been passed, as i examined you code in order to reach the update and your echoed $sql we have to satisfy the if statement
if ((isset($_GET['action']))&&($_GET['action']=='UpdateResult'))
if clicking the update button regenerates this url
mathleteresults.php?action=UpdateResult&athlete_id=187&event=100m swim&result=1:30
so that means we had these data
$_GET = 'UpdateResult'
$_GET = 187
$_GET = '100m swim'
$_GET = '1:30'
so because of the $_GET = 'UpdateResult' we satisfied the if statement and we should access the update part.
one way of saying thanks is marking this thread solved :)
coz there is wrong with you update
$sql = "UPDATE event_results set result='".$i."' Where event='$event' and athlete_id='$id'";
why are you passing the $i?
it should be
$id = $_GET['athlete_id'];
$event = $_GET['event'];
$result = $_GET['result'];
$sql = "UPDATE event_results set result='".$result."' Where event='".$event."' and athlete_id='".$id."'";
lol you didn't put a value fied on you option tag
<option style="width: 170px;">1</option>
changed it to
<option style="width: 170px;" value="1">1</option>
what ie version? 6, 7 or 8?
are you sure? that seems like the database schema you gave to me, well if that's really the file name then try editing this part
from
window.location='?action=UpdateResult&athlete_id='+athlete+'&event='+event+'&result='+result;
to
window.location='mathleteresults.php?action=UpdateResult&athlete_id='+athlete+'&event='+event+'&result='+result;
may i know the name of your main php file?
this code
// Make the query:
$query = "SELECT * FROM athlete,events,event_results where athlete.athlete_id = event_results.athlete_id
and events.event = event_results.event ORDER BY $order_by LIMIT $start, $display";
$res = mysql_query($query);
echo '<form name="form1" action="mathleteresults.php" method="post">';
// Table header:
echo '<table align="center" cellspacing="0" cellpadding="5" width="155%">
<tr>
<td align="left"><b>Edit</b></td>
<td align="left"><b>Delete</b></td>
<td align="left"><b>FirstName</b></td>
<td align="left"><b>LastName</b></td>
<td align="left"><b><a href="mathleteresults.php?sort=eventorder">Event</a></b></td>
<td align="left"><b><a href="mathleteresults.php?sort=result">Results</a></b></td>
<td align="left"><b>Date</b></td>
</tr>';
// Fetch and print all the records....
$bg = '#eeeeee';
while ($row = sqlFetchArray($res)) {
$bg = ($bg=='#eeeeee' ? '#ffffff' : '#eeeeee');
//echo $a_id;
echo '<tr bgcolor="' . $bg . '">
<td align="left"><a href="?action=UpdateResult&athlete_id=' . $row['athlete_id'] . '&event=' .$row['event'] . '&result=' . $row['result'] .'" >Update </a></td>
<td align="left"><a href="?action=DeleteResult&athlete_id=' . $row['athlete_id'] . '">Delete</a></td>
<td align="left">' . $row['first_name'] . '</td>
<td align="left">' . $row['last_name'] . '</td>
<td align="left"><input name="event" size="10" id="event" value="' . $row['event'] . '"></td>
<td align="left"><input type="text" name="result" id="result" size="8" value="' . $row['result'] . '" ></td>
<td align="left">' . $row['date'] . '</td>
</tr>';
} // End of WHILE loop.
echo '</table>';
echo '</form>';
//request to edit/update result
if ((isset($_GET['action']))&&($_GET['action']=='UpdateResult'))
{ echo "just cant find the result";
$time = $_GET["result"];
$event = $_GET['event'];
$id = $_GET['athlete_id'];
$sql = "UPDATE event_results set result='".$time."' Where event='$event' and athlete_id='$id'";
echo $sql;
$res = sqlQuery($sql); if(sqlErrorReturn()) sqlDebug(__FILE__,__LINE__,sqlErrorReturn());
if (!empty($res))
return 99;
return false;
}
what's the name of this php file?
athlete, event and res are javascript variables, during a click event
<a href="javascript:void(0)" onclick="jfunc('.$row["athlete_id"].','.$row["event"].','.$i.'" />Update</a>
and they will be redirection by using the window.location
window.location='?action=UpdateResult&athlete_id='+athlete+'&event='+event+'&result='+result;
dude try removing your html code in your getList.php, just remain your php code
<?php
$q=$_GET["q"];
$con = mysql_connect('localhost', '********', '********');
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("*******", $con);
$sql="SELECT * FROM resi_list WHERE id = '".$q."'";
$result = mysql_query($sql);
//php code. this loops through the table based on the variable sent.
while($row = mysql_fetch_array($result))
{
echo'<div id="imgDiv">';
echo'<div id="topimg"><img src='. $row['img1'] .' border=0></div>';
echo'<div id="botPics">';
echo'<div id="smallImg1"><img src=' . $row['img2'] . ' border=0></div>';
echo'<div id="smallImg2"><img src=' . $row['img3'] . ' border=0></div>';
echo'<div id="smallImg3"><img src=' . $row['img4'] . ' border=0></div>';
echo'</div>';
echo'</div>';
}
mysql_close($con);
?>
you dont need another html page inside an html page, and kindly remove the <div id="imgDiv">, coz the main page already had that div, and you dont have to create another inside of it.
echo'<div id="topimg"><img src='. $row['img1'] .' border=0></div>';
echo'<div id="botPics">';
echo'<div id="smallImg1"><img src=' . $row['img2'] . ' border=0></div>';
echo'<div id="smallImg2"><img src=' . $row['img3'] . ' border=0></div>';
echo'<div id="smallImg3"><img src=' . $row['img4'] . ' border=0></div>';
echo'</div>';
take note, ie is the most buggy in all browser, so you must be clean in you code coz ie will output incorrect results if you dont.
hope that helps
just take extra careful when you use echo, if you use double qoutes, use single qoutes inside, if you want to use double qoutes then escape it, and if you use single qoutes it vice versa.
example
echo "<input type='text' name='txttest' />";
if you want to use double qoutes inside, escape them
echo "<input type=\"text\" name=\"txttest\" />";
if you use single qoutes on echo then you do the opposite
echo '<input type="text" name="txttest" />';
if you want to use single qoutes inside, escape them
echo '<input type=\'text\' name=\'txttest\' />';
but if you encounter concatenation, you can use single or double qoutes, it doesn't matter coz concatenation makes it outside the string
echo "<input type='text' name='txttest' value='".$row['sample']."' />";
or just use what i have already make for you
this part
echo '<tr bgcolor="' . $bg . '">
<td align="left"><a href="javascript:void(0)" onclick="jfunc('.$row["athlete_id"].','.$row["event"].','.$i.'" />Update</a></td>
<td align="left"><a href="?action=DeleteResult&athlete_id=' . $row['athlete_id'] . '">Delete</a></td>
<td align="left">' . $row['first_name'] . '</td>
<td align="left">' . $row['last_name'] . '</td>
<td align="left"><input name="event" size="10" id="event" value="' . $row['event'] . '"></td>
<td align="left"><input type="text" name="textres'.$i.'" id="textres'.$i.'" value="'.$row['result'].'" /></td>
<td align="left">' . $row['date'] . '</td>
</tr>';
i hope you get my point
hehe your ajax example is from w3schools...
ok first make a database for names, then query them all
then changed this part from an array
// Fill up array with names
$a[]="Anna";
$a[]="Brittany";
$a[]="Cinderella";
$a[]="Diana";
$a[]="Eva";
$a[]="Fiona";
$a[]="Gunda";
$a[]="Hege";
$a[]="Inga";
$a[]="Johanna";
$a[]="Kitty";
$a[]="Linda";
$a[]="Nina";
$a[]="Ophelia";
$a[]="Petunia";
$a[]="Amanda";
$a[]="Raquel";
$a[]="Cindy";
$a[]="Doris";
$a[]="Eve";
$a[]="Evita";
$a[]="Sunniva";
$a[]="Tove";
$a[]="Unni";
$a[]="Violet";
$a[]="Liza";
$a[]="Elizabeth";
$a[]="Ellen";
$a[]="Wenche";
$a[]="Vicky";
to
$sql = mysql_query("SELECT name FROM users"); //sample table users
while($row=mysql_fetch_array($sql)){
$a[] = $row['name'];
}
just read the link for better understanding...
actually you did updated it, but you didn't notice the change coz your still passing the old value....
examine your query string....
<a href="?action=UpdateResult&athlete_id=' . $row['athlete_id'] . '&event=' .$row['event'] . '&result=' . $row['result'] .'" >Update </a>
have you noticed? your result value is equal to the old result value which is $row. your result should be the value of the result textfield not the $row which is the old one. So let's use javascript to get the value of the result textfield.
put this in the head section of your html code
<script type="text/javascript">
function jfunc(athlete,event,res){
var result = document.getElementById('textres'+res).value;
window.location='?action=UpdateResult&athlete_id='+athlete+'&event='+event+'&result='+result;
}
</script>
then replace your old anchor tag from
<a href="?action=UpdateResult&athlete_id=' . $row['athlete_id'] . '&event=' .$row['event'] . '&result=' . $row['result'] .'" >Update </a
to
<a href='javascript:void(0)' onclick="jfunc(<?=$row['athlete_id']?>,<?=$row['event']?>,<?=$i?>)" />Update</a>
and replace your result textfield from
<input type="text" name="result" id="result" size="8" value="' . $row['result'] . '" >
to
<input type="text" name="textres<?=$i?>" id="textres<?=$i?>" value="<?=$row['result']?>" />
then put $i=1 above while ($row = sqlFetchArray($res)) and increment the $i in the end of the loop, it will look something like this
$i = 1;
while ($row = sqlFetchArray($res)) {
$bg = ($bg=='#eeeeee' ? '#ffffff' : '#eeeeee');
echo '<tr bgcolor="' . $bg . '">
<td align="left"><a href="javascript:void(0)" onclick="jfunc('.$row["athlete_id"].','.$row["event"].','.$i.'" />Update</a></td>
<td align="left"><a href="?action=DeleteResult&athlete_id=' . $row['athlete_id'] . '">Delete</a></td>
<td align="left">' . $row['first_name'] . '</td>
<td align="left">' . $row['last_name'] . '</td>
<td align="left"><input name="event" size="10" id="event" value="' . $row['event'] . '"></td>
<td align="left"><input type="text" name="textres'.$i.'" id="textres'.$i.'" value="'.$row['result'].'" /></td>
<td align="left">' . $row['date'] . '</td>
</tr>';
$i++; …
just use my attached sql file, i already created that database for you just change the file extension to .sql ex. test2.sql and import it to your database via phpmyadmin
changed the two &stmt to $stmt
$stmt->bindParam(':username', &username, PDO::PARAM_STR);
$stmt->bindParam(':password', &password, PDO::PARAM_STR, 40);
one thing is for sure.... your PHP tags is not parsed... maybe you have problem on your PHP server, or maybe you didn't put it the root directory or you didn't save it as .php
do you know that in order for you to use php mail() function, u need to set-up a working email system first.
maybe ill get back to you tommorow coz. its already 12:41 am here... it's so late
1st of all re-design your database... coz its very hard to join tables coz your not using foreign keys
paste this code in the SQL portion of phpmyadmin to test the query results
SELECT a.firstname, a.lastname, e.name, er.result, e.date
FROM event_results er
LEFT JOIN athletes a ON ( er.athlete_id = a.id )
LEFT JOIN EVENTS e ON ( er.event_id = e.id )
here just rename this to any name you want and append a .sql ex. test.sql and import it to phpmyadmin
-- phpMyAdmin SQL Dump
-- version 3.2.0.1
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Jun 26, 2010 at 12:29 AM
-- Server version: 5.1.37
-- PHP Version: 5.3.0
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
--
-- Database: `test2`
--
-- --------------------------------------------------------
--
-- Table structure for table `athletes`
--
CREATE TABLE IF NOT EXISTS `athletes` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`firstname` varchar(100) NOT NULL,
`lastname` varchar(100) NOT NULL,
`gender` varchar(100) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;
--
-- Dumping data for table `athletes`
--
INSERT INTO `athletes` (`id`, `firstname`, `lastname`, `gender`) VALUES
(1, 'Naruto', 'Uzumaki', ''),
(2, 'Sasuke', 'Uchiha', '');
-- --------------------------------------------------------
--
-- Table structure for table `events`
--
CREATE TABLE IF NOT EXISTS `events` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(100) NOT NULL,
`category` varchar(100) NOT NULL,
`date` datetime NOT NULL,
`location` varchar(100) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;
--
-- Dumping data for table `events`
--
INSERT INTO `events` (`id`, `name`, `category`, `date`, `location`) VALUES
(1, 'Kunai Throwing', 'men', '2010-06-30 00:08:08', 'Konoha'),
(2, 'Genjutsu Casting', 'women', '2010-06-29 00:08:16', 'Suna');
-- --------------------------------------------------------
--
-- Table structure for table `event_results`
--
CREATE TABLE IF NOT EXISTS `event_results` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`athlete_id` int(11) NOT NULL,
`event_id` int(11) NOT NULL,
`result` time NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;
--
-- Dumping data for table `event_results`
--
INSERT INTO `event_results` (`id`, `athlete_id`, `event_id`, `result`) VALUES
(1, 1, 1, '05:30:00'),
(2, 2, 2, '05:50:00');
redesign your database
if thats the case then that means that the 'result' field in one of your table is null or empty, are you sure that you named it as 'result' not 'results'. As i see you had 3 tables, if you really want me to help you. can you gave me your database schema so i can test it here. Coz i can just imagine here and visualize what are the data in your database. im not sure if you query is right.
yeah dont worry itech7 i believe you... what do you get from lying? nothing...
hmm... whats sqlQuery($sql)?
it should be...
$sql = "UPDATE event_results set result='".$time."' Where event='$event' and athlete_id='$id'";
mysql_query($sql);
yeah i agree.... MAYBE itech7 is lying on screenshots, but i will totally agree on him on the page load, it takes a head ache waiting on page loads, good thing i can hover on threads to see its description before i click a thread i want to engage.
what does your $row holds in your database? if it's an image then you dont just echo it directly, you have to put it on an <img> tag
echo "<img src='".$row['content']."' />";
i hope i get your point :)
depends on your php server, like WAMP you save your .php file in the "www" folder, or if you use XAMPP you save it in the "htdocs" folder.
the arrow sign "->" is used to reference objects from its function/methods and properties
1st keep in mind that inorder for you to use php mail() function, you should set-up a working email system
the username should be root if you use the default
mysql_connect("localhost","root","")
why do you have to extract() the result? when you can already traverse the recordset via mysql_fetch_array. and when you do extract you dont use arrays anymore like $row coz extract() assign values to array indexes so instead of echo $row you use $content. you may try this
<?php
$query = sprintf("SELECT * FROM property_images JOIN property ON property.id = property_images.property_id ORDER BY property_images.id DESC LIMIT 0 , 30");
$result = mysql_query($query, $db) or die('Error, query failed');
if (mysql_num_rows($result) == 0) { echo "Error: property has no images. "; }
else {
while ($row = mysql_fetch_array($result)) {
header('Content-type: ' . $row['uploadedimage_type']);
header('Content-length: ' . $row['uploadedimage_size']);
echo $row['content']; } // end while
} // end else
?>
<script type="text/javascript">
function ftest(){
window.location="totherecievingpagedatabasesave.php?test="+document.getElementById('test').value;
}
</script>
<input type="text" name="test" id="test" />
<a href="javascript:void(0);" onclick="ftest()">click me</a>
then get the text box variable on the receiving end via $_GET;
strings should be enclosed with quotes, single or double
if(isset($id) && $id=="benelli")
and also the equals sign "=" is an assignment operator, not an equality operator used for comparison, use the equality operator "==" instead
it doesn't matter if the letter "L" in location is in small caps... it will still redirect...
or you could try this, if u think the header() still doesn't work
echo "<script>window.location='http://www.websitename/members/securecode/index.php'</script>";
maybe because in the first place it didn't satisfy your if statement
if($dbpasswword == $passwd)
because if it does, it should redirect... i don't see anything wrong on the php header() function
rajarajan was right... it's all about file permission. You must edit it either through ftp or explicitly define it using php chmod() function. set the permission to 0775
it wont display dude coz its a tag. i dont what kind of tag is that but you actually created it... try viewing the source code and youll see that your tag has been created.
one way of saying thanks is marking this thread solved.
there's no problem with the code... i don't think the problem came there... it might be the code before that. Try reviewing your code.
have you really doin some effort? havnt you noticed you had no opening curly brace( { ) in your switch in criteria. line 11.
I wanna say that im not lazy even since i've started posting in this forum..for your higher information, every single code or i mean syntax you've posted,i always try to search the meaning,the function of that code..i have a tutorial here PHP and Javascript.And if you didn't know,i learned..i've gained new knowledge in some of your code.Yeah i searched,but if i do not find any answer,i just post in this forum..and ask some help..and yeah,i copy the code here but not all the codes i've asked here were copy and paste..well, it's your opinion and view of point,but you can't see me while thinking,debugging all the codes..Ya,learning comes from asking,and when you ask,there's an explanation why..Just ask and you learn something new..im not a typical person that you know copy and paste the codes, i searched. study the all the PHP codes in w3schools,print it so that i have a hard copy here..tnx for your commented..
i really hope it's true as we are taking our time and effort on helping you here. About your error in search, you said that there's an error. can you show us the error?. coz. i didn't find any wrong in the code.