Ready, steady… save!
You don’t need a chart to join in. Here are 2 ways to record your savings:
1. Cross it off
Pop a chart into your first post. Saved an amount? Cross it out! Read more »
£0.01 £0.02 £0.03
2. Write it down
Skip the chart and add updates to your first post. Read more »
“Another +£3 saved today. Go me!”
Use +£ before each new saving so it counts towards your total.
We’d like to remind Forumites to please avoid political debate on the Forum.
This is to keep it a safe and useful space for MoneySaving discussions. Threads that are – or become – political in nature may be removed in line with the Forum’s rules. Thank you for your understanding.
mysql 4.1 & php5
Lychee
Posts: 448
Forumite
in Techie Stuff
Anyone who is familiar with mySQL 4.1 ...
I've been trying all day to open a connection via php5 to mySQL 4.1 database :
<?php
$connection=mysqli_connect("localhost","user","password");
mysqli_select_db($connection, "thisDatabase");
$result = mysqli_query($connection, "SELECT * FROM thisTable");
..........
but I get this error message :
Parse error: syntax error, unexpected T_VARIABLE on Line 3 - which is the $connection line
I've used mysql_connect, mysql_pconnect but they don't work either! I haven't a clue what the syntax error can be... unless there's something I haven't configured right... I'm also using Apache 1.3
any help much appreciated!
thanks in advance
I've been trying all day to open a connection via php5 to mySQL 4.1 database :
<?php
$connection=mysqli_connect("localhost","user","password");
mysqli_select_db($connection, "thisDatabase");
$result = mysqli_query($connection, "SELECT * FROM thisTable");
..........
but I get this error message :
Parse error: syntax error, unexpected T_VARIABLE on Line 3 - which is the $connection line
I've used mysql_connect, mysql_pconnect but they don't work either! I haven't a clue what the syntax error can be... unless there's something I haven't configured right... I'm also using Apache 1.3
any help much appreciated!
thanks in advance
0
Comments
-
why not use the mysqli code as shown on the php site...
<?php
$link = mysqli_connect("localhost", "my_user", "my_password", "world");
/* check connection */
if (!$link) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
printf("Host information: %s\n", mysqli_get_host_info($link));
/* close connection */
mysqli_close($link);
?>
try that and see what error messages you get? see if its the same...pm me if you want more and i can look further, unfortunately ive only actually coded in php4 not 5...
neil0 -
thanks neil...have also sent a pm. the code you gave gives me this :
Fatal error: Call to undefined function mysqli_connect() ... on line 2
*sob* :P This is really annoying...0 -
There is information on php.net site which suggests the mysqli_connect function is for versions of PHP5 obtained from the CVS only. If you have version 5, and its not working that could be the reason. You would then have to checkout a copy of the PHP 5 source from the CVS server and compile it yourself. This is easy if you have access to a unix shell, although I have no idea how to do it in windows.
The first error is suggestive of the fact you have missed something out though... so if this code is part of a file, its worth posting the whole lot, including the start and end tags.
The second error is more likely to be the CVS thing.
http://uk2.php.net/manual/en/function.mysqli-connect.php
It says:
mysqli_connect
(no version information, might be only in CVS)
I'm like the previous poster... php4 only here.0 -
i would be inclined to agree with the person before in the assumption you havent got the most recent and supported version of php5...you say you tried myql_connect??
<?php
$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
mysql_close($link);
?>
update--> may be worth having a look at here -> http://www.dbforums.com/t1044828.html may have some usefull info!
neil0 -
NellyLock wrote:i would be inclined to agree with the person before in the assumption you havent got the most recent and supported version of php5...you say you tried myql_connect??
<?php
$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
mysql_close($link);
?>
update--> may be worth having a look at here -> http://www.dbforums.com/t1044828.html may have some usefull info!
neil
Connected successfully !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
LoL!
please refrain from going "DUH!" and smacking your head kinda hard but...
I initially downloaded the PHP 5 installer thinking that was all I needed. obviously the N.B. no external extensions included meant nothing to me:P but after looking at the above link from NellyLock, I realised I was missing a few very important things :P so downloaded the PHP 5 ZIP package instead, followed instructions from http://www.dbforums.com/t1044828.html and voila... I can sleep tonight. mysqli_connect doesnt seem to work though. The code above works perfectly.
Many many many many many many many many thank yous to NellyLock and newfoundglory for the help
0 -
right... now I want to connect to the database via php from my Flash movie. I'm trying to use phpObject... anyone familiar with that or Flash Remoting in general?0
-
not done any flash for a LONG time and to be honest i didnt realise that it could be linked with mysql/php now (it couldnt when i learnt it!) anyway heres a link that looks like it could be of help http://actionscript-toolbox.com/samplephpmysql.php but i cant get you any definitive answers.
neil0 -
NellyLock wrote:not done any flash for a LONG time and to be honest i didnt realise that it could be linked with mysql/php now (it couldnt when i learnt it!) anyway heres a link that looks like it could be of help http://actionscript-toolbox.com/samplephpmysql.php but i cant get you any definitive answers.
neil
wa-hey! spent the whole day reading endless forums, many outdated and I was starting to wonder whether phpObject is compatible with PHP5 :P anyway, I've got my database connected and feel very satisfied... and tired !
Thanks for the link neil. unfortunately, that's Flash 5 and I'm using Flash MX Pro.0 -
Can i asked how or were you all learnt .php ??
I am looking for a course now !0 -
self taught, although helps to know other languages not nesc scripting languages. if you want to learn and need to ask any specific questions i will try my best to help!
neil0
This discussion has been closed.
Categories
- All Categories
- 356K Banking & Borrowing
- 255K Reduce Debt & Boost Income
- 456.3K Spending & Discounts
- 248.5K Work, Benefits & Business
- 606.3K Mortgages, Homes & Bills
- 179.1K Life & Family
- 264.1K Travel & Transport
- 1.6M Hobbies & Leisure
- 16.2K Discuss & Feedback
- 37.7K Read-Only Boards