PHP Upgrade?

Status
Not open for further replies.

r3bol

New Member
Messages
5
Reaction score
0
Points
0
Help! I have no idea what PHP upgrade means. I've looked around the CP and can't find anything to configure PHP or request an upgrade.
In my CP stats it says - PHP version 5.2.6. Do I need to upgrade PHP?

Thanks :biggrin:
 

Christopher

Retired
Messages
14,659
Reaction score
8
Points
0
We offer basic, intermediate, and advanced php configurations.

For most people basic is good. If you get PHP errors request intermediate. You shouldn't need advanced.

Only request advanced if you are told to do so by a administrator.
 

r3bol

New Member
Messages
5
Reaction score
0
Points
0
Does this mean I need to upgrade then?...
test php page...
<?php
$a = 123
echo "hello " . $a . '456';
?>
error...
Parse error: syntax error, unexpected T_ECHO in /home/leke/public_html/test.php on line 3
 

Brandon

Former Senior Account Rep
Community Support
Messages
19,181
Reaction score
28
Points
48
Your syntax is wrong, try this.

Code:
<?php
$a = 123;
echo "hello " . $a . '456';
?>

You missed the ; in the 2nd line.
 

r3bol

New Member
Messages
5
Reaction score
0
Points
0
Ok, how about this error?
Warning: fopen(http://rebol.pcriot.com/dic/new_test.html) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections in /home/leke/public_html/submit_script.php on line 65

Warning: fwrite(): supplied argument is not a valid stream resource in /home/leke/public_html/submit_script.php on line 72

Warning: fclose(): supplied argument is not a valid stream resource in /home/leke/public_html/submit_script.php on line 73
Is this more bad coding or a needed upgrade?
Here is my script - The file open stuff is near the end...
PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head>
<meta content="text/html; charset=ISO-8859-1" http-equiv="content-type" /><title>REBOL Submit Confirmation</title></head>
<body>
<br>
<?php

// Connect to DB
$conn = mysql_connect("localhost",  "hidden", "hidden_too");
mysql_select_db("leke_reboldb", $conn);
if (!$conn) {
    die("Could not connect to DB: <br />" . mysql_error());
}
echo "Connected to DB successfully <br />";

$word = $_POST[word];
$code = $_POST[code];
$notes = $_POST[notes];

// INSERT data
$sql = "INSERT INTO user_form values ('', '$_POST[word]', '$_POST[code]', '$_POST[notes]')";
if (mysql_query($sql, $conn)) {
    echo "<br />Record added as: <br /><br />" . $word . "<br /><br />" . $code . "<br /><br />" . $notes . "<br />";
} else {
    echo "Error: Failed to INSERT INTO MySQL <br />";
}

// Writes a new file if file doesn't exist >>>>>>
$fileName = 'http://rebol.pcriot.com/dic/' . $word . '.html';

$new_file_content1 = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta content="text/html; charset=ISO-8859-1" http-equiv="content-type" />
  <title>REBOL Word Index</title>
</head>
<body>';
$new_file_content2 = "\n<?php\n\$word = \"$word\";\n?>\n";
$new_file_content3 = '<h1>$word</h1>
<?php
// Connect to DB
$conn = mysql_connect("localhost",  "hidden_again", "hey_guess_what!?");
mysql_select_db("leke_reboldb", $conn);
if (!$conn) {
    die("Could not connect to DB: <br />" . mysql_error());
}
echo "Connected to DB successfully <br />";

// create a SQL statment - only selects type $word
$sql = "SELECT * FROM leke_reboldb WHERE word = " . "\'" . $word . "\'";

// execute the sql statement
$result = mysql_query($sql, $conn) or die(mysql_error());

// go through each row in the result set and display picked data
while ($newArray = mysql_fetch_array($result)) {
// give a name to the fields
$code = $newArray[\'code\'];
$notes = $newArray[\'notes\'];
// echo results on the screen with some formating.
echo "</ br></ br>" . "$code" . "</ br></ br>" . "$notes" . "</ br></ br>";
}
?>
</body></html>';

$handle = fopen($fileName, 'x+');

if (file_exists($fileName)) {
// Do nothing :) zzz
}
else
{
fwrite($handle, "$new_file_content1 . $new_file_content2 . $new_file_content3");
fclose($handle);
}

?>
</body></html>
 

Christopher

Retired
Messages
14,659
Reaction score
8
Points
0
You are opening a file using the http protocol. You need to open the file you are trying to write to as a local file.
 

r3bol

New Member
Messages
5
Reaction score
0
Points
0
aha, the error makes more sense now :) Thanks, I'll look into it.
Edit:
Thanks, everything seems to be working now - except, I can create new files, but I am having trouble writing content to them.

for example...
PHP:
$handle = fopen($fileName, 'w'); // I tried 'a' and '+x' too.  

if (file_exists($fileName)) {
// Do nothing :) zzz
}
else
{
fwrite($handle, "$new_file_content1 . $new_file_content2 . $new_file_content3");
fclose($handle);
}
Am I making some obvious mistake here?
And thanks, I really appreciate all the help I've gotten here. You have been very nice and patient with me!
 
Last edited:
Status
Not open for further replies.
Top