3 Replies - 1201 Views - Last Post: 08 September 2012 - 07:11 AM Rate Topic: -----

#1 himanshu123  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 06-September 12

<br /><b>Warning</b>: mysql_fetch_array() exp

Posted 06 September 2012 - 10:11 PM

<form method="POST" action="">
			
						
<input type="text" name="T1" value="<?php $x=$_POST["D1"]; echo $x; ?>" size="20" readonly></p>
						  
						
					
<input type="text" name="T2" value="<?php
$con=mysql_connect("localhost","root","");
mysql_select_db("evincere",$con);
$s="select*from enquery2 where st_name=$x";
$result=mysql_query($s,$con);
$r=mysql_fetch_array($result);
echo $r['st_address']
?>" size="20" readonly> 


Is This A Good Question/Topic? 0
  • +

Replies To: <br /><b>Warning</b>: mysql_fetch_array() exp

#2 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 2899
  • View blog
  • Posts: 7,555
  • Joined: 08-June 10

Re: <br /><b>Warning</b>: mysql_fetch_array() exp

Posted 06 September 2012 - 10:47 PM

your query fails. I would stab a guess at some missing spaces in the SQL query.

besides that
- the old mysql extension is outdated, use the more modern PDO or MySQLi extensions instead
- you’re wide open to SQL Injection
- never ever connect as root except for administrative purposes
- separate HTML and PHP, this will make understanding the code much easier
- use spaces and indentation extensively, the PHP engine does not care about them and doesn’t get slower because of that. but your readability increases significantly
Was This Post Helpful? 4
  • +
  • -

#3 BrairMoss  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 15
  • View blog
  • Posts: 79
  • Joined: 13-April 10

Re: <br /><b>Warning</b>: mysql_fetch_array() exp

Posted 08 September 2012 - 06:27 AM

You are also missing a semi-colon at the end of your last echo statement.
Was This Post Helpful? 0
  • +
  • -

#4 JackOfAllTrades  Icon User is online

  • Saucy!
  • member icon

Reputation: 5676
  • View blog
  • Posts: 22,538
  • Joined: 23-August 08

Re: <br /><b>Warning</b>: mysql_fetch_array() exp

Posted 08 September 2012 - 07:11 AM

Honestly, it's just horrible code X 1000
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1