Jump to content

need help... php newbie!


imes_bedo

Recommended Posts

Hi. I've been assigned to handle the website of my org and the entire website is made in php which i have no idea of.

 

Anyway, somehow, I managed to do some stuff but... on my file uploader, i keep getting this error

 

Warning: mysql_result() [function.mysql-result]: Unable to jump to row 0 on MySQL result index 5

 

I really don't know what it means so... please help me! I need to finish this by tomorrow.

Link to comment
https://forums.phpfreaks.com/topic/52285-need-help-php-newbie/
Share on other sites

first error code:

<?php if($_SESSION["user_login"]=="yes"){
$file_id=$_REQUEST["file"];
$folder_id=$_REQUEST["folder"];

mysql_connect($host_name,$username,$password);

@mysql_select_db($database) or die( "Unable to select database");

$query="SELECT * FROM file where file_id='$file_id';";

$result=mysql_query($query);

$num=@mysql_numrows($result);
mysql_close();


$temp_date = mysql_result($result,$i,"date_created");

?>

 

second error code:

 

<form action="pro_picture_delete.php" method="post" name="form1">
	<tr>
		<td colspan="2">
		<table width="742" border="0" cellspacing="0" cellpadding="0" height="100%">
			<tr>
				<td width="246"></td>
				<td colspan="2" class="v2" height="100%" valign="top"><br>
				<p align="center">
				<font face="Verdana" size="2" color="#666666"><?php echo mysql_result($result,$i,"file_title"); ?></font></b>
				</p>
				<p align="center">
				<a href="Uploads/<?php echo mysql_result($result,$i,"file_name");?>.doc"">Click Here to Download File</a>
				</p>
				<p align="center">
				<font face="Verdana" size="1" color="#666666">posted - <?php echo monthNumToWholeName(getMonth($temp_date))." ".getDay($temp_date).", ".getYear($temp_date); ?> 
				- </font><br>
				<br>
				</p>
				<p align="left"><b><a href="../imes_downloads.php">
				<font face="Verdana" size="2" color="#666666">back to folders</font></b></a>
				<font face="Verdana" size="2" color="#666666">: </font><b>
				<a href="view_picture.php?folder=<?php echo $folder_id ?>">
				<font face="Verdana" size="2" color="#666666">back to file</font></b></a>
				</p>
				</td>
			</tr>

 

The lines that had the error is the $temp_date one and the $result,$i,"file_title" in the second one.

 

I really need help. I need to finish this by tomorrow. Thanks. ^^

Link to comment
https://forums.phpfreaks.com/topic/52285-need-help-php-newbie/#findComment-258203
Share on other sites

When you use the mysql_result() function, it needs to have the row number to retrieve the data from. You are passing it the variable $i, but that variable is not defined anywhere.

 

Also the "@" character suppresses error messages, so you really don't know what is happening with your code.

 

I suggest that for testing purposes, you do the following:

<?php
if($_SESSION["user_login"]=="yes"){
$file_id=$_REQUEST["file"];
$folder_id=$_REQUEST["folder"];
mysql_connect($host_name,$username,$password);
mysql_select_db($database) or die( "Unable to select database<br>" . mysql_error());
$query="SELECT * FROM file where file_id='$file_id';";
$result=mysql_query($query) or die("Problem with the query:<pre>$query</pre><br>" . mysql_error());
$num=mysql_numrows($result) or die("Problem getting number of rows<br>" . mysql_error());
if (num > 0) {
    $rw = mysql_fetch_assoc($result);
    $temp_date = $rw["date_created"];
}	 
?>

 

Do something similar in the second area.

 

Ken

Link to comment
https://forums.phpfreaks.com/topic/52285-need-help-php-newbie/#findComment-258245
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.